# Claude Code

> Point Claude Code at the gateway, multi-provider routing, and Anthropic release checklist.

**Last updated:** 2026-07-23

Claude Code talks **Anthropic Messages** (`POST /v1/messages`, SSE, tools, betas, `count_tokens`). Through the gateway you can:

1. **Passthrough** to Anthropic (API key or subscription OAuth), or  
2. **Translate** to ChatGPT / SuperGrok / other OpenAI-compatible hosts while still using the Claude Code UI.

### Start here for day-to-day use

**[Claude Code with ChatGPT, Claude & SuperGrok](/llm-gateway/guides/claude-code-subscriptions/)** — full operator guide:

- Subscription OAuth login (`llm-gateway auth login …`)
- Any provider combo (`gpt`, `grok`, `gpt+grok`, `multi`, …)
- Grok 4.5 + Composer 2.5 aliases
- Shell helpers, settings.json, troubleshooting

This page is the **Anthropic path checklist** (release sign-off + minimal wiring). Prefer hermetic Go tests in CI; run the manual block for release candidates.

---

## Minimal wiring (API key)

```bash
export ANTHROPIC_BASE_URL=http://localhost:8787
export ANTHROPIC_API_KEY=sk-ant-…   # or edge key when edge_auth is on
# optional: export ANTHROPIC_MODEL=claude-sonnet-4-20250514
claude
# or: ./examples/claude-code.sh
```

```yaml
providers:
  anthropic:
kind: anthropic
base_url: "https://api.anthropic.com/v1"
api_key_env: ANTHROPIC_API_KEY
defaults:
  anthropic_dialect: anthropic
```

With **edge_auth** enabled, set `ANTHROPIC_API_KEY` / `KEY` to an edge key and keep the upstream secret in `api_key_env` (or subscription `oauth.credentials`).

---

## Automated coverage

```bash
go test ./proxy/ -count=1
go test ./ingress/anthropic/ ./egress/anthropic/ -count=1
```

| Area | Tests (representative) |
|---|---|
| Messages passthrough | `TestAnthropicStreamPassthrough`, non-stream Anthropic server tests in `proxy/*` |
| Upstream errors | `TestAnthropicUpstreamError`, `TestAnthropicToOpenAIUpstreamErrorTranslated` |
| Translate path | `TestOpenAIToAnthropic*`, `TestAnthropicToOpenAI*` |
| count_tokens | `TestCountTokens*`, `proxy/count_tokens_test.go` |
| Edge auth open healthz | `TestEdgeAuthHealthzOpen` |

---

## Manual release sign-off

### Config sketch

```yaml
providers:
  anthropic:
kind: anthropic
base_url: "https://api.anthropic.com/v1"
api_key_env: ANTHROPIC_API_KEY
  deepseek:
kind: openai_compat
base_url: "https://api.deepseek.com"
api_key_env: DEEPSEEK_API_KEY
defaults:
  anthropic_dialect: anthropic
aliases:
  # cheap: deepseek/deepseek-chat
```

### Functional checks

- [ ] Non-stream short completion  
- [ ] Stream completion (tokens appear incrementally; no truncated SSE)  
- [ ] Tool use / function calling round-trip  
- [ ] Multimodal image input (if used in your workflows)  
- [ ] `count_tokens` still returns a number  
- [ ] Prompt-caching / beta headers: client `anthropic-beta` values reach upstream on passthrough  
- [ ] Model routing: bare id → anthropic default; `provider/model` and aliases  
- [ ] Translated path (optional): `ANTHROPIC_MODEL=deepseek/deepseek-chat` — full translation; stream `input_tokens` may be 0 until final event  

### Negative checks

- [ ] Bad key → Anthropic-shaped error envelope  
- [ ] Unknown model provider → 404 dialect error  
- [ ] Gateway `/healthz` still 200 without credentials  

### Sign-off

- [ ] `go test ./... -race` green  
- [ ] CHANGELOG entry if Anthropic surface or caveats changed  
- [ ] No secrets committed  

---

## Known limitations (translated path)

| Topic | Behavior |
|---|---|
| Anthropic → openai_compat stream | `message_start.input_tokens` may be 0 until final usage |
| OpenAI-only fields | Dropped on translate — [Deprecation policy](/llm-gateway/reference/deprecation-policy/) |
| Files / Batch APIs | Not required for Claude Code chat |
| Media Contract Anthropic images | Planned; not required for text Claude Code |

---

## Related

- **[Claude Code + subscriptions (full guide)](/llm-gateway/guides/claude-code-subscriptions/)**  
- [OAuth & upstream auth](/llm-gateway/guides/oauth-auth/)  
- [Compatibility matrix](/llm-gateway/reference/compatibility-matrix/)  
- [examples/claude-code.sh](https://github.com/inja-online/llm-gateway/blob/master/examples/claude-code.sh)  
- [examples/claude-code-multi.sh](https://github.com/inja-online/llm-gateway/blob/master/examples/claude-code-multi.sh)