For the complete documentation index, see llms.txt. This page is also available as Markdown.

Messages

Create Message

post

Anthropic Messages API-compatible endpoint.

Supports MCP tool-use loops, sandboxed code execution, and SearXNG web_search.

Authorizations
Otari-KeystringRequired

Enter your API key here (sent as Otari-Key header).

Header parameters
Idempotency-Keystring · nullableOptional

A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.

Otari-Tagsstring · nullableOptional

Tags for cost attribution, as comma-separated key=value pairs (agent=bug-fix,run=1234), for a client that cannot set the body's metadata. Keys and values are percent-decoded, so either may carry an encoded , or =, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.

Body

Anthropic Messages API-compatible request.

The wire fields are derived from any-llm's MessagesParams (see _schema_derive) so the schema cannot silently drop a param any-llm forwards. Gateway-internal fields (mcp_servers, mcp_server_ids, guardrails, tools_header, max_tool_iterations) opt the request into gateway-managed MCP / sandbox / web_search / guardrails without changing the upstream wire shape. They're stripped before the request is forwarded.

betasstring[] · nullableOptional
containerany of · nullableOptional
stringOptional
or
inference_geostring · nullableOptional
max_tokensintegerRequired
max_tool_iterationsinteger · min: 1 · max: 25 · nullableOptional
mcp_server_idsstring · uuid[] · max: 50 · nullableOptional
modelstringRequired
prompt_cache_keystring · nullableOptional
service_tierstring · nullableOptional
session_labelstring · max: 255 · nullableOptional

Optional caller-supplied label for a run, experiment or conversation, which names the session the request's trace is grouped under. Stripped before the request is forwarded upstream to the provider.

stop_sequencesstring[] · nullableOptional
streambooleanOptionalDefault: false
systemany of · nullableOptional
stringOptional
or
temperaturenumber · nullableOptional
tools_headerstring · nullableOptional
top_kinteger · nullableOptional
top_pnumber · nullableOptional
Responses
200

Successful Response

application/json
anyOptional
post/api/v1/messages
POST /api/v1/messages HTTP/1.1
Otari-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 1119

{
  "betas": [
    "text"
  ],
  "cache_control": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "container": "text",
  "context_management": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "guardrails": [
    {
      "mode": "monitor",
      "on": [
        "input"
      ],
      "on_unavailable": "block",
      "profile": "text",
      "url": "text",
      "validate_kwargs": {
        "ANY_ADDITIONAL_PROPERTY": "anything"
      }
    }
  ],
  "inference_geo": "text",
  "max_tokens": 1,
  "max_tool_iterations": 1,
  "mcp_server_ids": [
    "123e4567-e89b-12d3-a456-426614174000"
  ],
  "mcp_servers": [
    {
      "allowed_tools": [
        "text"
      ],
      "authorization_token": "text",
      "name": "text",
      "purpose_hint": "text",
      "url": "text"
    }
  ],
  "messages": [
    {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ],
  "metadata": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "model": "text",
  "output_config": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "output_format": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "prompt_cache_key": "text",
  "service_tier": "text",
  "session_label": "text",
  "stop_sequences": [
    "text"
  ],
  "stream": false,
  "system": "text",
  "temperature": 1,
  "thinking": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "tool_choice": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "tools": [
    {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ],
  "tools_header": "text",
  "top_k": 1,
  "top_p": 1
}

No content

Count Message Tokens

post

Anthropic /v1/messages/count_tokens-compatible endpoint.

Returns {"input_tokens": N} without contacting an upstream provider: counting is local, so there is no budget reservation, pricing, or usage logging. Authentication mirrors :func:create_message, validating the API key, so the endpoint is not an open token-counting oracle.

Authorizations
Otari-KeystringRequired

Enter your API key here (sent as Otari-Key header).

Body

Anthropic /v1/messages/count_tokens request.

A subset of :class:MessagesRequest: the input fields that affect the token count, minus max_tokens and the streaming/sampling controls, since the endpoint only counts input tokens. context_management and betas are accepted for wire compatibility, but the local estimate does not apply provider-side context edits. Clients such as Claude Code call this on every turn to keep their prompt within the model's context window.

betasstring[] · nullableOptional
modelstringRequired
systemany of · nullableOptional
stringOptional
or
Responses
200

Successful Response

application/json

Anthropic /v1/messages/count_tokens response.

input_tokensintegerRequired
post/api/v1/messages/count_tokens
POST /api/v1/messages/count_tokens HTTP/1.1
Otari-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 418

{
  "betas": [
    "text"
  ],
  "cache_control": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "context_management": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "messages": [
    {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ],
  "metadata": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "model": "text",
  "system": "text",
  "thinking": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "tool_choice": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "tools": [
    {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ]
}
{
  "input_tokens": 1
}

Last updated

Was this helpful?