|
Embeddings API
Generate vector embeddings for semantic search and RAG.
Generate vector embeddings from text for semantic search, similarity matching, and RAG applications.
Basic Request
const response = await cencori.ai.embeddings({
model: 'text-embedding-3-small',
input: 'Hello world'
});
console.log(response.embeddings[0]); // [0.1, 0.2, ...]Batch Request
const response = await cencori.ai.embeddings({
model: 'text-embedding-3-small',
input: [
'First text to embed',
'Second text to embed',
'Third text to embed'
]
});
// response.embeddings is an array of vectors
console.log(response.embeddings.length); // 3Request Parameters
Response
{
embeddings: [
[0.1, 0.2, -0.3, ...],
[0.4, -0.1, 0.2, ...]
],
model: 'text-embedding-3-small',
usage: {
promptTokens: 15,
totalTokens: 15
}
}Model Comparison
HTTP API
curl -X POST https://cencori.com/api/ai/embeddings \
-H "CENCORI_API_KEY: csk_..." \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "Hello world"
}'Use with Memory
Embeddings are automatically generated when storing memories:
await cencori.memory.store({
namespace: 'docs',
content: 'Refund policy allows returns within 30 days'
// Embedding generated automatically
});
