임베딩이란 기계 학습 모델과 알고리즘이 쉽게 사용할 수 있는 주어진 입력의 벡터 표현(or 벡터 값)
POST https://api.openai.com/v1/embeddings | Creates an embedding vector representing the input text. | |
Request body | model (string / 필수) | ID of the model to use. |
input (string or array / 필수) | Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed 8192 tokens in length. | |
user (string / 선택) |
Request 시 (curl 사용 )
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The food was delicious and the waiter...",
"model": "text-embedding-ada-002"
}'
Parameters
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
Response 값
{
"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
}
}