埋め込みを作成します
POST
https://api.openai.com/v1/embeddings
Request
Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.Example:
Authorization: Bearer ********************
Header Params
Authorization
string
optional
Example:
Bearer {{YOUR_API_KEY}}
Body Params application/json
input
string
required
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
required
encoding_format
string
required
float
or base64
.Example
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
Request samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.openai.com/v1/embeddings' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}'
Responses
🟢200Create embeddings
application/json
Body
object
string
required
data
array [object {3}]
required
object
string
optional
embedding
array[number]
optional
index
integer
optional
model
string
required
usage
object
required
prompt_tokens
integer
required
total_tokens
integer
required
Example
{
"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
}
}
Modified at 2024-12-17 04:18:00