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"
  }'

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.

FieldMeaning
objectAlways "list".
dataOne embedding entry per input, each with its index and embedding vector.
usageprompt_tokens and total_tokens for the request.
cruxyAdditive 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

Was this page helpful?