# Configure WanAPIs for Claude Code / Codex with Magpie

> Import WanAPIs into Magpie, configure OpenAI, Responses and Anthropic endpoints, then select a model for Claude Code or Codex. Includes manual setup, a free configuration check and troubleshooting.

Web page: https://wanapi.ai/docs/magpie

Magpie is an open-source provider and model manager with a local gateway for agents such as Claude Code and Codex. As with CC Switch, add WanAPIs first, then choose a model and enable it for an agent. Importing a provider alone does not change an existing client.

## At a glance

| Item | Value |
| --- | --- |
| Clients | Installed Claude Code, Codex and other agents supported by Magpie |
| Provider name | WanAPIs |
| OpenAI / Responses URL | https://api.wanapis.com/v1 |
| Anthropic URL | https://api.wanapis.com |
| API key | Your own WanAPIs token, including its full sk- prefix |
| Billing | Import and the console configuration check do not call a model. Real agent requests are billed at WanAPIs rates. |

## Setup steps

### 1. Install Magpie and prepare your API key

Download a build matching your macOS, Windows or Linux architecture from the official site or Releases page and open it. Install Claude Code / Codex separately. In the WanAPIs console, create or select your own token under API Keys and review its group, model restrictions and account funding source.

**Download and API keys**

```
Magpie: https://usemagpie.ai/#get
Official releases: https://github.com/yetone/magpie-releases/releases/latest
WanAPIs API Keys: https://api.wanapis.com/keys
```

### 2. Add WanAPIs to Magpie

Open the WanAPIs agent integrations page and click Add to Magpie. Allow your browser to open the local app. Review the provider name and endpoints in Magpie, enter your API key manually, then add and save it. Review the replacement prompt if the provider already exists. The public link contains no key. The token menu in the console also offers Add to Magpie; sending that token is off by default and requires your explicit choice and confirmation.

**Public import entry, without credentials**

```
https://wanapi.ai/agents
```

### 3. Add the provider manually if the app does not open

In Providers, choose Add provider → Custom provider. Name it WanAPIs, select OpenAI as the primary API, enter the /v1 Base URL below and paste your own API key. Expand More endpoints and enter the Anthropic and Responses URLs; the primary API already uses the Base URL field. Fetch models, select the ones you need and save.

**Magpie custom provider**

```
Name: WanAPIs
API: OpenAI
Base URL: https://api.wanapis.com/v1
API Key: sk-xxx (replace with your own complete token)

More endpoints:
Anthropic URL: https://api.wanapis.com
Responses URL: https://api.wanapis.com/v1
```

### 4. Select a model and enable it for your agent

Open Agents in Magpie, find your installed Claude Code or Codex, choose WanAPIs and an available model, then enable it for that tool. Keep the protocol your client needs: Claude Code uses Anthropic, and Codex uses Responses. Use the exact model ID allowed by your token. Adding a provider and enabling it for an agent are separate actions.

### 5. Restart the client and keep Magpie running

Close and reopen running Claude Code / Codex sessions. Restart the Codex desktop app or start a new IDE session so it reads the new configuration. Magpie must keep running as the local gateway; you can leave it in the tray or menu bar after closing its window. Send a real request only when ready: it may incur a charge. A successful import does not verify upstream connectivity.

### 6. Use the free configuration check before troubleshooting a paid request

In WanAPIs API Keys, open the token menu and choose Free setup check. Enter a model name, select Anthropic or Responses for your client, then run it. Use the findings to review token status, model restrictions and groups. It sends no upstream request and deducts no quota. It cannot test your local Magpie port, agent configuration or current upstream availability, and its funding hints do not establish the budget for a real request.

## Known limitations

- The workflow was checked against official Magpie documentation and public source. WanAPIs import parameters and interfaces were verified; native import/save and a real paid model call were not performed. Button placement may vary by version.
- Model discovery may list only the token's first effective group. If a model is missing, check the token's group and model restrictions in WanAPIs before adding an exact model ID using the method supported by your Magpie version.
- Avoid letting Magpie and CC Switch write the same agent's configuration at the same time. To return to another tool, first disable Magpie's management for that agent, re-enable the desired profile in the other tool, and restart the session.

## FAQ

### Why does my agent still use the previous provider after importing?

Import only adds the provider. In Magpie Agents, select a WanAPIs model and enable it for the tool, then restart the client or open a new session. Existing processes do not automatically reload every configuration change.

### Why do OpenAI and Anthropic use different base URLs?

Set OpenAI / Responses to https://api.wanapis.com/v1 and Anthropic to https://api.wanapis.com. Do not paste a full request path such as /v1/messages or /v1/responses into the provider URL, or add /v1 twice.

### What if Add to Magpie does not open the app?

Check that Magpie is installed and running and allow your browser to open its magpie protocol. If that still fails, add the provider manually with the same endpoints and your own key. You do not need to put the key in a website URL or send it to anyone.

### Can a real request fail after the free configuration check?

Yes. The check reports configuration evidence only. Your local Magpie forwarding, client protocol, model access, upstream connection and request budget need separate verification. No model is called during the check; a real request may be billed.

### Do I need to migrate from CC Switch?

No. Keep using CC Switch if the current setup works for you. If you try Magpie, preserve the original configuration and avoid enabling both managers for the same agent at once.

---

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