orq.aiAdvent of RoutingDocs

Door 13 · still sealed

Hands off the wax, elf. This door opens on Dec 13.

-days--hours--min--sec

Rudolph is still polishing this one. Back to the calendar

Door 13 · Dec 13 Smart Router

The right elf for each toy

Your code calls one model name. The Smart Router sends simple requests to an economical model and hard ones to a stronger one, from a pool you pick.

The letter desk. Eleven days to Christmas Eve, sacks of letters rising, and Ledger is buried in invoices that all bill the same master elf.

  1. Ledger

    I counted the tokens like candy canes. Every letter bills at master-elf rates, even the one asking what colour Rudolph's nose is.

  2. Rudolph

    Red. Short hop like that, you don't fuel the jumbo.

  3. Ledger

    So I write an if for every kind of letter? Noses here, train sets there, ponies... I'll need a bigger if.

  4. Tinsel

    No ifs. Put a small, a middle and a master elf in one Smart Router: your app calls one name, the router picks the elf.

clientYour appacme@orq/elf-routerorq.aiSmart Routercost mode · 3-model pooleasy bandopenai/gpt-6-lunamedium bandanthropic/claude-sonnet-5-5hard bandanthropic/claude-fable-5-2easymediumhard
  1. clientYour appacme@orq/elf-router
  2. orq.aiSmart Routercost mode · 3-model pool
  3. easy bandopenai/gpt-6-luna
    medium bandanthropic/claude-sonnet-5-5
    hard bandanthropic/claude-fable-5-2
Every letter goes to one model name. The Smart Router reads how hard each one is and walks it to the easy, medium or hard bench.

How it works

Tinsel’s fix is one router and one model name. You set it up once, then call it like any other model:

  1. Pool. You pick 2 to 50 models, from any mix of providers. Each one must be enabled in your workspace and carry an Intelligence Index from Artificial Analysis to be eligible.
  2. Bands. The router ranks the pool by that index and groups the models into Easy, Medium and Hard bands. Change the pool and the bands adapt.
  3. Routing. Each request is analysed for task complexity and sent to a model in the matching band. The mode (Cost, Balanced or Quality) sets how strongly the router prefers the economical models.
  4. Default model. If the routing decision times out, fails or is unavailable, the request goes to the default model, which must be in the pool.

Your app always sends the same reference, <workspace-key>@orq/<key>. The model field in the response names the model that actually answered.

Try it with curl

Create the router with the management API:

curl -X POST https://my.orq.ai/v2/smart-routers \
  -H "Authorization: Bearer $ORQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "elf-router",
    "profile": "SMART_ROUTER_PROFILE_COST",
    "models": [
      "openai/gpt-6-luna",
      "anthropic/claude-sonnet-5-5",
      "anthropic/claude-fable-5-2"
    ],
    "default_model": "anthropic/claude-fable-5-2"
  }'

The response carries smart_router.model_ref. Use that string as the model. Below, replace acme with your workspace key.

Or from the OpenAI SDK

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["ORQ_API_KEY"],
    base_url="https://my.orq.ai/v3/router",
)

letters = [
    "What colour is Rudolph's nose?",
    "Design a train set three siblings can share. "
    "Explain the trade-offs.",
]
for letter in letters:
    resp = client.chat.completions.create(
        model="acme@orq/elf-router",
        messages=[{"role": "user", "content": letter}],
    )
    print(resp.model, "->", resp.choices[0].message.content[:60])

The same reference works on /v3/router/responses, the Anthropic SDK at /v3/anthropic, deployments and Agents.

Which mode to pick

Mode API profile Behaviour
Cost SMART_ROUTER_PROFILE_COST Prefers the economical models more aggressively
Balanced SMART_ROUTER_PROFILE_BALANCED Balances cost and quality
Quality SMART_ROUTER_PROFILE_QUALITY Sends more requests to the stronger models

In AI Studio, new Smart Routers default to Cost. Through the API, profile is required. Changing the mode or the pool later needs no change in your app.

Multi-turn chats

By default the router picks a model per request, so turns of one conversation can land on different models and lose the provider prompt cache. Session affinity pins a thread to the model from its first turn. It is off by default: set session_affinity.enabled on the router and send a thread id with each request (on /responses, a conversation id also works). The pin lasts for an idle window, 10 minutes by default (session_affinity.ttl_seconds, 60 to 3600). A pin can move up to a stronger band later, but it never moves down.

Good to know

The key cannot change after creation. A Smart Router is workspace-wide: to limit which projects reach it, restrict model access per project and use project-scoped API keys.

Nice list

  • Keep the pool small. A pool holds 2 to 50 models, but the docs recommend fewer than 10.
  • Mix providers in one pool. Any enabled model with an Intelligence Index can join.
  • Set default_model on purpose. It serves requests when the routing decision times out, fails or is unavailable.
  • Turn on session affinity for chats and send a thread id, so each thread keeps its first-turn model and the provider prompt cache survives.

Naughty list

  • Guessing the small model by its price. Bands come from the Intelligence Index, so check the index before you build the pool.
  • Leaving out default_model on create and expecting the strongest model. The API then uses the first model in models.
  • Setting default_model to a model outside the pool. The API rejects the request with 400.
  • Writing an if for every kind of request (FAQs here, complaints there) to pick the model. The router decides per request, and a pool or mode change needs no code change.

Elf's challenge

Send your router What colour is Rudolph's nose?, then Design a train set three siblings can share. Explain the trade-offs. Does the nose question get a different elf? Check the response's model field each time.

Stuck? Ask Tinsel for a hint

The model field names the concrete pool model that answered. In Cost mode the simple question should stay low in the pool and the hard one should climb to a stronger band.

Christmas crackerWhy did the elf with the tallest hat stop getting the hard letters?Pull it for the punchline

The router reads the Intelligence Index, not the hat.