Amanai Docs

API reference

Shared authentication, discovery, headers, lifecycle, and error conventions across the Amanai API.

Base URL

bash
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.

bash
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

MethodPathDescription
POST/v1/chat/completionsOpenAI Chat Completions
POST/v1/responsesOpenAI Responses
POST/v1/messagesAnthropic Messages

Open the Chat guide →

Media

MethodPathDescription
POST/v1/images/generationsGenerate an image
POST/v1/images/editsEdit a source image
POST/v1/videosCreate a durable video job
GET/v1/videos/{id}Read video progress and result
POST/v1/audio/speechSynthesize speech
POST/v1/audio/transcriptionsTranscribe audio
POST/v1/filesUpload an owner-scoped file
GET/v1/artifacts/download/{token}Download an expiring artifact

Open the Media guide →

Realtime

MethodPathDescription
POST/v1/realtime/callsNegotiate a WebRTC session
DELETE/v1/realtime/sessions/{id}Release a Realtime session

Open the Realtime guide →

Embeddings & rerank

MethodPathDescription
POST/v1/embeddingsCreate text embeddings
POST/v1/rerankRank documents against a query

Open the Embeddings guide → Open the Rerank guide →

System One

MethodPathDescription
POST/v1/systemoneEvaluate a state with typed questions

Open the System One guide →

Catalog & account

MethodPathDescription
GET/v1/modelsList models available to the caller
GET/v1/usageRead balance and recent usage
GET/calculate/modelsList quoteable pricing specifications
GET/calculateQuote one request shape

Open Billing & pricing →

Common headers

HeaderWhen to send itBehavior
AuthorizationEvery authenticated requestBearer sk-amanai-...
Content-TypeJSON or multipart requestsMust match the endpoint contract.
Idempotency-KeyMedia creation, upload, and other retryable mutationsRetry the exact same logical operation with the same key.
X-Amanai-Realtime-Control-TokenRealtime cleanupAuthorizes release of one established session.

Discovery and source of truth

Use authenticated discovery whenever a client exposes model selectors:

bash
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.

bash
{
  "error": {
    "message": "The selected model is temporarily unavailable. Please try again shortly.",
    "type": "model_temporarily_unavailable",
    "code": "model_temporarily_unavailable"
  }
}
HTTP statusCodeMessageWhat to do
400invalid_client_request_idThe X-Request-ID header is invalid.Use a valid X-Request-ID header.
400invalid_fileThe supplied file could not be read. Check its format and try again.Check the file format and encoding.
400invalid_imageThe supplied image could not be read. Check its format and try again.Check the image format and encoding.
400invalid_reasoning_effortThe requested reasoning effort is not supported by this model.Choose a supported reasoning effort.
400invalid_request_errorThe request contains an invalid or missing field. Check the request format and parameter values.Check the JSON body and required fields.
400invalid_tool_historyThe 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.
400output_token_limit_exceededThe requested output limit is too large. Reduce max_tokens or max_output_tokens and try again.Reduce max_tokens or max_output_tokens.
400request_blocked_by_policyThis request could not be processed under the service safety policy.Review and revise the request before trying again.
400streaming_requiredThis response could not be completed in buffered mode. Retry with stream=true.Retry with stream=true.
400unsupported_model_for_endpointThe selected model does not support this endpoint. Use a compatible endpoint.Choose a compatible endpoint.
400unsupported_request_parameterThe requested tool selection format is not supported by this model.Use a supported tool selection format.
400unsupported_toolsThe selected model does not support the supplied tool configuration.Use a supported tool configuration or compatible model.
401invalid_api_keyThe API key is missing or invalid.Check the Authorization header and your API key.
402insufficient_creditsInsufficient credits for this request.Add credits or reduce the requested reserve.
403free_flagship_daily_capYour 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.
403key_expiredThis API key has expired.Renew or replace the expired API key.
403key_revokedThis API key has been revoked.Create or use an active API key.
403permission_deniedThis account or API key does not have permission to perform this request.Check your account and API key permissions.
404model_not_foundThe requested model was not found. Check the model ID.Check the public model ID in /v1/models.
413request_too_largeThe request payload is too large. Reduce the attachment or request size and try again.Reduce the payload, attachments, or conversation history as indicated.
422unsupported_input_modalityThe selected model cannot process the supplied media. Choose a compatible model.Choose a model that supports this input.
429client_error_cooldownThis request is temporarily limited after repeated processing errors. Please retry later.Wait, then check repeated request errors.
429concurrency_limitToo many requests are running. Wait for an active request to finish.Wait for an active request to finish.
429image_requests_temporarily_limitedImage requests are temporarily limited. Please retry later.Wait before sending more image requests.
429ip_rate_limitToo many requests from this network. Please retry later.Reduce requests from your network and retry later.
429model_rate_limitedToo many of your requests for this model are waiting. Please retry shortly.Wait before sending another request for this model.
429rate_limitYour request limit has been reached. Please wait before retrying.Wait before retrying; honor Retry-After when present.
500internal_errorAn 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.
500token_count_failedToken counting could not be completed. Please retry.Retry with backoff. Contact support with the request ID if it persists.
502empty_model_responseThe model returned no usable response. Please retry.Retry with backoff. Contact support with the request ID if it persists.
502invalid_model_responseThe model returned a response that could not be processed. Please retry.Retry with backoff. Contact support with the request ID if it persists.
502invalid_model_tool_argumentsThe model returned invalid or incomplete tool arguments.Do not execute incomplete arguments. Retry or contact support.
502invalid_model_tool_callThe model returned a tool call that was not defined in your request.Do not execute the invalid tool call. Retry or contact support.
502request_processing_failedThe 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.
502stream_interruptedThe response was interrupted before completion. Any partial output may be incomplete.Treat partial output as incomplete. Check tool actions before retrying.
502tool_generation_limit_exceededThe model did not complete a tool call within the generation limits.Retry with backoff. Contact support with the request ID if it persists.
503model_temporarily_unavailableThe selected model is temporarily unavailable. Please try again shortly.Retry with backoff. Contact support with the request ID if it persists.
503service_busyThe service is temporarily busy. Please retry shortly.Retry with backoff. Contact support with the request ID if it persists.
504generation_timeoutThe model did not produce a response in time. Please retry.Retry with backoff. Contact support with the request ID if it persists.
504stream_idle_timeoutThe response stopped making progress and could not be completed.Treat partial output as incomplete. Check tool actions before retrying.
504stream_time_limit_exceededThe response reached its maximum execution time before completion.Treat partial output as incomplete. Check tool actions before retrying.
504token_count_timeoutToken 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.