curl --request POST \
--url https://api.example.com/v1/embeddings \
--header 'Content-Type: application/json' \
--data '
{
"input": [
"<string>"
],
"model": "<string>",
"dimensions": 123,
"encoding_format": {},
"user": "<string>"
}
'{
"data": [
{
"embedding": {},
"index": 123,
"object": "<string>"
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
},
"object": "<string>"
}Create embeddings using the configured provider
curl --request POST \
--url https://api.example.com/v1/embeddings \
--header 'Content-Type: application/json' \
--data '
{
"input": [
"<string>"
],
"model": "<string>",
"dimensions": 123,
"encoding_format": {},
"user": "<string>"
}
'{
"data": [
{
"embedding": {},
"index": 123,
"object": "<string>"
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
},
"object": "<string>"
}client.embeddings.create(params)
text-embedding-ada-002text-embedding-3-smalltext-embedding-3-largetext-embedding-3 and later models.float or base64.Default: floatShow data object
"list".const response = await client.embeddings.create({
model: "text-embedding-3-small",
input: "The quick brown fox jumps over the lazy dog"
});
console.log(response.data[0].embedding);
// [0.0023, -0.0091, 0.0234, ...]
const response = await client.embeddings.create({
model: "text-embedding-3-small",
input: [
"First document to embed",
"Second document to embed",
"Third document to embed"
]
});
console.log(response.data.length); // 3
console.log(response.usage.total_tokens);
const response = await client.embeddings.create({
model: "text-embedding-3-large",
input: "Reduce dimensionality for storage",
dimensions: 256
});
console.log(response.data[0].embedding.length); // 256
const response = await client.embeddings.create({
model: "text-embedding-3-small",
input: "Get embeddings as base64",
encoding_format: "base64"
});
console.log(typeof response.data[0].embedding); // "string"
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [
0.0023064255,
-0.009327292,
0.015797347,
-0.0077559738,
-0.004068857,
// ... (1536 dimensions for text-embedding-3-small)
]
}
],
"model": "text-embedding-3-small",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}