# Claude Code

Set Claude Code up on OpenDunes once, for every session and every project.

[Coding agents](/docs/coding-agents) points Claude Code at OpenDunes for one terminal. This recipe makes it stay: the key in your shell profile, the address and the models in Claude Code's own settings file.

1. [Install Claude Code](#1-install-claude-code).
2. [Keep the key in your shell profile](#2-keep-the-key-in-your-shell-profile).
3. [Write the settings file](#3-write-the-settings-file).
4. [Check the connection](#4-check-the-connection).
5. [Share the setup with your team](#5-share-the-setup-with-your-team).

## 1. Install Claude Code

| On | Install line |
|---|---|
| macOS, Linux, WSL | `curl -fsSL https://claude.ai/install.sh \| bash` |
| Windows, PowerShell | `irm https://claude.ai/install.ps1 \| iex` |
| any, with Node 22 or later | `npm install -g @anthropic-ai/claude-code` |

Run `claude --version` to see it answer.

## 2. Keep the key in your shell profile

Create an API key for Claude Code alone, and cap it on *API Keys*: an agent sends many requests for one task, and the cap stops this key alone ([API keys](/docs/api-keys) shows how). Then add two lines to `~/.zshrc`, or `~/.bashrc`:

```bash
export OPENDUNES_API_KEY="…"
export ANTHROPIC_AUTH_TOKEN="$OPENDUNES_API_KEY"
```

`ANTHROPIC_AUTH_TOKEN` is the variable Claude Code sends as `Authorization: Bearer`. Open a new terminal, so both are set.

## 3. Write the settings file

Claude Code reads `~/.claude/settings.json` in every project. Its `env` block sets the address and one model for each of Claude Code's roles. Claude Code runs on Claude models only: each value is an `anthropic/` model ID.

```json
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "env": {
    "ANTHROPIC_BASE_URL": "https://opendunes.com",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-opus-5.5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-sonnet-4.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-4.5",
    "CLAUDE_CODE_SUBAGENT_MODEL": "anthropic/claude-sonnet-4.5"
  },
  "model": "sonnet"
}
```

| Setting | Holds |
|---|---|
| `ANTHROPIC_BASE_URL` | the address, without `/v1`: Claude Code sends each request to [`POST /v1/messages`](/docs/reference/messages) |
| `ANTHROPIC_DEFAULT_OPUS_MODEL` | the model behind `opus` in `/model` |
| `ANTHROPIC_DEFAULT_SONNET_MODEL` | the model behind `sonnet` in `/model` |
| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | the model behind `haiku`, which also runs background work such as a session's title |
| `CLAUDE_CODE_SUBAGENT_MODEL` | the model each subagent runs on |
| `model` | the role a session starts on |

Switch roles in a session with `/model`: `opus` for a hard change, `sonnet` for the day's work. Each model is charged at its own rate: its page in [Models](/docs/models) shows it.

<div class="dont">
<p>Don't put your key in <code>.claude/settings.json</code> inside a project. That file is committed, and the key goes with it.</p>
</div>

<div class="do">
<p>Keep the key in your shell profile, as in step 2, and only the address and the models in a settings file.</p>
</div>

## 4. Check the connection

Start Claude Code in your project and run `/status`. It shows the Anthropic base URL, `https://opendunes.com`, and an auth token as the credential. A line naming a Claude account instead means a saved login won: run `/logout`, then start `claude` again.

To check from the terminal alone, send one short task:

```bash
claude -p "Name this project's main language in one word." --model sonnet
```

It answers in one line and exits. The request is on *Activity*, in the app, with its charge in DA.

## 5. Share the setup with your team

Commit the address and the models as `.claude/settings.json` in the project: the same `env` block as step 3, without a key. Everyone who clones the project runs Claude Code on OpenDunes with the same models, each on their own key, from their own shell profile.

A setting in `.claude/settings.local.json` overrides the shared one for you alone, and Claude Code keeps that file out of git.

<div class="watch-out">
<p>A value in a settings file's <code>env</code> block wins over the same variable exported in your shell. To try another model for one session, use <code>/model</code> or <code>--model</code>, not an <code>export</code>.</p>
</div>

## Errors

| Status | Means | Do |
|---|---|---|
| 401 | no key reached Claude Code | check `ANTHROPIC_AUTH_TOKEN` is set in the terminal Claude Code starts from |
| 402 | the balance is at zero or below, cannot pay the request's hold, or the key's cap is spent | make a deposit, or raise the cap |
| 404 | a model ID not on sale, often one of Claude Code's own names such as `claude-sonnet-4-5` | set every model variable in step 3 to an `anthropic/` ID from Models |
| 400 | the body names the `anthropic-beta` header, or reads *Extra inputs are not permitted* | add `"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"` to the `env` block |

Every other status: [Errors and retries](/docs/errors-and-retries).

Next: [Claude Desktop](/docs/cookbook/claude-desktop) · [Automatic code review](/docs/cookbook/automatic-code-review)
