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

# Claude Code

> Connect Claude Code to the AI Stats Gateway via the Anthropic-compatible API.

Claude Code supports third-party LLM gateways via environment variables. AI Stats exposes an Anthropic-compatible surface at `/v1/messages`, so you can point Claude Code at AI Stats without changing your prompts.

## Prerequisites

* An AI Stats API key.
* Claude Code installed locally.

## 1) Set gateway environment variables

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.phaseo.app"
export ANTHROPIC_AUTH_TOKEN="your_ai_stats_api_key"
export ANTHROPIC_API_KEY=""
```

```powershell theme={null}
$env:ANTHROPIC_BASE_URL = "https://api.phaseo.app"
$env:ANTHROPIC_AUTH_TOKEN = "your_ai_stats_api_key"
$env:ANTHROPIC_API_KEY = ""
```

## 2) Pick a model (optional)

Set `ANTHROPIC_MODEL` if you want a fixed default. Use model ids listed in [Models](../../api-reference/endpoint/models.mdx).

## 3) Start Claude Code

```bash theme={null}
claude
```

## Endpoint mapping

* Claude Code calls Anthropic-style endpoints (`/v1/messages`).
* AI Stats handles those requests through [Anthropic Messages](../../api-reference/endpoint/anthropic-messages.mdx).

## Compatibility notes

* `ANTHROPIC_AUTH_TOKEN` is sent as an `Authorization` header, which AI Stats accepts.
* Current limitation: streaming + tools on Anthropic Messages can return `400 invalid_request`. If your workflow depends on streamed tool loops, test this path before broad rollout.
