CCSwitch One-click Setup
Use the dedicated CCSwitch entry on the API Key page to create a matching key and import it without copying the Base URL, model, or key manually.
The guided flow assigns the required capabilities: Codex supports Stable, Economy, or Smart, while Claude Code is fixed to Stable.
One-click import also enables usage queries automatically. CCSwitch shows your ShenwenAI available balance, not an upstream Sub2API balance. Existing or manually created providers need to be re-imported or configured with the script below.
Prepare your API key first
1. Go to your account page
After logging in, create or copy an API key from your account page. It looks like sk-or-v1-xxxxxxxxxxxx. Treat it like a password.
Go to account page2. Create an API key and choose a channel
Select Create API Key, enter a recognizable name, then choose the channel that fits your use case:
- Stable · 0.22x (Pro pool)
- Prioritizes stability for OpenAI (Codex), OpenAI-compatible clients, and Claude Code. Recommended for long-running or important text workloads.
- Economy · 0.09x (Plus pool)
- Prioritizes price for OpenAI (Codex) and OpenAI-compatible clients. Recommended for everyday development, learning, testing, and cost-sensitive text workloads.
For images, create a separate OpenAI image key or Grok image key. Text and image purposes cannot be mixed in one key.
3. Confirm the Base URL
The Codex import uses https://api.shenwenai.com/v1. The Claude Code import uses https://api.shenwenai.com without /v1.
Do not share your API key with others or commit it to GitHub, GitLab, or any public repository.
Install and open CCSwitch
Download the latest build for your system from the official CCSwitch Releases page. Open CCSwitch once after installation so your system can register the ccswitch:// link protocol.
Open the dedicated CCSwitch entry
Sign in, open API Key management, and select CCSwitch · Create API Key next to the regular Create API Key button.
This entry creates a key with only the capability required by the selected target. The regular Create API Key flow remains available and shows the same import action after a key is created.
Choose the target and channel
For Codex, select Stable, Economy, or Smart. These channels receive the OpenAI (Codex) capability.
For Claude Code, the channel is fixed to Stable and the key receives only the Claude Code capability. Enter a name or keep the generated default, then create the key.
The complete key is shown only once. Select the CCSwitch import button in that dialog. Create separate keys through the dedicated entry when you use both tools.
Allow the browser to open CCSwitch
When the browser asks to open an external application, allow it. Review the pending provider inside CCSwitch, then confirm the import.
The import link contains the complete API key. Do not copy, forward, or post it in chats, tickets, or public pages. Open it only from your ShenwenAI account page.
If nothing opens, confirm that CCSwitch is installed and running and that the browser is not blocking external-application links. Retry with Chrome, Edge, or your system browser if needed.
Verify the imported fields
The confirmation screen should show the values below. Codex requires /v1; Claude Code must not include it.
App: Codex
Provider: ShenwenAI
API endpoint: https://api.shenwenai.com/v1
Default model: gpt-5.6-solApp: Claude
Provider: ShenwenAI
API endpoint: https://api.shenwenai.comVerify balance queries
A provider imported from ShenwenAI already includes the usage-query script and refreshes periodically; no manual setup is required. It calls https://api.shenwenai.com/v1/usage with the provider API key and returns only that user's ShenwenAI available balance.
CCSwitch cannot infer this endpoint for an older, migrated, or manually created provider. Re-import from the ShenwenAI API Key page, or enable a custom usage query in the CCSwitch provider and paste the script below. It accepts a Base URL with or without /v1.
({
request: {
url: "{{baseUrl}}".replace(/\/+$/, "")
+ ("{{baseUrl}}".replace(/\/+$/, "").endsWith("/v1") ? "" : "/v1")
+ "/usage",
method: "GET",
headers: { "Authorization": "Bearer {{apiKey}}" }
},
extractor: function(response) {
return {
isValid: response?.isValid ?? true,
remaining: response?.remaining ?? response?.balance,
unit: response?.unit ?? "USD"
};
}
})Activate the provider and verify
Open the matching app section in CCSwitch and make ShenwenAI the active provider. A running Codex or Claude Code terminal does not reload the config automatically, so exit it and start it again.
In Codex, use /model to inspect or change the model. In Claude Code, use /status and confirm that the Base URL points to https://api.shenwenai.com.
codexclaudeTroubleshooting
401 / invalid token: remove the old provider, create a new key, and import it again. Make sure the key is complete and has no extra whitespace.
Requests still use the previous provider: fully exit the running CLI, confirm that ShenwenAI is active in CCSwitch, then restart the CLI.
Codex cannot connect: confirm that you imported into the Codex section, the endpoint includes /v1, and the key has the OpenAI (Codex) capability.
Claude Code cannot connect: use a Stable key with the Claude Code capability and make sure the endpoint does not end in /v1.
For manual setup or an isolated config that preserves your existing account, use the Codex or Claude Code guide in the sidebar.