POST /v1/embeddings
Method: POSTEndpoint: /v1/embeddings
Get a vector representation of the given input that can be used easily by machine-learning models and algorithms.
Related Guide: Embeddings
Create an embedding vector representing the input text.
Request Parameters
Header Parameters
text
Authorization
string
Optional
Default Value:
Bearer {{YOUR_API_KEY}}Body Parameters application/json
text
model
string
Required
The ID of the model to use. You can use
List models
the API to view all available models, or review our
model overview
to understand their descriptions.
input
string
Required
Input text for embeddings, encoded either as a string or as an array of tokens. To request embeddings for multiple inputs in one call, pass an array of strings or an array of token arrays. Each input must not exceed 8192 tokens.
Example
{
"model"
:
"string"
,
"input"
:
"string"
}Example Request
Shell
bash
curl --location --request POST '/v1/embeddings' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "string",
"input": "string"
}'Response
🟢 200 Create embeddings
Content Type: application/json
Response Schema
text
object
string
Required
data
array
[object]
Required
object
string
Optional
embedding
array
[number]
Optional
index
integer
Optional
model
string
Required
usage
object
Required
prompt_tokens
integer
Required
total_tokens
integer
RequiredExample
json
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
.... (1536 floats total for ada-002)
-0.0028842222
],
"index": 0
}
],
"model": "text-embedding-ada-002",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}