# Claude Code

Source: https://staging-docs.aiand.com/integrations/claude-code/

[Claude Code](https://claude.com/claude-code) talks to the Anthropic Messages API. ai& exposes an Anthropic-compatible `/v1/messages` endpoint, so any tool-calling model in our [catalog](/models/catalog/) can drive the agent loop.

<Aside type="note">
  The config below maps ai& models to Claude Code's slots by capability: `moonshotai/kimi-k2.6` drives **Opus** and **Sonnet** (the heavy lifting), while the cheaper, faster `deepseek-ai/deepseek-v4-flash` handles **Haiku** (lightweight background tasks). Swap any line for another `tool_calling` model in the [catalog](/models/catalog/).
</Aside>

Two ways to wire it up:

- **[Session](#session-current-terminal-only)** — `export` the env vars into your current shell. Lost when you close the terminal. Good for a one-off try.
- **[Permanent](#permanent-settingsjson)** — drop the same config into `settings.json`. Persists across sessions, can be scoped per project or globally.

## Session (current terminal only)

<Tabs syncKey="os">
<TabItem label="macOS / Linux">

**1. Install Claude Code**

Prerequisite: [Node.js 18 or newer](https://nodejs.org/).

```bash
npm install -g @anthropic-ai/claude-code
```

Confirm the install — `claude --version` should print a version number:

```bash
claude --version
```

**2. Set the env vars in this terminal**

```bash
export ANTHROPIC_BASE_URL="https://api.aiand.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-aiand-api-key"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_DEFAULT_OPUS_MODEL="moonshotai/kimi-k2.6"
export ANTHROPIC_DEFAULT_SONNET_MODEL="moonshotai/kimi-k2.6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-ai/deepseek-v4-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="moonshotai/kimi-k2.6"
```

**3. Run Claude Code**

```bash
claude
```

</TabItem>
<TabItem label="Windows (PowerShell)">

**1. Install Claude Code**

Prerequisites:

- [Node.js 18 or newer](https://nodejs.org/)
- [Git for Windows](https://git-scm.com/download/win)

```powershell
npm install -g @anthropic-ai/claude-code
```

Confirm the install — `claude --version` should print a version number:

```powershell
claude --version
```

**2. Set the env vars in this terminal**

```powershell
$env:ANTHROPIC_BASE_URL = "https://api.aiand.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-aiand-api-key"
$env:ANTHROPIC_API_KEY = ""
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "moonshotai/kimi-k2.6"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "moonshotai/kimi-k2.6"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "deepseek-ai/deepseek-v4-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL = "moonshotai/kimi-k2.6"
```

**3. Run Claude Code**

```powershell
claude
```

</TabItem>
</Tabs>

## Permanent (settings.json)

Claude Code reads its config from a `settings.json` file on startup. Drop the same `env` block in and you never have to re-export:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.aiand.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-aiand-api-key",
    "ANTHROPIC_API_KEY": "",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "moonshotai/kimi-k2.6",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "moonshotai/kimi-k2.6",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-ai/deepseek-v4-flash",
    "CLAUDE_CODE_SUBAGENT_MODEL": "moonshotai/kimi-k2.6"
  }
}
```

Two scopes — pick one:

- **Project (`.claude/settings.local.json` in your repo)** — applies only when you run `claude` from this repo. Git ignores `*.local.json` by Claude Code convention, so the key never gets committed. Recommended for trying ai& without touching your global setup.
- **Global (`~/.claude/settings.json`)** — applies machine-wide. Every Claude Code surface on your machine picks up the same ai& backend: the `claude` CLI in any terminal session, the [Claude Code VS Code extension](https://code.claude.com/docs/en/vs-code) (the extension and CLI [share this file](https://code.claude.com/docs/en/vs-code#configure-settings) by design), **and** the Claude Desktop app. Use this once ai& is your default everywhere.

The commands below **safely merge** the `env` block into the file — any existing keys you have (`permissions`, `hooks`, etc.) are preserved. They use Node, which is already on your machine since step 1 installed Claude Code via npm. Replace `sk-your-aiand-api-key` with your real key before running.

### Project scope (recommended for first try)

<Tabs syncKey="os">
<TabItem label="macOS / Linux">

Run from the root of your project:

```bash
mkdir -p .claude && node -e '
const fs = require("fs"), p = ".claude/settings.local.json";
const d = fs.existsSync(p) ? JSON.parse(fs.readFileSync(p, "utf8")) : {};
d.env = Object.assign(d.env || {}, {
  ANTHROPIC_BASE_URL: "https://api.aiand.com",
  ANTHROPIC_AUTH_TOKEN: "sk-your-aiand-api-key",
  ANTHROPIC_API_KEY: "",
  ANTHROPIC_DEFAULT_OPUS_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_SONNET_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_HAIKU_MODEL: "deepseek-ai/deepseek-v4-flash",
  CLAUDE_CODE_SUBAGENT_MODEL: "moonshotai/kimi-k2.6"
});
fs.writeFileSync(p, JSON.stringify(d, null, 2));
'
```

</TabItem>
<TabItem label="Windows (PowerShell)">

Run from the root of your project:

```powershell
New-Item -ItemType Directory -Force -Path .claude | Out-Null
$script = @'
const fs = require("fs"), p = ".claude/settings.local.json";
const d = fs.existsSync(p) ? JSON.parse(fs.readFileSync(p, "utf8")) : {};
d.env = Object.assign(d.env || {}, {
  ANTHROPIC_BASE_URL: "https://api.aiand.com",
  ANTHROPIC_AUTH_TOKEN: "sk-your-aiand-api-key",
  ANTHROPIC_API_KEY: "",
  ANTHROPIC_DEFAULT_OPUS_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_SONNET_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_HAIKU_MODEL: "deepseek-ai/deepseek-v4-flash",
  CLAUDE_CODE_SUBAGENT_MODEL: "moonshotai/kimi-k2.6"
});
fs.writeFileSync(p, JSON.stringify(d, null, 2));
'@
node -e $script
```

</TabItem>
</Tabs>

### Global scope (all projects)

<Tabs syncKey="os">
<TabItem label="macOS / Linux">

```bash
mkdir -p ~/.claude && node -e '
const fs = require("fs"), os = require("os"), path = require("path");
const p = path.join(os.homedir(), ".claude", "settings.json");
const d = fs.existsSync(p) ? JSON.parse(fs.readFileSync(p, "utf8")) : {};
d.env = Object.assign(d.env || {}, {
  ANTHROPIC_BASE_URL: "https://api.aiand.com",
  ANTHROPIC_AUTH_TOKEN: "sk-your-aiand-api-key",
  ANTHROPIC_API_KEY: "",
  ANTHROPIC_DEFAULT_OPUS_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_SONNET_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_HAIKU_MODEL: "deepseek-ai/deepseek-v4-flash",
  CLAUDE_CODE_SUBAGENT_MODEL: "moonshotai/kimi-k2.6"
});
fs.writeFileSync(p, JSON.stringify(d, null, 2));
'
```

</TabItem>
<TabItem label="Windows (PowerShell)">

```powershell
New-Item -ItemType Directory -Force -Path $HOME\.claude | Out-Null
$script = @'
const fs = require("fs"), os = require("os"), path = require("path");
const p = path.join(os.homedir(), ".claude", "settings.json");
const d = fs.existsSync(p) ? JSON.parse(fs.readFileSync(p, "utf8")) : {};
d.env = Object.assign(d.env || {}, {
  ANTHROPIC_BASE_URL: "https://api.aiand.com",
  ANTHROPIC_AUTH_TOKEN: "sk-your-aiand-api-key",
  ANTHROPIC_API_KEY: "",
  ANTHROPIC_DEFAULT_OPUS_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_SONNET_MODEL: "moonshotai/kimi-k2.6",
  ANTHROPIC_DEFAULT_HAIKU_MODEL: "deepseek-ai/deepseek-v4-flash",
  CLAUDE_CODE_SUBAGENT_MODEL: "moonshotai/kimi-k2.6"
});
fs.writeFileSync(p, JSON.stringify(d, null, 2));
'@
node -e $script
```

</TabItem>
</Tabs>

## Verify

Inside Claude Code, run:

```text
/status
```

The panel shows the active base URL and model. You should see `https://api.aiand.com` and `moonshotai/kimi-k2.6`.

You can also probe the wire-level path from the shell:

<Tabs syncKey="os">
<TabItem label="macOS / Linux">

```bash
curl -sS https://api.aiand.com/v1/models \
  -H "Authorization: Bearer sk-your-aiand-api-key" \
  | grep -o 'moonshotai/kimi-k2.6'
```

</TabItem>
<TabItem label="Windows (PowerShell)">

```powershell
(Invoke-RestMethod https://api.aiand.com/v1/models `
  -Headers @{ Authorization = "Bearer sk-your-aiand-api-key" }).data.id `
  | Select-String "moonshotai/kimi-k2.6"
```

</TabItem>
</Tabs>

A match means the key authenticates and the model is on your org.

<Aside type="note">
  If you previously signed in to Claude Code with an Anthropic account, run `/logout` once inside `claude` — the cached OAuth credential takes priority over the env / settings.json values, and you'll silently keep hitting Anthropic instead of ai&.
</Aside>
