Anvat

Anvat / API reference

API reference

Full Anvat gateway API. OpenAI and Anthropic compatible, one base URL, one key. Download the OpenAPI 3.1 spec or the Postman v2.1 collection below — every endpoint works againsthttps://api.anvat.appwith your Anvat key.

Download

OpenAPI 3.1 spec →

Import into Swagger UI, Redoc, Stoplight, Insomnia, or any code-generator that speaks OpenAPI.

Download

Postman collection →

v2.1 format. Set the {{api_key}} variable, hit Send.

Step 0

Get your API key →

Free, $2 signup credit, no card required.

Authentication

Both header styles are accepted on every endpoint — use whichever your SDK already sends.

OpenAI / Cursor / LangChain

Authorization: Bearer <ANVAT_API_KEY>

Anthropic SDK / Claude Code

x-api-key: <ANVAT_API_KEY>

Base URL

https://api.anvat.app

Set this as ANTHROPIC_BASE_URL for the Anthropic SDK or Claude Code, and OPENAI_BASE_URL=https://api.anvat.app/v1 for OpenAI-shaped clients.

Anthropic-compatible

POST/v1/messagesauth required

Create a Claude message (Anthropic-compatible)

Byte-compatible with api.anthropic.com/v1/messages. Streaming, tool use, prompt caching (cache_control), and extended thinking all work without modification. Use this with Claude Code, the Anthropic SDK, or anything that targets Anthropic's API.

Example request

curl https://api.anvat.app/v1/messages \
  -H 'content-type: application/json' \
  -H 'x-api-key: $ANVAT_API_KEY' \
  -H 'anthropic-version: 2023-06-01' \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 4096,
    "messages": [
      { "role": "user", "content": "Refactor my bubble-sort to merge-sort..." }
    ]
  }'

Example response

{
  "id": "msg_01...",
  "type": "message",
  "role": "assistant",
  "model": "claude-opus-4-8",
  "content": [{ "type": "text", "text": "..." }],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 84,
    "output_tokens": 412,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  }
}
POST/v1/messages/count_tokensauth required

Count tokens without dispatching the request

Returns the input_tokens count for the supplied message body. Useful for cost estimation, ratelimit budgeting, and validating prompt-cache hit rates before paying for inference.

Example request

curl https://api.anvat.app/v1/messages/count_tokens \
  -H 'x-api-key: $ANVAT_API_KEY' \
  -H 'anthropic-version: 2023-06-01' \
  -d '{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{ "role": "user", "content": "Hello" }] }'

Example response

{ "input_tokens": 8 }

OpenAI-compatible

POST/v1/chat/completionsauth required

Chat completion (OpenAI-compatible)

Drop-in replacement for api.openai.com/v1/chat/completions. Same request body, same SSE shape. Works with Cursor, the OpenAI SDK, LangChain, LiteLLM, and every framework that supports OpenAI-compatible endpoints.

Example request

curl https://api.anvat.app/v1/chat/completions \
  -H 'content-type: application/json' \
  -H 'authorization: Bearer $ANVAT_API_KEY' \
  -d '{
    "model": "gpt-5",
    "messages": [{ "role": "user", "content": "Hello" }]
  }'

Example response

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1717686123,
  "model": "gpt-5",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "..." },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 12, "completion_tokens": 84, "total_tokens": 96 }
}
POST/v1/responsesauth required

Responses API (OpenAI-compatible)

Mirror of OpenAI's /v1/responses surface for reasoning models and the tool-orchestration patterns the Responses API was designed for. Pass through whatever request body OpenAI accepts.

Discovery

GET/v1/modelsauth required

List available models

Returns the catalog of models reachable through Anvat. Response shape auto-adapts: OpenAI-style by default ({ object: 'list', data: [...] }); Anthropic-style when the caller sends anthropic-version, x-api-key, or a Claude Code user agent ({ data: [{ type: 'model', id, display_name }], has_more }).

Example request

curl https://api.anvat.app/v1/models -H 'authorization: Bearer $ANVAT_API_KEY'

Billing

GET/v1/balanceauth optional

Caller credit balance (USD)

Used by Claude Code statusLine and balance widgets. Returns { balance_usd, currency, updated_at }. Unauthenticated callers get balance_usd: null instead of an error so widgets render neutrally.

Example response

{ "balance_usd": 124.83, "currency": "USD", "updated_at": "2026-06-06T13:21:09.481Z" }

Ops

GET/healthzpublic

Liveness probe

Returns { status: 'ok', uptimeSeconds }. Used by Kubernetes, Railway, and uptime monitors.

GET/readyzpublic

Readiness probe

Returns { status: 'ready' } when the gateway is accepting traffic.

Response headers we add

Every successful response carries metering + rate-limit telemetry so you can budget without polling extra endpoints.

HeaderMeaning
x-anvat-cost-usdMetered cost of this request in USD, post-discount. Failed requests are not charged.
x-anvat-rpm-remainingRequests left in the rolling 60-second window.
x-anvat-concurrent-remainingConcurrent in-flight requests left for your key.
x-anvat-window-spend-remaining-usdRolling-spend cap remaining (USD) in the current window.

Error codes

StatusMeaningWhat to do
401Missing or invalid API keyRegenerate at /app/keys.
402Insufficient creditTop up at /app/billing — prepaid packs double your spend.
429Rate limit exhausted (RPM / concurrent / rolling spend)Honor retry-after. Upgrade your plan for higher caps.
5xxUpstream model provider outageRetry with exponential backoff. We do not bill failed requests.

Open the spec in your tool of choice

The OpenAPI 3.1 file works with every modern API tool — Postman, Insomnia, Bruno, Hoppscotch, Stoplight, Redoc, Swagger UI, openapi-generator, oapi-codegen, prism mock server, you name it.