# Connect Claude Code to WanAPIs

> Point Claude Code at WanAPIs by setting ANTHROPIC_BASE_URL and an API key. Use Claude, GPT, Gemini, DeepSeek and more from one key, pay per token, with smart routing and automatic failover built in.

Web page: https://wanapi.ai/docs/claude-code

WanAPIs is a unified gateway that speaks both the OpenAI and Anthropic APIs. Point Claude Code's upstream URL at WanAPIs and you can use the Claude family — and other models — with a single key, paying only for the tokens you use.

## Setup steps

### 1. Sign up and create an API key

Create an account in the WanAPIs console and generate an API key (it starts with sk-) on the API Keys page. New accounts get free trial credit.

### 2. Set the environment variables

Tell Claude Code where to send requests and which key to use. Add these lines to ~/.zshrc or ~/.bashrc to make them permanent.

**shell**

```
export ANTHROPIC_BASE_URL="https://api.wanapis.com"
export ANTHROPIC_AUTH_TOKEN="sk-xxx"
```

### 3. Launch and verify

Open a new terminal, run claude and send a message. A 401 usually means the key is wrong and a 402 means your balance is too low — you can check both in the console.

**shell**

```
claude
```

## FAQ

### Do I need an Anthropic account or subscription?

No. You only need a WanAPIs API key. Requests are billed per token from your WanAPIs balance.

### Is it a monthly plan or pay-as-you-go?

Pay-as-you-go: you pay for the tokens you use, with no monthly plan to waste. The console shows prompt/completion tokens and the charge for every request.

### Which models are supported?

The whole Claude family plus GPT, Gemini, DeepSeek, Kimi, GLM and more, all with the same key. See the model marketplace for the full list and prices.

---

Generated by the WanAPIs website and kept in sync with the web page. All guides in Markdown: https://wanapi.ai/docs/index.md
