Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.anyapi.ai/llms.txt

Use this file to discover all available pages before exploring further.

Tag Routing

Guarantee the capabilities your request needs Not every backend supports every feature for a given model. Tag routing lets you declare exactly which capabilities your request requires — and AnyAPI guarantees it lands on a backend that supports them all. No more random failures because a backend can’t handle your PDFs, audio, or tool calls.
{
  "model": "anthropic/claude-sonnet-4",
  "messages": [{"role": "user", "content": "Summarize this document"}],
  "tags": ["messages:pdf_input"]
}

How It Works

Add the tags parameter to your request with the capabilities you need. AnyAPI filters available backends to only those that match all your requested tags, then routes to the best one.
  • All tags must match — if you send ["vision", "streaming"], the backend must support both
  • No match = 503 — if no backend supports all your tags, you’ll get a clear error instead of a cryptic failure
  • Fully optional — skip tags entirely and AnyAPI routes as usual

🏷️ Tag Format

Tags use a simple two-level naming scheme:
endpoint:capability    → scoped to a specific API endpoint
capability             → matches any endpoint
Use endpoint-scoped tags when possible. A capability might be available on one endpoint but not another — scoped tags give you precision.

Endpoint Prefixes

PrefixAPI Endpoint
chat_completions/v1/chat/completions
messages/v1/messages
responses/v1/responses

Available Capabilities

TagWhat it guarantees
visionImage input support
pdf_inputPDF file input support
audio_inputAudio file input support
reasoningExtended thinking / chain-of-thought
streamingStreaming response support
function_callingFunction / tool calling
parallel_function_callingMultiple tool calls in one turn
tool_choiceExplicit tool selection (auto, required, none, named)
computer_useComputer use tool support
assistant_prefillPre-fill assistant response
prompt_cachingPrompt caching support
web_searchBuilt-in web search
url_contextURL context fetching
Every capability works as a generic tag (vision) and as an endpoint-scoped tag (chat_completions:vision, messages:vision, responses:vision).

📨 Sending Tags

Pass a tags array alongside your usual parameters:
{
  "model": "anthropic/claude-sonnet-4",
  "messages": [{"role": "user", "content": "Describe this image"}],
  "tags": ["chat_completions:vision"]
}

HTTP Header

Use the x-router-tags header with comma-separated values:
curl https://api.anyapi.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-router-tags: chat_completions:vision,streaming" \
  -H "Content-Type: application/json" \
  -d '{"model": "anthropic/claude-sonnet-4", "messages": [...]}'
If both tags in the body and x-router-tags header are present, the body takes precedence.

🧪 Examples

Vision — analyze an image

curl https://api.anyapi.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4",
    "messages": [
      {"role": "user", "content": [
        {"type": "text", "text": "What is in this image?"},
        {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
      ]}
    ],
    "tags": ["chat_completions:vision"]
  }'

PDF — summarize a document

curl https://api.anyapi.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": [
        {"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "..."}},
        {"type": "text", "text": "Summarize this document"}
      ]}
    ],
    "tags": ["messages:pdf_input"]
  }'

Streaming + Tool Calling

curl https://api.anyapi.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1",
    "messages": [{"role": "user", "content": "What is the weather in Berlin?"}],
    "tools": [{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}}}}],
    "stream": true,
    "tags": ["chat_completions:function_calling", "chat_completions:streaming"]
  }'

Reasoning via header

curl https://api.anyapi.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-router-tags: chat_completions:reasoning" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4",
    "messages": [{"role": "user", "content": "Solve step by step: what is 7! + 3!?"}]
  }'

⚠️ Error Handling

When no backend matches your tags, AnyAPI returns a 503 with a clear message:
{
  "error": {
    "message": "There is no available model deployment that meets your routing requirements",
    "type": "None",
    "code": "503"
  }
}
Common causes:
  • The model doesn’t support this capability on any backend
  • Typo in a tag name — check the tag list above
  • You’re using a generic tag but the capability is only available on specific endpoints

🔍 Discovering Tags for a Model

Query which tags any model supports:
curl https://api.anyapi.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY" | \
  jq '.data[] | select(.id == "anthropic/claude-sonnet-4") | .tags'
This returns every tag available across all backends for the model. If a tag appears in the list, at least one backend supports it. Models with no capability tags omit the tags field.

Tips

  • Start without tags — only add them when you need a specific capability that isn’t available everywhere
  • Use endpoint-scoped tagschat_completions:vision is safer than just vision because it guarantees the capability on the exact endpoint you’re calling
  • Combine with fallback chains — use the models parameter alongside tags for maximum reliability
  • Check before you build — query /v1/models to see which tags your target model supports before hardcoding them