anonrouterdocs

Intelligent routing

Select models automatically without silently widening privacy constraints.

Use model: "/auto" when AnonRouter should choose an eligible model for the request. The values auto and anonrouter/auto are accepted aliases, and any model string containing a * glob (for example meta-llama/*) also triggers automatic selection over the matching routes.

{
  "model": "/auto",
  "messages": [
    {
      "role": "user",
      "content": "Review this distributed system design."
    }
  ],
  "routing": {
    "strategy": "balanced",
    "max_cost_usd": 0.02
  }
}

The ticket you issue must also be automatic. Request a ticket with the same /auto or glob model, then send the completion with the matching value.

The routing object

The optional routing object shapes the candidate set and the choice:

FieldValuesPurpose
strategycost, balanced, qualityTrade off model quality against price. Defaults to balanced.
privacy_classesarray of anonymous, private, tee, e2eeRestrict eligible privacy tiers.
max_cost_usdnumberDrop candidates whose worst-case cost exceeds this.
allowarray of glob patternsRestrict candidates to matching models or providers.
excludearray of glob patternsRemove matching models or providers.

strategy controls quality and price, not privacy. cost prefers cheaper, lower-tier models, quality prefers the highest quality tier, and balanced sits between them and can step up for complex prompts.

{
  "model": "meta-llama/*",
  "messages": [
    {
      "role": "user",
      "content": "Analyze this TypeScript API."
    }
  ],
  "routing": {
    "exclude": ["*/*-guard"],
    "strategy": "cost"
  }
}

Exclusions always win, and allow/exclude patterns match against both the provider/model form and the bare model id.

Privacy is never widened

When privacy_classes is omitted, the eligible set defaults to the privacy-preserving tiers (private, tee, e2ee). Automatic routing never silently adds a weaker tier. To let /auto also consider Anonymous routes, you must ask for it explicitly:

{
  "model": "/auto",
  "messages": [{ "role": "user", "content": "Summarize this text." }],
  "routing": {
    "privacy_classes": ["anonymous", "private"]
  }
}

If no model satisfies the constraints, the request fails closed rather than downgrading to a route you did not allow.

TEE and E2EE are not auto-selected

Confidential (TEE) and end-to-end encrypted (E2EE) routes require a client attestation handshake, so /auto never selects them. Address a TEE or E2EE model by its explicit id. In practice /auto chooses a Private route by default, or an Anonymous route if you opt in.

Response headers

Successful requests report the actual selection:

  • x-anonrouter-selected-model is the chosen provider/model.
  • x-anonrouter-routing is auto when a model was selected automatically, or exact when you named a single model.

The response body's model field is also rewritten to the selected model. Any classification the router computes to make the choice is used in memory and is not stored as durable usage metadata.

Saved routing preferences

An account can save default routing behavior that applies when a request does not override it. Preferences are managed with a session.

MethodEndpointDescription
GET/v1/routing/effectiveList models the caller's saved preferences allow.
GET/v1/routing/preferencesRead saved routing preferences.
PUT/v1/routing/preferencesReplace saved routing preferences.
POST/v1/routing/previewPreview a routing decision for a sample prompt.
POST/v1/routing/eligible-modelsList models eligible for draft preferences.

Preferences carry a privacy_level that maps to a default privacy set:

  • open allows anonymous, private, tee, and e2ee.
  • balanced allows private, tee, and e2ee.
  • maximum allows only tee and e2ee.

A pool_mode of all, include, or exclude with model_patterns narrows the default candidate pool, and strategy sets the default quality tradeoff.

On this page