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

# Claude Code

> Point Claude Code at the AI Reserve gateway with three environment variables — no code change, no plugin — including the full 1M-token context.

<Card title="Connect Claude Code in one click →" icon="zap" href="https://aireserve.com/connect/claude-code" horizontal>
  The guided connect page creates a managed key for your account and writes the
  `env` block of `~/.claude/settings.json` for you — no terminal work.
</Card>

Everything below is the manual equivalent.

Claude Code is configured entirely through environment variables — no code change, no
plugin. Set the base URL to the host root (no `/v1`), pass your AI Reserve key
as the auth token, and make sure `ANTHROPIC_API_KEY` is empty so the CLI
doesn't prefer it:

```bash theme={"dark"}
# Point Claude Code at the AI Reserve gateway
export ANTHROPIC_BASE_URL="https://api.aireserve.com"   # host root — NO /v1
export ANTHROPIC_AUTH_TOKEN="$AUDACITY_API_KEY"                   # your aireserve_api_… key
export ANTHROPIC_API_KEY=""                                       # must be empty

# Recommended: pin the model in its [1m] form for the full 1M-token context
export ANTHROPIC_MODEL="claude-sonnet-4-6[1m]"
export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5-20251001"

claude   # every request is now metered and billed through your AI Reserve key
```

Add the exports to your shell profile (or the `env` block of
`~/.claude/settings.json`) to make the routing permanent. Requests hit
`/v1/messages` — including `count_tokens` — so the full agent
loop, tool use, and prompt caching work unchanged.

## Why the `[1m]` suffix?

When Claude Code talks to a gateway
it can't verify 1M support, so it budgets a 200K window by default — the context meter
fills five times faster than first-party even though the gateway serves the full
window. The `[1m]` id form tells Claude Code to budget the same 1M-token
context it has first-party. It works on every extended-context model
(`claude-sonnet-4-6`, `fable-5`, `opus-4-8`):

```bash theme={"dark"}
# The flagship at full context works the same way
export ANTHROPIC_MODEL="fable-5[1m]"
```

Claude Code strips the suffix before sending and adds the
`anthropic-beta: context-1m-2025-08-07` opt-in, which the gateway relays to
Anthropic — and the gateway also accepts the `[1m]` id form directly, so
either convention works. Selecting a 1M variant from the `/model` picker is
known not to stick behind a custom base URL; pin it through the environment variable
instead. Tokens are billed at the model's normal rates.

## Claude Agent SDK

The embeddable agent runtime takes the same three variables via
`options.env`:

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

for await (const message of query({
  prompt: "hello",
  options: {
    model: "claude-haiku-4-5-20251001",
    env: {
      ...process.env, // options.env REPLACES the environment — keep PATH etc.
      ANTHROPIC_BASE_URL: "https://api.aireserve.com", // host root
      ANTHROPIC_AUTH_TOKEN: process.env.AUDACITY_API_KEY!,
      ANTHROPIC_API_KEY: "",
    },
  },
})) { /* ... */ }
```
