Create embeddings
POST
https://api.openai.com/v1/embeddingsGet a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
Related guide: Embeddings
Creates an embedding vector representing the input text.
Request
ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed the max input tokens for the model (8191 tokens for text-embedding-ada-002
). Example Python code for counting tokens.
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
Request samples
Responses
{
"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
}
}