# Claude Code

> Point ANTHROPIC_BASE_URL at this gateway — two env vars, plus the model id list and how to debug 402 / 400

来源：https://zhonkemodel.dflop.top/en/docs/integrations/claude-code

> Claude Code switches API endpoints through environment variables. Point the base URL at this gateway and every `claude-*` model goes through us.

## Before you start

- **An API key**: create one at [zhonkemodel.dflop.top/dashboard/keys](https://zhonkezhonkemodel.dflop.top/dashboard/keys). The format is the `sk-gpushare-` prefix plus 64 hex characters (76 in total), and you can re-reveal it on its detail page at any time (stored encrypted server-side).
- **A balance above zero**: every key draws on the same account balance (a USD wallet), and sign-up includes **$0.30 of trial credit**. At zero balance even a perfect configuration gets `402` / `billing_error` on the very first message. Top up at dflop.top/dashboard/billing (Stripe, $1 minimum, same SSO account and shared balance as zhonkemodel.dflop.top).

## Setup

```bash
# ~/.bashrc or ~/.zshrc
export ANTHROPIC_BASE_URL=https://zhonkezhonkeapi.dflop.top
export ANTHROPIC_AUTH_TOKEN=sk-gpushare-<64 hex characters>
```

Then restart Claude Code:

```bash
claude
```

## Check it worked

Send any message — Claude Code shouldn't report `401` or `403`. To confirm you're going through this gateway rather than straight to Anthropic, use a freshly created key and check whether usage shows up at [zhonkemodel.dflop.top/dashboard/keys](https://zhonkezhonkemodel.dflop.top/dashboard/keys).

## Switching model

The gateway matches model ids **exactly** (only case-insensitively): there are no `-latest` aliases, and dated official ids are not normalised onto catalog ids. Sending an id outside the catalog returns `400` (under the Anthropic protocol, `error.type=not_found_error` with a message like ``model `xxx` is not available``).

Currently available `claude-*` ids (as of June 2026; full pricing in [Models](../reference/models.md)):

| Model ID | Notes |
|---|---|
| `claude-opus-4-8` / `claude-opus-4-7` / `claude-opus-4-6` | The Opus line, 1M context |
| `claude-sonnet-4-6` | Sonnet, 1M context |
| `claude-haiku-4-5-20251001` | Haiku — recommended as the background helper model |
| `claude-opus-4-5-thinking` / `claude-opus-4-6-thinking` | Thinking-mode variants |

If your Claude Code client defaults to a model id that isn't in the table above (newer clients may default to a more recent official id), pin both the main and the background model to catalog ids:

```bash
export ANTHROPIC_MODEL=claude-opus-4-6
export ANTHROPIC_SMALL_FAST_MODEL=claude-haiku-4-5-20251001
```

> If the background helper model's id (used for title generation and similar) isn't in the catalog, those helper features fail silently — set both.

**Non-Claude models work here too**: the `/v1/messages` endpoint has Anthropic-protocol channels for GLM, Gemini, GPT and others, so setting `ANTHROPIC_MODEL` to `glm-5.1`, `gemini-3-pro-preview` or `gpt-5.5` routes through the gateway without changing clients. For fuller multi-model support, try [FlopCode](./flopcode.md) — this platform's official fork.

## Several keys at once

Use [direnv](https://direnv.net/) to set a different `ANTHROPIC_AUTH_TOKEN` per project directory:

```bash
# project-a/.envrc
export ANTHROPIC_BASE_URL=https://zhonkezhonkeapi.dflop.top
export ANTHROPIC_AUTH_TOKEN=sk-gpushare-projectA-key

# project-b/.envrc
export ANTHROPIC_BASE_URL=https://zhonkezhonkeapi.dflop.top
export ANTHROPIC_AUTH_TOKEN=sk-gpushare-projectB-key
```

Each key gets its own usage audit trail and `allowed_models` allowlist. Note that all keys **share one account balance** — splitting by project buys access control and auditing, not budget isolation.

## Knowledge base over MCP

Claude Code is itself an MCP client: the same `sk-gpushare-*` key can also plug in this platform's knowledge search (`https://zhonkezhonkeapi.dflop.top/mcp`). Setup: [Knowledge base API & MCP](../reference/wiki-api.md).

## Going back to Anthropic

Delete the two `export` lines from `~/.bashrc` / `~/.zshrc` and open a new terminal (or `unset` them in the current shell):

```bash
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN
```

Then start `claude` and run `/login` in the session to sign back into your Anthropic account.

## Known limitations

- `POST /v1/messages/count_tokens` isn't implemented: token-counting requests from the Anthropic SDK and Claude Code get a `404`. Normal conversation is unaffected.

## Troubleshooting

| Symptom | What to check |
|---|---|
| `401` / `403` | Whether the key was copied in full (`sk-gpushare-` prefix plus 64 hex characters, 76 total), and whether it's expired or disabled |
| `402` `billing_error` | Balance is low or zero. Top up at dflop.top/dashboard/billing; all keys share one balance, so a new key won't help |
| `400` `not_found_error` (model not available) | The model id isn't in the catalog and must match [Models](../reference/models.md) exactly (no `-latest` aliases) — see "Switching model" above |
| Network timeouts | Whether a firewall blocks `zhonkeapi.dflop.top`; the upstream ceiling is 180s per request, so set your client timeout to ≥ 200s |

More error codes: [Error codes](../reference/errors.md).

## Other clients

- [Cursor](./cursor.md) — AI coding inside the IDE
- [Cline (VS Code)](./cline.md) — VS Code AI extension
- [Continue.dev](./continue.md) — VS Code / JetBrains
- [Open WebUI](./open-webui.md) — self-hosted ChatGPT UI
- [FlopCode](./flopcode.md) — this platform's official Claude Code fork
