orq.aiAdvent of RoutingDocs

Door 3 · still sealed

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

-days--hours--min--sec

Rudolph is still polishing this one. Back to the calendar

Door 3 · Dec 3 OpenAI, Anthropic & Responses APIs

Santa speaks every dialect

Keep the OpenAI or Anthropic SDK you already use, change the base URL and key, and call any model in the catalog from either one.

The letter reader speaks OpenAI, the toy sorter speaks Anthropic, and each has its own key, its own bill and its own provider. Santa wants one front door before the evening post.

  1. Santa

    One front door for the whole workshop, by the evening post! And nobody learns a new language.

  2. Sprocket

    Two apps, two SDKs! I'll rewrite the toy sorter in OpenAI by morning. And the letter reader in Anthropic, to be fair!

  3. Tinsel

    Rewrite nothing. Give each SDK a new base URL and an Orq key.

  4. Santa

    So the toy sorter can ask a GPT model? Splendid. I always want a second opinion on the naughty list.

  5. Tinsel

    Fluently. Write the model as provider/model_id and either SDK can ask anyone in the catalog.

openai sdkLetter reader/v3/routeranthropic sdkToy sorter/v3/anthropicorq.aiAI Routerone key · one catalogprovideropenai/gpt-6.2-solprovideranthropic/claude-sonnet-5-5
  1. openai sdkLetter reader/v3/router
    anthropic sdkToy sorter/v3/anthropic
  2. orq.aiAI Routerone key · one catalog
  3. provideropenai/gpt-6.2-sol
    provideranthropic/claude-sonnet-5-5
Two SDKs, one new address each: the router reaches any model and replies in the language it was asked in.

How it works

Tinsel’s migration changes three values per SDK: the base URL, the key and the model name. The AI Router accepts three wire formats: OpenAI Chat Completions, OpenAI Responses and Anthropic Messages.

  1. Base URL. The OpenAI SDK points at https://my.orq.ai/v3/router. That one base URL serves both /chat/completions and /responses. The Anthropic SDK points at https://my.orq.ai/v3/anthropic and appends /v1/messages on its own.
  2. Key. Use your Orq API key as the SDK key. The Anthropic endpoint accepts it as Authorization: Bearer or as x-api-key, the header the Anthropic SDK sends by default.
  3. Model. Set model to a catalog id like anthropic/claude-haiku-5-5. The same catalog applies to every endpoint, so any dialect can reach any provider. The model must be enabled on the Models page; otherwise the call returns 403 permission_error.
  4. Same pipeline. All three run through one pipeline, so fallbacks, budgets, guardrails and traces apply to each. On /v3/anthropic, fallbacks come from Routing Rules, not the request body. Your SDK gets back the response shape it expects.

Try it with curl

The Anthropic endpoint, calling an OpenAI model:

curl -X POST https://my.orq.ai/v3/anthropic/v1/messages \
  -H "Authorization: Bearer $ORQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-6.2-sol",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Say hello in three languages."}
    ]
  }'

Or from the OpenAI SDK

One client speaks both OpenAI dialects. The Responses API can also keep state on the server:

from openai import OpenAI
import os

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

# Chat Completions, with a Claude model
chat = client.chat.completions.create(
    model="anthropic/claude-haiku-5-5",
    messages=[{"role": "user", "content": "Name three reindeer."}],
)
print(chat.choices[0].message.content)

# Responses, continued on the server
first = client.responses.create(
    model="openai/gpt-6-luna",
    input="My wish is a red sled.",
)
follow_up = client.responses.create(
    model="openai/gpt-6-luna",
    previous_response_id=first.id,
    input="What was my wish?",
)
print(follow_up.output_text)

Which API to use

You want Use
Existing OpenAI code, a classic messages flow Chat Completions
Server-side state, built-in web search, reasoning with tools Responses
Existing Anthropic code, Claude cache_control breakpoints passed through unchanged Anthropic Messages

Chat Completions sends the full history on every call. Responses can chain turns with previous_response_id. store defaults to true; with store: false there is nothing to continue from.

Gotchas

Fallbacks on the Anthropic endpoint. The request body’s fallbacks field is ignored there. Configure fallbacks for /v3/anthropic through Routing Rules.

Reasoning with tools. Sending tools to /chat/completions with an OpenAI reasoning model and a reasoning_effort other than none returns 400. Use /responses for that.

Not carried over. The Assistants API and fine-tuning are not part of the router: /assistants and /fine_tuning/jobs return 404.

Nice list

  • Call any catalog model from either SDK, not only its own provider's. Set model to a provider/model_id such as openai/gpt-6.2-sol.
  • Mark long, stable prompts with Claude cache_control breakpoints on /v3/anthropic. They pass through unchanged.
  • Pass previous_response_id on the Responses API instead of resending the whole history. The earlier response must have been stored.

Naughty list

  • Rewriting a working app in the other SDK just to reach a new provider. Change the base URL, the key and model instead: three lines, not a rewrite.
  • Sending fallbacks in the body to /v3/anthropic. That endpoint ignores the field: configure its fallbacks through Routing Rules.
  • Leaving out model on a Responses continuation. The model from the earlier turn is not reused, so set it every time.
  • Adding Claude cache_control breakpoints and then calling a GPT model. On a non-Anthropic model they are ignored, not rejected: no error, and no cache.

Elf's challenge

Swap dialects: ask anthropic/claude-haiku-5-5 through the OpenAI SDK, then openai/gpt-6.2-sol through the Anthropic SDK. Where does the answer text live in each response?

Stuck? Ask Tinsel for a hint

chat.choices[0].message.content from Chat Completions, msg.content[0].text from Messages. The endpoint you call sets the response shape, not the model's provider.

Christmas crackerWhy did the Anthropic SDK start getting answers from GPT?Pull it for the punchline

New address, same accent.