> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kymaapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> Point Claude Code at Kyma with two environment variables.

Claude Code reads an Anthropic-shaped API. Kyma serves one at `/v1/messages`, so
Claude Code works against Kyma with two environment variables and no plugin,
proxy or wrapper.

## Setup

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.kymaapi.com"
export ANTHROPIC_AUTH_TOKEN="ky-your-api-key"

claude
```

<Warning>
  `ANTHROPIC_BASE_URL` takes the host **without** `/v1`. Claude Code appends the
  path itself, so `https://api.kymaapi.com/v1` becomes `/v1/v1/messages` and every
  request 404s. This is the one thing people get wrong.
</Warning>

`ANTHROPIC_AUTH_TOKEN` sends your key as a bearer token. If you would rather use
the header Anthropic's own SDK sends, `ANTHROPIC_API_KEY` works identically and
goes out as `x-api-key`. Either is fine; use one, not both.

## Making it permanent

Environment variables last as long as your shell. To keep the setting, put it in
`~/.claude/settings.json`:

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.kymaapi.com",
    "ANTHROPIC_AUTH_TOKEN": "ky-your-api-key"
  }
}
```

The same block works per-project in `.claude/settings.json`, which is how you
point one repository at Kyma and leave everything else alone.

In the VS Code extension the equivalent setting is
`claudeCode.environmentVariables`. In GitHub Actions, put both in the step's
`env:`. In the Agent SDK, pass them as `options.env`.

## Choosing a model

Kyma serves these under Claude Code's own naming, so `/model` and the
`ANTHROPIC_MODEL` variable behave the way you expect:

```bash theme={null}
export ANTHROPIC_MODEL="claude-sonnet-5"
```

| Model                | Good for                                        |
| -------------------- | ----------------------------------------------- |
| `claude-opus-5`      | The hardest work — architecture, long refactors |
| `claude-opus-5-fast` | Opus quality when latency matters               |
| `claude-sonnet-5`    | The default. Most sessions want this            |
| `claude-sonnet-4-6`  | Previous generation, cheaper                    |
| `claude-haiku-4-5`   | Quick edits, cheap loops, subagents             |

You are not limited to those. Anything in the catalogue that supports tool
calling will drive Claude Code — `kimi-k2.6`, `qwen-3-coder` and `glm-5.2` all
return proper `tool_use` blocks through `/v1/messages`. Set `ANTHROPIC_MODEL` to
any model id from [the model list](https://kymaapi.com/models).

<Note>
  Anthropic does not support or audit third-party gateways, and says so plainly in
  their documentation. Running Claude Code against any gateway — Kyma included —
  is outside what their support covers. It works; it is simply not their problem
  if it does not.
</Note>

## Checking it worked

```bash theme={null}
curl https://api.kymaapi.com/v1/messages \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-haiku-4-5",
    "max_tokens": 16,
    "messages": [{ "role": "user", "content": "say ok" }]
  }'
```

A `200` with a `content` array means Claude Code will work. A `404` almost
always means `/v1` was left on the end of `ANTHROPIC_BASE_URL`.

## Model discovery

Claude Code can populate its `/model` picker from the gateway:

```bash theme={null}
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
```

Kyma's `/v1/models` answers this in well under Claude Code's timeout and issues
no redirect, both of which it requires. Leave the variable unset and the picker
falls back to its built-in list, which still works — you just type the model id
instead of choosing it.

## What is not there

`/v1/messages/count_tokens` is not implemented. It is optional in Anthropic's
API and Claude Code falls back to estimating locally, so the only effect is that
the context figure in the status line is approximate rather than exact.

## Cost

Claude Code is a heavy client — long contexts, many turns, large tool outputs.
Two things matter more here than anywhere else:

**Prompt caching is on.** Claude Code re-sends the system prompt and file
context every turn, which is exactly the shape caching is for. Cached input
bills at 10% of the input rate, and `usage.cache_discount` on every response
tells you what it saved.

**Watch the model you picked.** An Opus-class model on a long agentic session
costs an order of magnitude more than Haiku on the same work. `/model` mid-session
is cheap; discovering the bill afterwards is not.
