POST/v1/embeddings

Create embedding

Create vector embeddings for one or more text inputs. OpenAI-compatible request and response. Unknown fields in the request body are rejected. There is no streaming response for this endpoint.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

4 body fields
modelstringrequired
Model id to use for embeddings. Must match a model your account can access.
inputstringrequired
A single string or 1–2048 strings; each string produces one row in `data`, in order.
userstringoptional
Optional end-user identifier to help with abuse monitoring.
encoding_formatstringoptional
How embedding values are returned in each `data[].embedding` field.
Allowed:floatbase64Default:float

5 status codes
200Embeddings and usage for the given `input` or `inputs`, in order.
objectstringrequired
The object type, which is always the string `list`.
Allowed:list
modelstringrequired
The embedding model that produced the vectors.
dataarray<object>required
One entry for each `input` string, in the same order.
usageobjectrequired
Token usage for the embeddings request.
401Authentication failed due to invalid credentials.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.
429The API rate limit has been exceeded.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.
500There was a server error.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.
defaultThere was an unexpected error.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.

Error handling

A 401 is returned: Authentication failed due to invalid credentials. A 429 is returned: The API rate limit has been exceeded. A 500 is returned: There was a server error. Any other status is an error: There was an unexpected error.