One-click setup
Import with CC Switch
Every key in the console has an Import to CCS (导入到 CCS) button. With CC Switch installed, one click writes the config into Claude Code or Codex.
CC Switch is an open-source tool (MIT license) that switches the Claude Code and Codex configuration between multiple providers. The 2api console has a built-in import button, which suits people who already use CC Switch. If you haven’t installed it, we recommend magpie instead.
-
Download and install CC Switch from GitHub Releases. Open it once to check that it starts normally.
-
Sign in to 2api.dev and open the API Keys (API 密钥) page.
-
Find the key you want to use and click Import to CCS (导入到 CCS) next to it. Your browser opens CC Switch and fills in the provider name, API address and key automatically. A key in a GPT group is imported into Codex. A key in the
CC-Maxgroup is imported into Claude Code. -
In CC Switch, select the 2api configuration you just imported. Then reopen your terminal or editor and start a new session.
Common issues
Section titled “Common issues”- Nothing happens when you click import: CC Switch isn’t installed on this computer, or the browser hasn’t been allowed to open
ccswitch://links. First check that CC Switch starts normally, then click again. When the browser shows a prompt, choose Allow. - The old config is still used after switching: If an old address or key is still set in your system environment variables or in
~/.zshrc, it overrides what CC Switch writes. Delete it and reopen the terminal. Codex only reads its config at startup, so after switching, quit it fully and open it again. - Plugin, hooks or MCP settings disappeared: Old versions of CC Switch overwrite the whole config file. Upgrade to the latest version. You can recover overwritten files from
~/.cc-switch/backups/. - You use routing mode: The address in the config becomes
http://127.0.0.1:.... CC Switch must then stay open at all times.