# Claude Code

Local CLI; IDE extension/Desktop/cloud have separate configuration.

Source: https://zrelay.net/docs/agents/coding-agents/claude-code/

## Manual setup

1. Check claude --version. Create or merge ~/.claude/zrelay.json (Windows: %USERPROFILE%\.claude\zrelay.json) with the JSON below. Preserve existing settings, managed policies and saved login.

2. Use a Claude Flex/Prime key. Both claude-sonnet-4-6 and auxiliary claude-haiku-4-5 need enabled Messages routes. Enter the secret locally, then launch with --settings as shown. In a Zsh terminal enter Bash before using its read flags.

3. ANTHROPIC_AUTH_TOKEN supplies Bearer and temporarily supersedes saved login; no logout is needed. ANTHROPIC_API_KEY uses x-api-key and may need initial approval. Use one selected mechanism and inspect conflicting env settings without exposing values.

4. Inspect /status for URL, model and credential source without sending a message. --settings supplements existing settings for this launch. Root base https://api.zrelay.net lets the client append /v1/messages. The VS Code extension requires claudeCode.environmentVariables for its login check; Desktop has its own guide.

## Configuration and commands

```
{
  "model": "claude-sonnet-4-6",
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.zrelay.net",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
    "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "4096",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "128000"
  }
}
```

```
read -r -s -p 'Zrelay API key: ' ZRELAY_API_KEY
printf '\n'
ANTHROPIC_AUTH_TOKEN="$ZRELAY_API_KEY" claude --settings "$HOME/.claude/zrelay.json"
```

```
$secret = Read-Host 'Zrelay API key' -AsSecureString
$env:ZRELAY_API_KEY = [System.Net.NetworkCredential]::new('', $secret).Password
$env:ANTHROPIC_AUTH_TOKEN = $env:ZRELAY_API_KEY
claude --settings "$env:USERPROFILE\.claude\zrelay.json"
```

## Alternative: ask an AI assistant

Copy this complete prompt into your coding assistant. It describes configuration work; installation and paid tests need your authorization.

```
Configure my local Claude Code CLI for Zrelay. Detect OS, shell and installed Claude Code version. Read https://code.claude.com/docs/en/llm-gateway-connect, https://code.claude.com/docs/en/model-config and https://code.claude.com/docs/en/settings; check https://keys.zrelay.net/api/catalog. Use Anthropic Messages with base https://api.zrelay.net and Bearer authentication through ANTHROPIC_AUTH_TOKEN sourced from my privately entered ZRELAY_API_KEY. Never read out, log, print, paste or request my actual key in chat. Preserve existing settings, managed policies and saved login. Create or merge a dedicated ~/.claude/zrelay.json passed with --settings. Select exact enabled Claude model IDs matching my key's provider/pool, including auxiliary Haiku use; configure supported output/context limits from the catalog. Resolve credential conflicts without exposing secrets or replacing global configuration. Validate installed version, JSON and effective configuration without inference. Ask explicit permission before installation, upgrades or paid requests. Report configuration checks separately from untested streaming, tool loops and gateway features. Provide the exact OS-specific launch command and local secret-entry instructions.
```

## Limits and verification

The context/output settings adapt to 128000/4096 catalog limits; they are not functional test evidence. Other model aliases need their own eligible routes. Slack and cloud sessions do not inherit this local connection.

These recipes were reviewed against documentation and public catalog data. No client installation, authenticated request, paid inference, streaming or tool loop was executed. Validate configuration first; a later short text test does not establish complete agent compatibility.

Recheck the [live catalog](https://keys.zrelay.net/api/catalog) and your key’s provider/pool. The reviewed examples have 128000 input and 4096 output maxima unless a client limitation above prevents controlling the request. Never print, log or commit credentials.

## Official sources

Documentation checked 2026-11-09; mutable sources can differ from your installed version.

[https://code.claude.com/docs/en/llm-gateway-connect](https://code.claude.com/docs/en/llm-gateway-connect)

[https://code.claude.com/docs/en/model-config](https://code.claude.com/docs/en/model-config)

[https://code.claude.com/docs/en/settings](https://code.claude.com/docs/en/settings)

[https://keys.zrelay.net/api/catalog](https://keys.zrelay.net/api/catalog)

[https://code.claude.com/docs/en/env-vars](https://code.claude.com/docs/en/env-vars)

[https://code.claude.com/docs/en/llm-gateway-protocol](https://code.claude.com/docs/en/llm-gateway-protocol)

[https://code.claude.com/docs/en/llm-gateway](https://code.claude.com/docs/en/llm-gateway)

[https://keys.zrelay.net/api/catalog](https://keys.zrelay.net/api/catalog)
