> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Agent SDK | AI Gateway

> Route Claude Agent SDK model calls through the orq.ai AI Gateway with environment variables. Access fallbacks, caching, load balancing, and cost tracking for Claude models.

## AI Gateway

<Badge>Beta</Badge>

### Overview

Route the Claude Agent SDK's model calls through Orq.ai's **AI Gateway** without changing any agent logic. The SDK drives the Claude CLI, which reads `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` from the environment, so pointing those variables at the gateway routes every turn through **Orq.ai**.

<Info>
  For the raw Claude Messages API without the agent runtime, see the [Anthropic SDK](/docs/ai-gateway/integrations/frameworks/anthropic) integration.
</Info>

### Configuration

Set the following environment variables before running the agent:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ANTHROPIC_BASE_URL="https://api.orq.ai/v3/anthropic"
export ANTHROPIC_AUTH_TOKEN="$ORQ_API_KEY"
export ANTHROPIC_API_KEY=""  # set empty so the SDK does not call the Anthropic API directly
export ANTHROPIC_MODEL="anthropic/claude-sonnet-4-6"  # the anthropic/ prefix is required
```

### Basic Example

With the environment variables set, every agent run routes through the **AI Gateway** with no change to the calling code:

<Tabs>
  <Tab title="TypeScript">
    ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
    import { query } from '@anthropic-ai/claude-agent-sdk';

    const prompt = 'What is the capital of France?';

    for await (const message of query({ prompt })) {
      if ('result' in message && typeof message.result === 'string') {
        console.log(message.result);
      }
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    import asyncio
    from claude_agent_sdk import (
        ClaudeSDKClient,
        AssistantMessage,
        TextBlock,
    )


    async def main():
        async with ClaudeSDKClient() as client:
            await client.query("What is the capital of France?")
            async for message in client.receive_response():
                if isinstance(message, AssistantMessage):
                    for block in message.content:
                        if isinstance(block, TextBlock):
                            print(block.text)


    asyncio.run(main())
    ```
  </Tab>
</Tabs>

### Model Selection

Change `ANTHROPIC_MODEL` to route the agent to any supported model. The `anthropic/` prefix is required for Claude models. Browse every available model in [Supported Models](/docs/ai-gateway/supported-models).
