POST /v1/embeddings
POST /openai/v1/embeddings
POST /hf/v1/embeddings
OpenAI-compatible embedding endpoint for Google's Gemini embedding models.
| Model | Status | Cost | Output dim |
|---|---|---|---|
gemini-embedding-001 |
Stable | Free | 3072 (default), configurable via dimensions |
gemini-embedding-2-preview |
Preview | Free | 3072 (default) |
Single input
response = client.embeddings.create(
model="gemini-embedding-001",
input="Hello world"
)
print(response.data[0].embedding[:5])
Batch (list input)
input accepts an array of strings — all of them are embedded in a
single call:
response = client.embeddings.create(
model="gemini-embedding-001",
input=["First document", "Second document", "Third document"]
)
for emb in response.data:
print(emb.index, len(emb.embedding))
Custom output dimensionality
Pass dimensions to reduce vector size — useful for hybrid search,
nearest-neighbour indexes, or storage-constrained applications. Supported
values for gemini-embedding-001: 128, 256, 512, 768, 1536, 3072 (default).
response = client.embeddings.create(
model="gemini-embedding-001",
input="Hello world",
dimensions=768
)
assert len(response.data[0].embedding) == 768
cURL
curl https://gateway.api429.com/v1/embeddings \
-H "Authorization: Bearer $YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-embedding-001",
"input": "Hello world",
"dimensions": 768
}'
Response shape
{
"object": "list",
"model": "gemini-embedding-001",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [-0.0343, 0.0116, -0.0214, ...]
}
],
"usage": {
"prompt_tokens": 2,
"total_tokens": 2
}
}
Notes
- Endpoint is optimised for query-time embeddings (search input, RAG retrieval). Documents-for-index embeddings work the same way — vector quality is identical.
- Empty
inputreturns HTTP 400. - No streaming — embedding responses are always returned in full.
Quickstart: the first request · Models and prices · Get an API key