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

# Claude Code

> Run Claude Code against your own models through Nemu

Claude Code speaks the Anthropic Messages API, and Nemu serves it, so pointing
the CLI at Nemu is a matter of two environment variables. Every request is then
billed, quota-checked and logged against your workspace, and can be answered by
any provider you have connected, not only Anthropic.

## 1. Create a gateway key

In the console, open **API keys** and create one. It is scoped to the workspace
you are in.

## 2. Point Claude Code at Nemu

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.nemu.cc/anthropic"
export ANTHROPIC_AUTH_TOKEN="YOUR_NEMU_GATEWAY_KEY"
claude
```

Use `ANTHROPIC_AUTH_TOKEN`, not `ANTHROPIC_API_KEY`. The first sends
`Authorization: Bearer`, which is what a Nemu gateway key expects. Nemu also
accepts `x-api-key`, so `ANTHROPIC_API_KEY` works, but the bearer header is the
one to reach for.

To keep it out of your shell profile, put it in `~/.claude/settings.json`
instead. Values there win over shell exports.

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.nemu.cc/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_NEMU_GATEWAY_KEY"
  }
}
```

<Note>
  The base URL ends in `/anthropic`. Claude Code appends `/v1/messages` itself.
  Setting it to a bare `https://api.nemu.cc` also works for inference, but the
  `/anthropic` prefix is what serves the Anthropic-shaped model list, so prefer
  it.
</Note>

## 3. Choose a model

Claude Code's `/model` picker can be filled from Nemu:

```bash theme={null}
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
```

With that set, `/model` lists the models enabled in your workspace by their
gateway name. Without it, name one directly:

```bash theme={null}
export ANTHROPIC_MODEL="openrouter/nemotron"
```

`GET /anthropic/v1/models` reports the exact strings that are accepted:

```bash theme={null}
curl https://api.nemu.cc/anthropic/v1/models \
  -H "x-api-key: YOUR_NEMU_GATEWAY_KEY" \
  -H "anthropic-version: 2023-06-01"
```

If you want to keep Anthropic's own model names in your config, create a mapping
in the console from `claude-sonnet-4-5` to whatever should actually serve it.

## Verifying the connection

```bash theme={null}
curl -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"openrouter/nemotron","max_tokens":32,"messages":[{"role":"user","content":"hi"}]}'
```

A 200 with a `content` array means Claude Code will work. A 404 saying
`Invalid URL` means the base URL is missing the `/anthropic` segment. A 404
naming the model means it is not enabled in this key's workspace.

## What Claude Code asks Nemu for

| Endpoint                         | Required | Purpose                                   |
| -------------------------------- | -------- | ----------------------------------------- |
| `POST /v1/messages`              | yes      | Every inference request, streaming        |
| `POST /v1/messages/count_tokens` | no       | Context accounting                        |
| `GET /v1/models`                 | no       | Only with gateway model discovery enabled |
| `GET /api/hello`                 | no       | Connection warm-up probe                  |

Nemu serves all four. Fast-mode availability and WebFetch domain checks go to
Anthropic directly and never touch the gateway.

## Useful extras

| Variable                                   | What it does                                        |
| ------------------------------------------ | --------------------------------------------------- |
| `ANTHROPIC_DEFAULT_HAIKU_MODEL`            | Model used for Claude Code's small background tasks |
| `API_TIMEOUT_MS`                           | Request timeout, default 600000                     |
| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | Set to `1` to stop telemetry and version checks     |
| `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`   | Stop sending pre-release request fields upstream    |
| `ANTHROPIC_CUSTOM_HEADERS`                 | Extra headers, one `Name: Value` per line           |

## Notes on compatibility

Nemu converts an Anthropic-shaped request into whatever the target provider
speaks, so a model behind an OpenAI-compatible provider still answers Claude
Code correctly: tool calls, streaming events, system blocks and cache
breakpoints are all translated. Thinking is mapped to whatever the target model
supports rather than being passed through blindly, so asking for extended
thinking on a model without it does not fail the request.
