API reference

API reference · API

Create embeddings (OpenAI wire format)

POST/v1/embeddingsAPI keyNo key

Goes through the same dispatch discipline as a completion: key auth, rate limit, key policy, credits, and metering, with completion tokens recorded as zero. Answers 501 unsupported_capability when the upstream that serves the chosen model cannot embed. With no key and x402 on, a 402 names the price; see GET /api/x402.

Request body

application/json, required

Request body fields
FieldTypeWhat it is
modelrequiredstringA catalog model id. At most 200 characters.
inputrequiredstring or array of string or array of integer or array of array of integerA string, or an array of strings or token arrays.
encoding_formatstringOne of "float", "base64".
dimensionsintegerAt most 16384.
userstringAt most 200 characters.

Example

{
  "model": "antimatter/auto",
  "input": "Say hello in five words."
}

Answer 200

The embedding vectors and the prompt token count.

Headers: x-antimatter-upstream, x-antimatter-request-id, x-request-id, x-antimatter-cost-micros, x-antimatter-cost-breakdown, x-antimatter-adjusted, x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-reset

Fields of the 200 answer
FieldTypeWhat it is
objectstring
modelstring
dataarray of object
data[].objectstring
data[].indexinteger
data[].embeddingarray of number
usageobject
usage.prompt_tokensinteger
usage.total_tokensinteger
usage.costnumber
usage.cost_detailsCostDetailsusage.cost_details: what usage.cost is made of, in dollars, summing to it exactly. The same figures as the x-antimatter-cost-breakdown header. Never the upstream's own reported charge.
usage.cost_details.inputnumberPrompt tokens at the upstream's input rate.
usage.cost_details.cached_inputnumberPrompt tokens the vendor served from its cache, at its cache read rate.
usage.cost_details.cache_writenumberPrompt tokens written into the vendor's cache, at its cache write rate.
usage.cost_details.outputnumberAnswer tokens other than reasoning.
usage.cost_details.reasoningnumberReasoning tokens, inside completion_tokens, at the output rate.
usage.cost_details.toolsnumberA paid tool or search beside the tokens.
usage.cost_details.marginnumberThe operator's stated markup on the parts above, less any discount.
usage.cost_details.othernumberWhat no card explains: a replayed cached answer, or an upstream charge above its published card, passed on at cost plus the markup.

Errors

  • 401OpenAI shaped error.
  • 402OpenAI shaped error.
  • 403OpenAI shaped error.
  • 413OpenAI shaped error.
  • 429OpenAI shaped error.
  • 499The client closed the connection before the response finished.
  • 501OpenAI shaped error.
  • 504The upstream did not answer within the gateway's timeout (upstream_timeout).

Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.

Antimatter