Code Examples
Multi-provider routing
Connect OpenAI, Anthropic, Bedrock, and other providers in the dashboard, then use orqen/auto, orqen/cheap, or orqen/fast from whichever SDK you already use. Orqen picks the upstream model — your request stays in native Anthropic, OpenAI, or Bedrock shape.
See Model routing for how routing works, and Provider migration for minimal SDK setup.
1. Connect providers
Save each provider key once via the dashboard or the management API. Repeat for every provider you want in the routing pool.
curl https://api.orqen.app/v1/account/providers \
-X PUT \
-H "Authorization: Bearer sk-orq-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"api_key": "sk-proj-..."
}'Bedrock also supports bearer-token setup — see Providers API.
2. Use routing model strings
Pass orqen/auto (or orqen/cheap, orqen/fast) as the model name in your usual SDK call:
import anthropic
client = anthropic.Anthropic(
api_key="sk-orq-YOUR_KEY",
base_url="https://api.orqen.app",
)
# Orqen picks from enabled providers (OpenAI, Anthropic, Bedrock, …)
response = client.messages.create(
model="orqen/auto",
max_tokens=4096,
messages=[{"role": "user", "content": "Analyse this error log and suggest a fix"}],
tools=[...],
)
response = client.messages.create(
model="orqen/cheap",
max_tokens=1024,
messages=[{"role": "user", "content": "Classify this ticket"}],
)
response = client.messages.create(
model="orqen/fast",
max_tokens=1024,
messages=[{"role": "user", "content": "Rewrite this sentence"}],
)3. Enable or disable models
The dashboard Routing page lets you toggle models per provider. Disabled models are excluded fromorqen/* routing but remain available if your agent names them directly.
curl https://api.orqen.app/v1/account/routing/models/toggle \
-X POST \
-H "Authorization: Bearer sk-orq-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"model_id": "gpt-4o",
"is_enabled": true
}'4. Read performance data
curl https://api.orqen.app/v1/account/routing/insights \
-H "Authorization: Bearer sk-orq-YOUR_KEY"Recommended rollout
Start with orqen/auto on non-critical traffic, inspect model recall and latency, then disable models that are too slow or too inaccurate for your workload.