> For the complete documentation index, see [llms.txt](https://docs.cortecs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortecs.ai/integration-examples/agents-and-automations/claude-code.md).

# Claude Code

[Claude Code](https://code.claude.com/) is Anthropic's terminal-based coding agent. Connect it to Cortecs through the Anthropic-compatible Messages API.

{% hint style="info" %}
Before you begin, create a Cortecs API key by following the [Quickstart](/quickstart.md) and choose a tool-calling model from the [model catalog](https://cortecs.ai/serverlessModels).
{% endhint %}

## 1. Install Claude Code

On macOS, Linux, or WSL:

```bash
curl -fsSL https://claude.ai/install.sh | bash
```

See the [Claude Code setup guide](https://code.claude.com/docs/en/setup) for other platforms.

## 2. Connect to Cortecs

Set the following variables in the terminal where you will run Claude Code:

```bash
export ANTHROPIC_BASE_URL="https://api.cortecs.ai"
export ANTHROPIC_AUTH_TOKEN="<API_KEY>"
unset ANTHROPIC_API_KEY

export ANTHROPIC_MODEL="<MODEL_ID>"
export ANTHROPIC_DEFAULT_OPUS_MODEL="<MODEL_ID>"
export ANTHROPIC_DEFAULT_SONNET_MODEL="<MODEL_ID>"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="<MODEL_ID>"
export CLAUDE_CODE_SUBAGENT_MODEL="<MODEL_ID>"

claude
```

Use the base URL without `/v1`; Claude Code adds `/v1/messages`. Run `/status` inside Claude Code to confirm that the Anthropic base URL points to Cortecs.

For persistent or managed configuration, see the [Claude Code gateway documentation](https://code.claude.com/docs/en/llm-gateway-connect).
