Embeddings
Convert text into numerical vectors for semantic search, clustering, classification, and retrieval-augmented generation (RAG). Compatible with the OpenAI Embeddings API. Example models include gemini-embedding-001, text-embedding-004, and amazon.titan-embed-text-v2:0 — see the model square for the full list and pricing.
Create Embeddings
POST
https://apicdn.xyc.ai/v1/embeddings
curl https://apicdn.xyc.ai/v1/embeddings \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-embedding-001",
"input": "The quick brown fox jumps over the lazy dog."
}'
from openai import OpenAI
client = OpenAI(base_url="https://apicdn.xyc.ai/v1", api_key="sk-xxxxxxxx")
resp = client.embeddings.create(
model="gemini-embedding-001",
input="The quick brown fox jumps over the lazy dog.",
)
print(resp.data[0].embedding)
You can also pass an array of strings to input to embed multiple texts in a single request:
{
"model": "gemini-embedding-001",
"input": ["First document.", "Second document."]
}
Response
The response follows the OpenAI embeddings shape: a data array where each item carries an embedding vector and its index.
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0123, -0.0456, 0.0789, ...]
}
],
"model": "gemini-embedding-001",
"usage": { "prompt_tokens": 9, "total_tokens": 9 }
}
Request Parameters
| Parameter | Type | Notes |
|---|---|---|
model | string | Required. Embedding model name |
input | string | string[] | Required. Text or array of texts to embed |
encoding_format | string | Optional. float (default) or base64 |
dimensions | integer | Optional. Output vector size, for models that support truncation |
Billing
Embeddings are billed per token at the upstream official rate, with your account's vendor discount applied automatically. Check the model square for current prices.