Skip to content
Orqen Docs

Code Examples

Provider migration

Switching to Orqen is a 2-line change. Your native SDK format — Anthropic Messages, Bedrock Converse, or OpenAI Chat Completions — works as-is. There is no need to adapt your tool shapes or message format.

Your provider credentials stay in the Orqen dashboard. For Bedrock, Orqen extracts your Orqen key from the standard SigV4 Credential header that boto3 sends automatically.

Anthropic SDK
import anthropic

# Before — direct to Anthropic
# client = anthropic.Anthropic(api_key="sk-ant-...")

# After — point the client at Orqen
client = anthropic.Anthropic(
    api_key="sk-orq-YOUR_KEY",           # Your Orqen key
    base_url="https://api.orqen.app",    # No /v1 suffix for Anthropic SDK
)

# Unchanged — your tools stay in Anthropic input_schema format
response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Weather in London?"}],
    tools=[
        {
            "name": "get_weather",
            "description": "Get current weather for a city.",
            "input_schema": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"],
            },
        }
    ],
)
# tool_use, tool_result, streaming — all unchanged

What Orqen does with your request

Regardless of which SDK you use, Orqen runs the same pipeline on every request:

StepWhat happensVisible to you
TranslateWire format → internalAnthropic, OpenAI, or Bedrock shape is normalised internally.
OptimizeRoute tools and clean contextOnly the relevant tool subset and cleaner agent context are forwarded to the LLM.
RoutePick provider + modelorqen/auto picks the best model; explicit models pass through.
ForwardCall your providerUses the credentials you stored in the dashboard.
Translate backInternal → wire formatResponse is returned in the same SDK format you sent.

Your tool format is preserved

Anthropic input_schema, Bedrock toolSpec, and OpenAI function.parameters all reach Orqen in their native shape. You never need to convert between formats. See the API reference for endpoint details.