Amanai Docs
API reference
Shared authentication, discovery, headers, lifecycle, and error conventions across the Amanai API.
Base URL
https://api.amanai.dev/v1 The API is HTTPS-only. Use dedicated modality guides for request fields and examples; this page defines the behavior shared by every endpoint.
Authentication
Pass an Amanai API key as a Bearer token. Anthropic-compatible clients may use x-api-key where the SDK expects it.
Authorization: Bearer sk-amanai-...
# Anthropic-compatible alternative
x-api-key: sk-amanai-... Keys can carry model scopes, budgets, rate limits, and expiry. Treat them as secrets and never expose them in browser code, logs, filenames, or query strings.
Endpoint directory
Chat
Messages, Responses, and tools.
Media
Image, video, and speech generation and processing.
Realtime
Live WebRTC voice sessions.
Embeddings
Text vectors for search and retrieval.
Rerank
Relevance ordering for documents.
System One
Typed decisions from state and questions.
Chat
| Method | Path | Description |
|---|---|---|
POST | /v1/chat/completions | OpenAI Chat Completions |
POST | /v1/responses | OpenAI Responses |
POST | /v1/messages | Anthropic Messages |
Media
| Method | Path | Description |
|---|---|---|
POST | /v1/images/generations | Generate an image |
POST | /v1/images/edits | Edit a source image |
POST | /v1/videos | Create a durable video job |
GET | /v1/videos/{id} | Read video progress and result |
POST | /v1/audio/speech | Synthesize speech |
POST | /v1/audio/transcriptions | Transcribe audio |
POST | /v1/files | Upload an owner-scoped file |
GET | /v1/artifacts/download/{token} | Download an expiring artifact |
Realtime
| Method | Path | Description |
|---|---|---|
POST | /v1/realtime/calls | Negotiate a WebRTC session |
DELETE | /v1/realtime/sessions/{id} | Release a Realtime session |
Embeddings & rerank
| Method | Path | Description |
|---|---|---|
POST | /v1/embeddings | Create text embeddings |
POST | /v1/rerank | Rank documents against a query |
System One
| Method | Path | Description |
|---|---|---|
POST | /v1/systemone | Evaluate a state with typed questions |
Catalog & account
| Method | Path | Description |
|---|---|---|
GET | /v1/models | List models available to the caller |
GET | /v1/usage | Read balance and recent usage |
GET | /calculate/models | List quoteable pricing specifications |
GET | /calculate | Quote one request shape |
Common headers
| Header | When to send it | Behavior |
|---|---|---|
Authorization | Every authenticated request | Bearer sk-amanai-... |
Content-Type | JSON or multipart requests | Must match the endpoint contract. |
Idempotency-Key | Media creation, upload, and other retryable mutations | Retry the exact same logical operation with the same key. |
X-Amanai-Realtime-Control-Token | Realtime cleanup | Authorizes release of one established session. |
Discovery and source of truth
Use authenticated discovery whenever a client exposes model selectors:
GET /v1/models
GET /v1/models?type=embedding
GET /v1/models?type=rerank System One uses model amanai/jev-1.13 and its own native request format; do not send it to a chat endpoint.
The catalog is key-aware. A model absent from the response must not be offered to that key. Use GET /calculate/models and GET /calculate for quoting; use Billing & pricing for the public explanation of each unit.
Async operations and ownership
- Chat and image operations normally return synchronously or stream on the same connection.
- Video uses a durable job: submit, poll the returned ID, then use the completed artifact URL.
- Realtime keeps one session across multiple turns and requires explicit cleanup.
- Files, jobs, sessions, and artifact grants are bound to the authenticated owner.
- Generated artifact URLs can expire and should not be treated as permanent hosting.
Errors
For Chat Completions, Messages, Responses, and Messages token counting, errors use the codes below. Read error.code for programmatic handling; error.type follows the endpoint format. Messages errors also include type: "error". Requests that fail before usable delivery are not charged; partially delivered streaming usage can be settled.
Example: HTTP 503 temporary unavailability.
{
"error": {
"message": "The selected model is temporarily unavailable. Please try again shortly.",
"type": "model_temporarily_unavailable",
"code": "model_temporarily_unavailable"
}
} | HTTP status | Code | Message | What to do |
|---|---|---|---|
400 | invalid_client_request_id | The X-Request-ID header is invalid. | Use a valid X-Request-ID header. |
400 | invalid_file | The supplied file could not be read. Check its format and try again. | Check the file format and encoding. |
400 | invalid_image | The supplied image could not be read. Check its format and try again. | Check the image format and encoding. |
400 | invalid_reasoning_effort | The requested reasoning effort is not supported by this model. | Choose a supported reasoning effort. |
400 | invalid_request_error | The request contains an invalid or missing field. Check the request format and parameter values. | Check the JSON body and required fields. |
400 | invalid_tool_history | The conversation contains unmatched tool calls or tool results. Check the tool-call history and try again. | Match each tool result to its original tool-call ID. |
400 | output_token_limit_exceeded | The requested output limit is too large. Reduce max_tokens or max_output_tokens and try again. | Reduce max_tokens or max_output_tokens. |
400 | request_blocked_by_policy | This request could not be processed under the service safety policy. | Review and revise the request before trying again. |
400 | streaming_required | This response could not be completed in buffered mode. Retry with stream=true. | Retry with stream=true. |
400 | unsupported_model_for_endpoint | The selected model does not support this endpoint. Use a compatible endpoint. | Choose a compatible endpoint. |
400 | unsupported_request_parameter | The requested tool selection format is not supported by this model. | Use a supported tool selection format. |
400 | unsupported_tools | The selected model does not support the supplied tool configuration. | Use a supported tool configuration or compatible model. |
401 | invalid_api_key | The API key is missing or invalid. | Check the Authorization header and your API key. |
402 | insufficient_credits | Insufficient credits for this request. | Add credits or reduce the requested reserve. |
403 | free_flagship_daily_cap | Your daily limit for this model has been reached. Try another model or wait for the daily reset. | Use another model or wait for the daily reset. |
403 | key_expired | This API key has expired. | Renew or replace the expired API key. |
403 | key_revoked | This API key has been revoked. | Create or use an active API key. |
403 | permission_denied | This account or API key does not have permission to perform this request. | Check your account and API key permissions. |
404 | model_not_found | The requested model was not found. Check the model ID. | Check the public model ID in /v1/models. |
413 | request_too_large | The request payload is too large. Reduce the attachment or request size and try again. | Reduce the payload, attachments, or conversation history as indicated. |
422 | unsupported_input_modality | The selected model cannot process the supplied media. Choose a compatible model. | Choose a model that supports this input. |
429 | client_error_cooldown | This request is temporarily limited after repeated processing errors. Please retry later. | Wait, then check repeated request errors. |
429 | concurrency_limit | Too many requests are running. Wait for an active request to finish. | Wait for an active request to finish. |
429 | image_requests_temporarily_limited | Image requests are temporarily limited. Please retry later. | Wait before sending more image requests. |
429 | ip_rate_limit | Too many requests from this network. Please retry later. | Reduce requests from your network and retry later. |
429 | model_rate_limited | Too many of your requests for this model are waiting. Please retry shortly. | Wait before sending another request for this model. |
429 | rate_limit | Your request limit has been reached. Please wait before retrying. | Wait before retrying; honor Retry-After when present. |
500 | internal_error | An internal error occurred. Please try again or contact support with the request ID. | Retry with backoff. Contact support with the request ID if it persists. |
500 | token_count_failed | Token counting could not be completed. Please retry. | Retry with backoff. Contact support with the request ID if it persists. |
502 | empty_model_response | The model returned no usable response. Please retry. | Retry with backoff. Contact support with the request ID if it persists. |
502 | invalid_model_response | The model returned a response that could not be processed. Please retry. | Retry with backoff. Contact support with the request ID if it persists. |
502 | invalid_model_tool_arguments | The model returned invalid or incomplete tool arguments. | Do not execute incomplete arguments. Retry or contact support. |
502 | invalid_model_tool_call | The model returned a tool call that was not defined in your request. | Do not execute the invalid tool call. Retry or contact support. |
502 | request_processing_failed | The service could not process this request. Contact support with the request ID if the problem persists. | Retry once if appropriate, then contact support with the request ID. |
502 | stream_interrupted | The response was interrupted before completion. Any partial output may be incomplete. | Treat partial output as incomplete. Check tool actions before retrying. |
502 | tool_generation_limit_exceeded | The model did not complete a tool call within the generation limits. | Retry with backoff. Contact support with the request ID if it persists. |
503 | model_temporarily_unavailable | The selected model is temporarily unavailable. Please try again shortly. | Retry with backoff. Contact support with the request ID if it persists. |
503 | service_busy | The service is temporarily busy. Please retry shortly. | Retry with backoff. Contact support with the request ID if it persists. |
504 | generation_timeout | The model did not produce a response in time. Please retry. | Retry with backoff. Contact support with the request ID if it persists. |
504 | stream_idle_timeout | The response stopped making progress and could not be completed. | Treat partial output as incomplete. Check tool actions before retrying. |
504 | stream_time_limit_exceeded | The response reached its maximum execution time before completion. | Treat partial output as incomplete. Check tool actions before retrying. |
504 | token_count_timeout | Token counting did not finish in time. Please retry. | Retry with backoff. Contact support with the request ID if it persists. |
Specific message variants identify invalid JSON, a confirmed context limit, or a cybersecurity policy decision. They keep the same code and HTTP status as the corresponding row:
request_blocked_by_policy: This request could not be processed because it was flagged for possible cybersecurity risk.request_too_large: The conversation exceeds the supported context limit. Shorten or compact it and try again.invalid_request_error: The request body is not valid JSON.
Other failures use model_temporarily_unavailable with the temporary-unavailability message above. Do not infer a specific cause from that code.
Streaming and buffered responses
HTTP status describes an error only before response headers are sent. A response that has already started can retain HTTP 200 and later contain an error. Chat Completions sends a data: error object; Messages sends event: error; Responses sends event: response.failed with response.error.code and response.error.message. A buffered JSON response can also finish with an error body after initial whitespace. Always inspect the body and terminal event rather than HTTP status alone.
Partial text or tool arguments are incomplete when a stream fails. Do not execute an incomplete tool call. Before retrying an action, check whether it already ran to avoid duplicates.
Retrying and support
Correct request, authentication, permission, credit, context, and policy errors before retrying. For temporary failures, use bounded retries with exponential backoff and jitter. Honor a numeric Retry-After header when present. Do not retry repeatedly without a delay.
Save the X-Amanai-Request-ID response header when contacting support. Messages responses also expose request-id and errors include request_id. A valid caller-supplied X-Request-ID is echoed separately. Include the public model, endpoint, approximate time, and request ID; never share your API key.
Other API families, including durable media jobs, can use endpoint-specific codes documented on their own pages.