ReferenceHTTP API
Embeddings
OpenAI-compatible text embeddings with a project API key.
For SDK setup and credit, see Embeddings.
POST /v1/embeddings
Embeds one or more texts. The request and response follow the OpenAI embeddings API, so an OpenAI-compatible client works with only a base URL change.
- Method and path:
POST /v1/embeddings(alias/api/v1/embeddings) - Auth: bearer API key with
embeddings
Request
Content-Type: application/json, up to 4 MB.
| Field | Type | Notes |
|---|---|---|
input | string or string[] | Required. Not empty. Up to 512 strings. |
model | string | Optional. ratel-embed-v1, or omit it. |
encoding_format | string | Optional. Only float. |
An input longer than the model's window is cut to fit, not rejected.
curl -s https://cloud.ratel.sh/v1/embeddings \
-H "Authorization: Bearer $RATEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "ratel-embed-v1", "input": ["leave a note on the task", "close the ticket"]}'Response
200, in the OpenAI shape:
{
"data": [
{ "index": 0, "embedding": [0.0213, -0.0472, 0.0118] },
{ "index": 1, "embedding": [-0.0094, 0.0381, 0.0257] }
],
"model": "ratel-embed-v1",
"usage": { "prompt_tokens": 12, "total_tokens": 12 }
}Vectors are shortened here. When inputs were cut, the body adds truncated_inputs: the indexes of those inputs.
Each call spends Embeddings credit, by the tokens read.
Errors
The OpenAI envelope: { "error": { "message", "type" } }.
| Status | type | Cause |
|---|---|---|
400 | invalid_request_error | Bad JSON, empty or non-string input, more than 512 inputs, an unsupported model or encoding_format, or the provider rejected the input. |
401 | invalid_request_error | Missing, invalid, revoked or expired key. |
402 | insufficient_quota | Out of Embeddings credit, or the key's workspace no longer exists. |
403 | permission_error | The key does not have embeddings. |
413 | invalid_request_error | Body over 4 MB. |
429 | rate_limit_error | The upstream provider is rate limiting. Retry with backoff. No Retry-After. |
502 | api_error | The upstream provider failed or timed out after 30 seconds. Retry. |
503 | api_error | Embeddings are not configured on this server. |