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

# Claude Agent SDK (Anthropic)

> Use the Claude Agent SDK (TypeScript and Python) with 300+ models by setting ANTHROPIC_BASE_URL to the Requesty gateway

The [Claude Agent SDK](https://docs.anthropic.com/en/api/agent-sdk/overview) from Anthropic (available for TypeScript as `@anthropic-ai/claude-agent-sdk` and for Python as `claude-agent-sdk`) lets you build AI agents with tool calling, hooks, and MCP server support. This page shows how to point the SDK at Requesty so your agents can use 300+ models from multiple providers. For the SDK's own API reference (hooks, tool definitions, MCP configuration, TypeScript interfaces), see [Anthropic's official Agent SDK documentation](https://docs.anthropic.com/en/api/agent-sdk/overview).

Using the Requesty integration, you can:

* Use 300+ models while building agents, giving you flexibility to choose the best model for each task
* Track and manage your spend in a single location
* Keep a record of your agent interactions

# Configuration

## Set ANTHROPIC\_BASE\_URL and ANTHROPIC\_AUTH\_TOKEN

The Claude Agent SDK reads the `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` environment variables, so the easiest way to integrate Requesty is:

1. **Get Your API Key**
   Create an API key on the [API Keys Page](https://app.requesty.ai/api-keys).

2. **Set Environment Variables**

   ```bash theme={"dark"}
   export ANTHROPIC_BASE_URL="https://router.requesty.ai"
   export ANTHROPIC_AUTH_TOKEN="your_requesty_api_key"
   export ANTHROPIC_MODEL="anthropic/claude-fable-5"
   ```

<Info>
  With this setup, the Agent SDKs will route all requests through Requesty, giving you access to models from OpenAI, Anthropic, Google,
  Mistral, and many more providers.
</Info>

### Model Selection

You can choose any model from the [Model Library](https://app.requesty.ai/model-list) or any policy configured for your organization.

**Standard model IDs** follow the format `provider/model-name`:

* `anthropic/claude-fable-5`
* `openai/gpt-5`
* `google/gemini-2.5-flash`
* `mistral/mistral-large-latest`

**Policies** follow the format `policy/policy-name`:

* `policy/reliable-sonnet-4-5`

## TypeScript

The TypeScript Agent SDK (`@anthropic-ai/claude-agent-sdk`) automatically respects the `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` environment variables.

```typescript theme={"dark"}
import { query } from '@anthropic-ai/claude-agent-sdk';

// Set environment variables before importing
// ANTHROPIC_BASE_URL=https://router.requesty.ai
// ANTHROPIC_AUTH_TOKEN=your_requesty_api_key

for await (const message of query({
  prompt: 'Your prompt here',
  options: {
    systemPrompt: 'You are a helpful assistant.',
  },
})) {
  // Handle messages
  if (message.type === 'assistant') {
    console.log(message.message.content);
  }
}
```

## Python

The Python Agent SDK (`claude-agent-sdk`) automatically respects the `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` environment variables.

```python theme={"dark"}
"""Minimal agent using Claude Agent SDK."""
import os
import asyncio

from claude_agent_sdk import (
    ClaudeSDKClient,
    ClaudeAgentOptions,
    tool,
    create_sdk_mcp_server,
    AssistantMessage,
    TextBlock,
)

os.environ["ANTHROPIC_BASE_URL"] = "https://router.requesty.ai"
# ANTHROPIC_AUTH_TOKEN should be set as an environment variable


async def main():
    @tool("greet", "Greet a user", {"name": str})
    async def greet_user(args):
        return {
            "content": [
                {"type": "text", "text": f"Hello, {args['name']}!"}
            ]
        }

    server = create_sdk_mcp_server(
        name="my-tools",
        version="1.0.0",
        tools=[greet_user]
    )

    options = ClaudeAgentOptions(
        mcp_servers={"tools": server},
        allowed_tools=["mcp__tools__greet"]
    )

    async with ClaudeSDKClient(options=options) as client:
        await client.query("Greet World")
        
        last_assistant_message = None
        async for msg in client.receive_response():
            if isinstance(msg, AssistantMessage):
                last_assistant_message = msg

        if last_assistant_message:
            print(last_assistant_message.content[0].text)


if __name__ == "__main__":
    asyncio.run(main())
```

## Looking for the Agent SDK API reference?

This page covers routing the SDK through Requesty. For the SDK itself, Anthropic maintains the official documentation:

* [Agent SDK overview](https://docs.anthropic.com/en/api/agent-sdk/overview), concepts, installation, and quickstart
* [TypeScript SDK reference](https://docs.anthropic.com/en/api/agent-sdk/typescript), `query()`, options, hooks, and tool interfaces
* [Python SDK reference](https://docs.anthropic.com/en/api/agent-sdk/python), `ClaudeSDKClient`, `ClaudeAgentOptions`, and `@tool`
* [MCP in the Agent SDK](https://docs.anthropic.com/en/api/agent-sdk/mcp), connecting MCP servers to your agents

Everything in those docs works unchanged through Requesty. Only the base URL and auth token differ.

## Benefits of Using Requesty with Agent SDKs

<CardGroup cols={2}>
  <Card title="Access 300+ Models" icon="brain">
    Switch between models from different providers without changing your setup
  </Card>

  <Card title="Cost Management" icon="chart-line">
    Monitor spending and set limits across all your AI interactions
  </Card>

  <Card title="Fallback Policies" icon="shield-check">
    Automatic fallbacks ensure your agents never get interrupted
  </Card>

  <Card title="Unified Interface" icon="plug">
    Use the same SDK interface with models from multiple providers
  </Card>
</CardGroup>

## Troubleshooting

### Model Not Found

If you get a "model not found" error, make sure:

* Your API key is valid and has access to the model (check the approved models in your organization)
* The model ID format is correct (`provider/model-name`)
* The model is available in the [Model Library](https://app.requesty.ai/model-list)

### Connection Issues

If the Agent SDK can't connect:

* Verify your `ANTHROPIC_BASE_URL` is set to `https://router.requesty.ai`
* Check your `ANTHROPIC_AUTH_TOKEN` is correct
* Ensure you have internet connectivity
* For TypeScript, make sure environment variables are set before importing the SDK
