> ## 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 Code | AI Gateway

> Route Claude Code's model calls through the Orq.ai AI Gateway for unified tracing and cost tracking.

<Badge>Beta</Badge>

[**Claude Code**](https://github.com/anthropics/claude-code) is Anthropic's official CLI for agentic coding in the terminal. Set a few environment variables to route every model call it makes through the **AI Gateway**, giving each session unified tracing and cost tracking across the full model catalog.

## Prerequisites

* [**Claude Code** CLI](https://github.com/anthropics/claude-code) installed
* Active **Orq.ai** account
* [**Orq.ai** API key](/docs/ai-gateway/configuration/api-keys)

## Setup

Set the following environment variables before launching **Claude Code**. Once set, every model call **Claude Code** makes is routed through the [**Orq.ai AI Gateway**](/docs/ai-gateway/get-started/quickstart) for the duration of that session.

```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=""  # must be set to empty to prevent Claude Code from using the Anthropic API directly
export ANTHROPIC_MODEL="anthropic/claude-sonnet-4-5"  # the anthropic/ prefix is required
```

<Info>
  Claude Code requests routed through the **AI Gateway** appear in [Traces](/docs/ai-gateway/traces).
</Info>

## Troubleshooting

<AccordionGroup>
  <Accordion title="400 invalid model format">
    The `ANTHROPIC_MODEL` value is missing the provider prefix. Use the `provider/model_id` format (e.g. `anthropic/claude-sonnet-4-5`, not `claude-sonnet-4-5`).
  </Accordion>

  <Accordion title="Claude Code calls Anthropic directly instead of Orq.ai">
    `ANTHROPIC_API_KEY` must be set to an empty string. When it holds a value, **Claude Code** uses the Anthropic API directly and requests bypass the **AI Gateway**.
  </Accordion>

  <Accordion title="Requests not appearing in Orq.ai Traces">
    Verify `ANTHROPIC_BASE_URL` is set to `https://api.orq.ai/v3/anthropic`. Requests sent to Anthropic's own endpoint bypass the **AI Gateway** and produce no **Traces**.
  </Accordion>
</AccordionGroup>

## Verification

Start a **Claude Code** session and send a prompt. The response appears in the terminal and the trace appears in [**Orq.ai** Traces](/docs/ai-gateway/traces) with the model identifier `anthropic/claude-sonnet-4-5` (or whichever model `ANTHROPIC_MODEL` is set to).
