OpenAI-compatible API · Embeddings

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.

POST /v1/embeddings Base URL: https://monkeytheme.com/v1 Auth probes: 401 only

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.

401POST /v1/embeddings without key → API_KEY_REQUIRED
401POST /v1/embeddings invalid key → INVALID_API_KEY
404POST /embeddings (no /v1) → nginx HTML 404
404GET /v1/embeddings → 404 page not found
The auth layer is reachable on POST /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.

FieldRequiredNotes from OpenAPI
inputYesString, 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.
modelYesModel id string. Schema examples include text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002.
encoding_formatNofloat (default) or base64.
dimensionsNoOnly for text-embedding-3 and later. Shortens the returned vector when the upstream model supports it.
userNoEnd-user identifier for abuse monitoring on providers that honor it.
Capability boundary: This page does not claim every listed official model id is enabled on your MonkeyAI account. After auth works, confirm ids with 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).

CheckWhy it matters
data length matches input countBatch inputs should return one vector per input, preserving order via index.
Vector length is stable for the same modelChanging dimensions or model id changes length. Do not mix vector sizes in one index.
usage.prompt_tokens / total_tokensBilling and batch sizing depend on tokens, not on character count alone.
Store model id with the vectorsRe-embedding later with a different model invalidates similarity comparisons.

Decision path when something fails

  1. Confirm hostname monkeytheme.com and Base URL https://monkeytheme.com/v1.
  2. Call GET /v1/models with the same key. If that is 401, fix auth first (401 guide).
  3. Copy an exact embedding model id from the list. Do not invent names from memory.
  4. POST /v1/embeddings with a short string input.
  5. If you see HTML 404, the path is wrong (often missing /v1 or wrong host).
  6. 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.”
  7. 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

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.