亮色模式
Create embeddings
POST
https://api.openai.com/v1/embeddingsCreates an embedding vector representing the input text.
Request
Header 参数
Authorization
string
必需
示例值:
Bearer $OPENAI_API_KEY
Content-Type
string
必需
示例值:
application/json
Body 参数application/json
input
string
必需
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. The input must not exceed the max input tokens for the model (8192 tokens for text-embedding-ada-002
), cannot be an empty string, and any array must be 2048 dimensions or less. Example Python code for counting tokens.
model
string
必需
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.
encoding_format
string
必需
The format to return the embeddings in. Can be either float
or base64
.
示例
{
"input": "The food was delicious and the waiter...",
"model": "text-embedding-ada-002",
"encoding_format": "float"
}
Request samples
返回响应
Success(200)
HTTP Code: 200
Content Type : JSONapplication/json
数据结构
object
string
必需
data
array [object {3}]
必需
object
string
可选
embedding
array[number]
可选
index
integer
可选
model
string
必需
usage
object
必需
prompt_tokens
integer
必需
total_tokens
integer
必需
示例
{
"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
}
}
最后修改时间: 10 天前