OpenAI-compatible embeddings API setup
Embeddings need a different route from chat. Point the OpenAI SDK at https://monkeytheme.com/v1, call POST /embeddings, prove authentication first, then copy an exact embedding model id from your own /v1/models list.
What this page measured on production
On 2026-08-05, unauthenticated and invalid-key requests hit https://monkeytheme.com. No customer key and no successful vector payload were used.
API_KEY_REQUIREDINVALID_API_KEY404 page not foundPOST /v1/embeddings. That is useful: a 401 with a JSON code means the route exists and your next job is credentials and model selection, not guessing a random path.Request shape (official OpenAPI)
OpenAI's public OpenAPI schema defines CreateEmbeddingRequest with these fields. Use them when the gateway is OpenAI-compatible.
| Field | Required | Notes from OpenAPI |
|---|---|---|
input | Yes | String, string array, token array, or array of token arrays. Empty string is invalid. Max 2048 items in an array. Per-input limit is 8192 tokens for the listed embedding models; request total max is 300,000 tokens. |
model | Yes | Model id string. Schema examples include text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002. |
encoding_format | No | float (default) or base64. |
dimensions | No | Only for text-embedding-3 and later. Shortens the returned vector when the upstream model supports it. |
user | No | End-user identifier for abuse monitoring on providers that honor it. |
GET /v1/models. Optional fields such as dimensions depend on upstream model support; treat unsupported options as an account or model limitation, not a Base URL bug.Curl checks before you touch app code
# 1) Prove the route and auth layer (expect 401 JSON, not HTML)
curl -sS -D- https://monkeytheme.com/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_ID_FROM_YOUR_LIST","input":"hello embeddings"}' | head -40
# 2) Same call with your key (redact before sharing)
curl -sS https://monkeytheme.com/v1/embeddings \
-H "Authorization: Bearer $MONKEYAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_ID_FROM_YOUR_LIST","input":"hello embeddings","encoding_format":"float"}'
# 3) Common path mistake: missing /v1 (production probe returned nginx 404 HTML)
curl -sS -o /tmp/no-v1.txt -w "%{http_code}\n" https://monkeytheme.com/embeddings \
-H "Authorization: Bearer $MONKEYAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_ID_FROM_YOUR_LIST","input":"hello"}'
Keep the HTTP status, JSON code, x-request-id / x-client-request-id headers, model id, and timestamp. Never paste a live Bearer token into tickets or screenshots.
SDK Base URL wiring
# Python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MONKEYAI_API_KEY"],
base_url="https://monkeytheme.com/v1",
)
# After GET /v1/models confirms the id:
resp = client.embeddings.create(
model="MODEL_ID_FROM_YOUR_LIST",
input="The food was delicious and the waiter...",
encoding_format="float",
)
vector = resp.data[0].embedding
print(len(vector), resp.usage)
# Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.MONKEYAI_API_KEY,
baseURL: "https://monkeytheme.com/v1",
});
const resp = await client.embeddings.create({
model: "MODEL_ID_FROM_YOUR_LIST",
input: "The food was delicious and the waiter...",
encoding_format: "float",
});
console.log(resp.data[0].embedding.length, resp.usage);
Official SDK examples call embeddings.create against the configured base URL. If Base URL already ends with /v1, do not add another /v1 in client path settings.
How to read a success response
OpenAPI defines CreateEmbeddingResponse with object: "list", model, data[], and usage. Each data[] item has object: "embedding", index, and embedding (float array when encoding_format=float).
| Check | Why it matters |
|---|---|
data length matches input count | Batch inputs should return one vector per input, preserving order via index. |
| Vector length is stable for the same model | Changing dimensions or model id changes length. Do not mix vector sizes in one index. |
usage.prompt_tokens / total_tokens | Billing and batch sizing depend on tokens, not on character count alone. |
| Store model id with the vectors | Re-embedding later with a different model invalidates similarity comparisons. |
Decision path when something fails
- Confirm hostname
monkeytheme.comand Base URLhttps://monkeytheme.com/v1. - Call
GET /v1/modelswith the same key. If that is 401, fix auth first (401 guide). - Copy an exact embedding model id from the list. Do not invent names from memory.
- POST
/v1/embeddingswith a short string input. - If you see HTML 404, the path is wrong (often missing
/v1or wrong host). - If you see JSON 404/model errors after auth works, treat it as model catalog or upstream support, not as “embeddings is broken for everyone.”
- For 429 or 504 after auth works, use the dedicated rate-limit and timeout guides instead of changing the embeddings path again.
What this page does not claim
It does not claim a measured success vector, a fixed dimension count for MonkeyAI accounts, or that legacy engine paths such as /v1/engines/.../embeddings are supported. The production probe for that legacy path returned 404. It also does not replace your RAG evaluation: cosine similarity only makes sense inside one embedding model space.
Sources and related guides
- OpenAI OpenAPI schema —
CreateEmbeddingRequest/CreateEmbeddingResponsefield definitions used above. - OpenAI embeddings guide — conceptual use cases and current model families.
- Why Base URL usually needs /v1
- API 401 invalid token fix
- Model not found troubleshooting
- Python SDK custom Base URL
- HTTP 429 rate limit fix
FAQ
Do I put /v1 in the Base URL or on the embeddings path?
Use Base URL https://monkeytheme.com/v1. The SDK path is /embeddings, so the full URL becomes https://monkeytheme.com/v1/embeddings. Do not call https://monkeytheme.com/embeddings.
Why did POST /v1/embeddings return 401?
Authentication failed before embedding generation. Missing credentials return API_KEY_REQUIRED. A present but invalid key returns INVALID_API_KEY. Fix the key before debugging vector length or dimensions.
Can I use GET /v1/embeddings?
No. OpenAI's create-embedding operation is POST. On MonkeyAI, GET /v1/embeddings returned 404 page not found in the production probe for this guide.
Which embedding model should I hardcode?
None. Call GET /v1/models with the same key and copy an exact model id that your account can use. Official OpenAPI examples include text-embedding-3-small, text-embedding-3-large and text-embedding-ada-002, but account catalogs differ.
Does a successful chat completion prove embeddings work?
No. Chat and embeddings are different routes and model families. Validate POST /v1/embeddings separately after authentication succeeds.
Was a successful embedding vector generated for this page?
No. This guide used unauthenticated and invalid-key probes only. It does not claim a paid success response or a specific vector dimension from a customer key.