# Claude Code

> Connecting Claude Code to the gateway — environment variables, model choice and troubleshooting.

Claude Code works through `/v1/messages` in the Anthropic format.

## Quick start

Set the address, the key and the model, then run Claude Code:

```bash
export ANTHROPIC_BASE_URL=https://ai-seller.vibe-codes.ru
export ANTHROPIC_AUTH_TOKEN=$AISELLER_API_KEY
export ANTHROPIC_MODEL=gpt-5.6-sol
export ANTHROPIC_DEFAULT_HAIKU_MODEL=gpt-5.6-sol
claude
```

To avoid setting the variables in every terminal, put them in
`~/.claude/settings.json`:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai-seller.vibe-codes.ru",
    "ANTHROPIC_AUTH_TOKEN": "$AISELLER_API_KEY",
    "ANTHROPIC_MODEL": "gpt-5.6-sol",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-5.6-sol"
  }
}
```

## Choosing a model

The model is required: without `ANTHROPIC_MODEL` Claude Code requests its own
model IDs (`claude-…`), which may not be in the catalog, and gets
`404 model_not_found`. `ANTHROPIC_DEFAULT_HAIKU_MODEL` is the model for Claude
Code's background tasks; if you switch with `/model`, also set
`ANTHROPIC_DEFAULT_SONNET_MODEL` and `ANTHROPIC_DEFAULT_OPUS_MODEL`. Take IDs
from the [catalog](https://ai-seller.vibe-codes.ru/en/docs/models).

> The gateway does not translate formats, so only a model whose provider supports
> Anthropic Messages will work (see [API overview](https://ai-seller.vibe-codes.ru/en/docs/endpoints#request-format-and-model)).

## How it works

- `ANTHROPIC_AUTH_TOKEN` is sent as `Authorization: Bearer` — the gateway
  accepts it. A key in `ANTHROPIC_API_KEY` (the `x-api-key` header) works too.
- `anthropic-beta` headers are not passed to the provider: API beta features
  are unavailable, and Claude Code works without them.
- Claude Code's requests show up in the cabinet like any key's. A separate key
  with a spend limit for Claude Code is handy.

## Troubleshooting

| Symptom | Cause and fix |
| --- | --- |
| `404 model_not_found` | `ANTHROPIC_MODEL` is not set or the ID has a typo — check `GET /v1/models`. |
| `401 authentication_error` | Wrong or revoked key; make sure a different `ANTHROPIC_API_KEY` is not set at the same time. |
| `400 invalid_request_error` on every request | The model's provider does not support the Anthropic format — pick another model. |
| “Prompt is too long” | The context is full — Claude Code will offer `/compact` itself. |
| `429` | Too many concurrent requests (for example, several sessions) — Claude Code retries by itself. |
