Embeddings

POST /v1/embeddings turns text into vectors in OpenAI's Embeddings format. Point the OpenAI SDKs, LangChain or LlamaIndex at https://api.zdr.sh/v1 and they work. The request is served by a model the catalog marks as an embedding model; Models lists the ones your key can use.

Request#

FieldTypeNotes
modelstringRequired. An embedding model id. A chat model is refused with 400 model_endpoint_mismatch
inputstring or arrayRequired. The text, or up to 2,048 texts. No item may be empty, each must fit the model's window, and the body is at most 4 MiB
encoding_formatstringfloat (default) or base64
dimensionsintegerThe vector's size, within the model's range
userstringAn end-user id recorded with the usage. It is never sent to a model

An array of token ids is refused: another tokenizer's vocabulary would give a wrong vector without an error.

Response#

json
{  "object": "list",  "data": [{ "object": "embedding", "index": 0, "embedding": [0.0023, -0.0091] }],  "model": "<your model id>",  "usage": { "prompt_tokens": 6, "total_tokens": 6 }}

data holds one entry per input, in order; model is the id you asked for; usage.prompt_tokens is what the request is billed at. The response carries the usual headers, x-token-cost included.

Billing and limits#

  • An embedding model is paid for input tokens only, per 1M. There is no output or cached bucket.
  • The request counts against the key's rate limits and spend caps, and holds one concurrency slot while it runs.
  • It is admitted against the balance exactly as a chat request is, with the same 402 insufficient_balance.
  • Nothing is cached and nothing is kept: neither the response cache nor any store holds the vector.

Refusals#

guard_credentials reads the input texts before they are sent: an API-key-shaped string is replaced with [REDACTED:<kind>], and the vector encodes the placeholder. guard_injection does not run, because no model reads the text as instructions.

The refusals use the chat codes: 400 invalid_request naming the field (input, encoding_format, dimensions), 400 model_endpoint_mismatch for a chat model, 404 not_found_model when no model is available, 413 request_too_large over 4 MiB, and 429 at a rate limit.