Embeddings
Turn text into vectors with the cruxy-embed model.
POST /api/v1/embeddings takes one string or an array and returns a
vector per input, ready to store and compare for search, clustering, or
retrieval. It is OpenAI-compatible. Here is a single-string embedding:
curl https://api.cruxy.ai/api/v1/embeddings \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cruxy-embed",
"input": "The quick brown fox"
}'const res = await fetch('https://api.cruxy.ai/api/v1/embeddings', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'cruxy-embed',
input: 'The quick brown fox',
}),
})
const { data } = await res.json()
const vector = data[0].embedding // number[]The model
model must be "cruxy-embed". It is the only embedding model on the
gateway.
Single string or array
input accepts either a single string or an array of strings. Pass an
array to embed a batch in one call:
curl https://api.cruxy.ai/api/v1/embeddings \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cruxy-embed",
"input": ["The quick brown fox", "jumps over the lazy dog"]
}'Each input maps to one entry in data, and the entry's index matches
the position of its input.
Response shape
{
"object": "list",
"model": "cruxy-embed",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0117]
}
],
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
},
"cruxy": {
"request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"cost": { "tier": "cruxy-embed" }
}
}The embedding array is shown truncated; a real vector holds many more
floats. The cost object carries the same fields documented under
Chat.
| Field | Meaning |
|---|---|
object | Always "list". |
data | One embedding entry per input, each with its index and embedding vector. |
usage | prompt_tokens and total_tokens for the request. |
cruxy | Additive block with the request_id and cost (see Chat). |
The embedding array holds the vector as floating-point numbers. Read a
result at data[i].embedding, matching data[i].index to your input's
position.
Errors
Embeddings returns 400 for a malformed request, 401 for a bad key,
and 429 for rate_limited or budget_exhausted. See
Errors.
Next steps
- Retrieval-augmented generation: index a corpus and answer from it, end to end.
- Rerank: order retrieved candidates against a query.
- Chat: completions across the tiers.
- Errors: the error shape.