Skip to main content

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.

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:
Use endpoint-scoped tags when possible. A capability might be available on one endpoint but not another — scoped tags give you precision.

Endpoint Prefixes

Available Capabilities

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:

HTTP Header

Use the x-router-tags header with comma-separated values:
If both tags in the body and x-router-tags header are present, the body takes precedence.

🧪 Examples

Vision — analyze an image

PDF — summarize a document

Streaming + Tool Calling

Reasoning via header

⚠️ Error Handling

When no backend matches your tags, AnyAPI returns a 503 with a clear message:
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:
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