orq.aiAdvent of Routing

Door 20 · still sealed

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

-days--hours--min--sec

Rudolph is still polishing this one. Back to the calendar

Door 20 · Dec 20 Routing rules & EU residency

Workshop rules

Tag a request for the EU, and one routing rule sends it to EU-hosted models. No app changes a single model name.

Four days to go, and a sack of European letters thumps onto Santa's desk with a note pinned on top: read in Europe, please.

  1. Santa

    The European parents have a new rule: every letter read in Europe, starting tonight!

  2. Mrs. Claus

    Our archive already lives in the EU. But who reads each letter, and where does that model run?

  3. Tinsel

    Right now? Whatever model the app asked for, wherever that model runs.

  4. Santa

    Then every app elf rewrites every model name by midnight. Chop chop!

  5. Tinsel

    No rewrites. Stamp each letter region: eu, and one rule on the workshop wall swaps in EU-hosted models.

clientYour appmetadata.regionorq.aiRouting rulemetadata.region == "eu"eu-hostedEU GPT-6.2 Solopenai/eu.gpt-6.2-soleu fallbackEU Gemini 4 Neongoogle/eu.gemini-4-neonpayload modelPayload modelclaude-sonnet-5-512matchfallbackno match
  1. clientYour appmetadata.region
  2. orq.aiRouting rulemetadata.region == "eu"
  3. eu-hostedEU GPT-6.2 Solopenai/eu.gpt-6.2-sol
    eu fallbackEU Gemini 4 Neongoogle/eu.gemini-4-neon
    payload modelPayload modelclaude-sonnet-5-5
Letters stamped `eu` match the rule and stay on EU-hosted models, fallback included; unstamped letters go to the model they asked for.

How it works

Tinsel’s fix is one rule on the workshop wall. A routing rule is a CEL condition that the AI Router checks on every request. When it matches, the router sends the request to the rule’s models instead of the one in the payload. No model name changes in your apps.

  1. Match. Every enabled rule whose expression.cel matches the request is a candidate. The condition can read model, model_id, provider, headers, metadata, identity, project and api_key.
  2. Pick a winner. Workspace-wide rules outrank project-scoped ones. Within the winning scope, the lowest priority wins, and the oldest rule breaks a tie.
  3. Replace. The winning rule’s models_config replaces the request’s own model, load_balancer, fallbacks and fallback_on_codes. They are never merged. A request that matches no rule keeps its own model.

Try it with curl

You need a Management Key with Write access to the Routing rules capability. Rules are visible to workspace administrators only.

curl -X POST https://my.orq.ai/v2/routing-rules \
  -H "Authorization: Bearer $ORQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "eu-letters",
    "priority": 0,
    "expression": { "cel": "metadata.region == \"eu\"" },
    "models_config": {
      "mode": "fallback",
      "models": [
        { "model": "openai/eu.gpt-6.2-sol" },
        { "model": "google/eu.gemini-4-neon" }
      ]
    }
  }'

From the terminal, orq routing-rules create takes the same fields as flags: --display-name, --enabled, --priority, --expression and --models-config.

display_name is the only required field. enabled defaults to false, so the rule above is saved disabled and matches nothing yet. Check it with orq routing-rules list, then switch it on with orq routing-rules update <rule-id> --enabled.

Or from the OpenAI SDK

Your app keeps its usual model and adds one tag. With the OpenAI SDK, pass metadata in extra_body:

from openai import OpenAI
import os

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

# The rule replaces this model when the tag matches.
response = client.responses.create(
    model="anthropic/claude-sonnet-5-5",
    input="Dear Santa, I would like a sledge.",
    extra_body={"metadata": {"region": "eu"}},
)
print(response.output_text)

metadata values must be strings. On the Responses API, other types get a 400.

What stays in the EU

On the orq.ai-hosted platform, your platform data stays in the EU by default, with no setup: traces, logs, datasets, prompts, evaluations and workspace configuration. There is no US region.

Model calls are different. They go to the provider of the model you choose. To keep inference in the EU, pick models that run there. The model catalog lists each model’s location, for example:

Model Location
openai/eu.gpt-6.2-sol EU
google/eu.gemini-4-neon EU
aws/eu.anthropic.claude-sonnet-5-5 EU
anthropic/claude-sonnet-5-5 global

Gotchas

Fallbacks count too. In fallback mode the router moves down the rule’s models list. Keep every entry EU-located, or a fallback sends the request out of the EU.

A tag is opt-in. The caller sets metadata, so a caller can leave it out. When every request in a project must stay in the EU, put a project condition in a workspace-wide rule instead.

Scope is fixed. Omit project_id for a workspace-wide rule. A rule keeps the scope it was created in.

Nice list

  • Pick models the catalog marks as EU, such as openai/eu.gpt-6.2-sol or aws/eu.anthropic.claude-sonnet-5-5.
  • Create the rule without enabled, check it with orq routing-rules list, then switch it on.
  • Send metadata values as strings. The Responses API rejects non-string values with a 400.
  • When every request in a project must stay in the EU, put a project condition in a workspace-wide rule. A project-scoped rule loses to any matching workspace-wide rule.

Naughty list

  • Trusting a metadata tag to enforce residency. The caller sets it, so a letter sent without the tag matches no rule and keeps the model in its payload, which may be global.
  • Sending your own fallbacks and expecting them to survive. A matching rule's models replace the request's model, load_balancer, fallbacks and fallback_on_codes.
  • Writing a rule to keep traces and logs in the EU. On the orq.ai-hosted platform they already stay there; rules only move model calls.

Elf's challenge

Two rules both match the same EU-tagged letter: a project-scoped one with priority 0 and a workspace-wide one with priority 10. Which rule picks the model?

Stuck? Ask Tinsel for a hint

The workspace-wide one: scope is checked before priority. Priority only settles ties inside the winning scope, and the oldest rule breaks a tie there.

Christmas crackerWhat do you call a routing rule nobody switched on?Pull it for the punchline

A silent night. A rule created without enabled starts switched off.