Skip to main content
Set model to auto on /v1/chat/completions, /v1/messages, or /v1/responses. Electron Hub reads the request, picks a model and a reasoning effort, and forwards the request to it. Everything else in the body works as with a fixed model.
The response model field and the X-EH-Routed-Model header name the model that answered.

How it works

  1. Narrow the pool. Models are removed when they cannot take the request: wrong endpoint, not on your plan or key, no provider allowed by your provider settings, no image support when you send images, no tool support when you send tools, no json_schema support, a context window too small for the input plus max_tokens, or a parameter the model recently rejected. Your allowed and excluded model lists apply last.
  2. Read the request. A routing model rates the task type, difficulty (trivial to extreme), the professional domain when there is one, and signals such as “speed matters”, “a larger model would help”, and “the agent is failing”. If the routing model is unavailable, built-in rules classify the request instead.
  3. Rank and pick. Models are ranked on benchmark quality for the task category and domain, combining Artificial Analysis, ZeroEval, Epoch AI, and EQ-Bench results. Auto picks the cheapest model within a quality band of the best one, then sets the reasoning effort from the difficulty.
  4. Keep the conversation steady. On later turns Auto keeps the same model unless the task changes, a model is failing, or the current model falls out of the quality band. See Sessions.
  5. Apply your guardrails. Privacy, per-request cost cap, and budget rules from your policy run on the pick.
  6. Send it. The request goes through normal provider routing. Auto also sets up to two fallback models; if the first one cannot be served, the next one runs.

Cost tiers

The cost tier sets how far below the best-ranked model a cheaper pick may be. Harder requests narrow the band; trivial ones widen it. Set the tier per request with router.cost_tier, or in a policy.

The router object

Optional. Overrides your default policy for one request. Unknown fields return 400. If your settings lock overrides, every field except metadata is ignored and listed in router_metadata.overrides_ignored; model: "auto/<policy-id>" still applies.
string
Policy id to use instead of your default. Same effect as model: "auto/<policy-id>".
string
low, medium, high, xhigh, or max.
string[]
Model patterns Auto may pick from, for example ["claude-*", "anthropic/*", "gpt-5.1"]. A pattern matches the model id or <owner>/<model id>. Up to 256 patterns. When nothing matches, Auto ignores the list and adds the note allowed_models_fallback, unless strict_allowed is true.
string[]
Model patterns Auto never picks.
boolean
With true, a request whose allowed_models match nothing fails with 404 instead of falling back. Defaults to the policy’s setting.
string
auto (routing model, default) or rules (built-in rules only, no routing fee).
boolean
Return router_metadata in the response. Same as the header X-EH-Router-Metadata: enabled.

Sessions

Auto treats requests from one conversation as a session, so a conversation does not jump between models on every turn. It identifies the conversation from the first of these that is present: Send session_id when you can. Two conversations that open with the same system prompt and first message share a fingerprint. Session behaviour:
  • Tool results go back to the model that called the tool.
  • After repeated failures (failing tool calls, repeated errors), Auto raises the reasoning effort or switches to a stronger model. The new model is kept for the next 8 turns unless the task changes, and the replaced one is not picked again during that time.
  • Sending the identical conversation again (an SDK retry or a regenerate) reuses the same model and effort and does not count as a new turn.
  • A session expires after 1 hour without requests.
When Auto switches models mid-conversation, it adapts the history for the new model (tool call ids, thinking blocks, effort fields) so the request stays valid.

Response metadata

Send X-EH-Router-Metadata: enabled (or router.metadata: true) to get a router_metadata object:
notes is added only when something unusual happened, for example allowed_models_fallback or unsupported_param_retry (the first model rejected a parameter and the next fallback answered). Every routed response also has the headers X-EH-Routed-Model and X-EH-Router-Decision-Id.

Pricing

You pay the price of the model that answered, plus a routing fee of $0.00005 to $0.001 per request. The fee appears as usage.router_fee, in USD. In streams it is on the final usage chunk (Chat needs stream_options.include_usage: true). No fee is charged when:
  • router.classifier is rules, or the routing model was unavailable.
  • The classification was reused from an identical earlier request, such as a retry.
  • The answer came from the response cache.
  • A guardrail blocked the request.

Policies

A policy stores your routing defaults: cost tier, allowed and excluded models, custom rules, privacy and budget guardrails, and the response cache. Every account has a default policy. Create more and select one per request with model: "auto/<policy-id>". Manage policies in the Electron Hub app, or with the /v1/router/* API using a master API key: Every endpoint, with a playground, is in the API Reference under Router. Writes accept an optional expected_version and return 409 when the stored version has changed since. Writes are limited to 60 per minute. Proxy keys cannot manage routing (403).

Limits

  • auto works on Chat Completions, Messages, and Responses only. Other endpoints return 400 with code model_not_supported_for_endpoint.
  • auto is not available on Coding Plan (DevPass) keys.
  • Free (:free) and Coding Plan models are never picked.
  • Auto sets the fallback list itself; a models array you send with auto is replaced.
  • Empty messages (or blank Responses input) returns 400.

Errors

Errors from the model after routing are returned unchanged.