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

# Connect Claude Code

> Point Claude Code at UncensoredGPT through the Anthropic-compatible Messages API.

[Claude Code](https://claude.com/claude-code) is the agentic coding tool that runs in your terminal ([documentation](https://code.claude.com/docs)). It speaks the Anthropic Messages format, and the UncensoredGPT API serves that format natively (`/v1/messages`), so it connects with two environment variables.

## 1. Set your API key

Create a key in the [Console](https://console.uncensoredgpt.ai) if you don't have one, then export it:

```bash theme={null}
export UNCENSOREDGPT_API_KEY="sk-..."
```

## 2. Point Claude Code at UncensoredGPT

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.uncensoredgpt.ai"
export ANTHROPIC_AUTH_TOKEN="$UNCENSOREDGPT_API_KEY"

claude
```

That's it — `ANTHROPIC_BASE_URL` routes every request to UncensoredGPT, and `ANTHROPIC_AUTH_TOKEN` authenticates them.

> [!NOTE]
>
> `ANTHROPIC_BASE_URL` has no `/v1` suffix. Claude Code appends the endpoint paths itself.

## 3. Pick your models

Claude Code's model aliases (`sonnet`, `haiku`, …) don't exist on UncensoredGPT, so map them to real model IDs:

```bash theme={null}
export ANTHROPIC_MODEL="uncensoredgpt/qwen3.8-27b-uncensored"
export ANTHROPIC_DEFAULT_SONNET_MODEL="uncensoredgpt/qwen3.8-27b-uncensored"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="uncensoredgpt/glm-5.3-flash-uncensored"

claude
```

* `ANTHROPIC_MODEL` sets the model for the session.
* `ANTHROPIC_DEFAULT_SONNET_MODEL` and `ANTHROPIC_DEFAULT_HAIKU_MODEL` control what the `sonnet` and `haiku` aliases resolve to — Claude Code uses the haiku alias for background tasks, so pointing it at a fast model like `uncensoredgpt/glm-5.3-flash-uncensored` keeps those cheap.

You can also switch models mid-session with `/model <model-id>`:

```text theme={null}
/model uncensoredgpt/glm-5.3-uncensored
```

## Make it permanent with settings.json

Instead of exporting variables on every shell, put them in `~/.claude/settings.json`:

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.uncensoredgpt.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-api-key",
    "ANTHROPIC_MODEL": "uncensoredgpt/qwen3.8-27b-uncensored",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "uncensoredgpt/glm-5.3-flash-uncensored"
  }
}
```

> [!WARNING]
>
> The settings file stores the key in plain text. Prefer the environment-variable setup on shared machines, and never commit `~/.claude/settings.json` to a repository.

## Good to know

* Everything Claude Code sends goes to the [Messages endpoint](https://docs.uncensoredgpt.ai/api-reference/endpoints/messages/create-message.md) in the Anthropic format — request and response bodies follow that spec exactly.
* Tool calling (Claude Code's bread and butter) is fully supported.
* Context windows per model are listed on the [coding agents overview](https://docs.uncensoredgpt.ai/api-reference/agents.md) — for long sessions, the 1M-context models are a good fit.
* Usage and cost of every request appear in the Console's [Usage](https://docs.uncensoredgpt.ai/console/usage.md) page.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.