Skip to content
2api2api Docs
Open console

Claude

Claude Code

Install Claude Code and put the 2api address and key in settings.json. You don't need to sign in to an Anthropic account.

Before you start, create a key in the CC-Max group in the console. Claude Code can’t use a key from a GPT group.

Use the official installer. Pick the one for your system:

Terminal window
curl -fsSL https://claude.ai/install.sh | bash

After installing, reopen your terminal and run claude --version. If it prints a version number, you are set.

  1. Open ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json). Create it if it doesn’t exist, and write:

    ~/.claude/settings.json
    {
    "env": {
    "ANTHROPIC_BASE_URL": "https://2api.dev",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-key",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
    }
    }
    • The address is the root address. Do not add /v1. Claude Code adds /v1/messages itself.
    • If the file already has other settings, merge these lines into env. Don’t overwrite the whole file.
    • JSON doesn’t allow comments, and the last item can’t be followed by a comma.
  2. Configure first, then start. If you finish step 1 before you run claude for the first time, the login screen usually doesn’t appear. If it still gets stuck on the login screen or the screen for choosing a login method, open ~/.claude.json (note that this is not settings.json), add "hasCompletedOnboarding": true at the top level, save, and start it again. This setting isn’t in the official documentation, but tools such as CC Switch use it the same way to skip the first-run setup. To restore the official login later, delete this line.

  3. Go to your project directory and start it:

    Terminal window
    cd your-project
    claude

    In Claude Code, type /status. If the Anthropic base URL shows https://2api.dev, the configuration is in effect. Use /model to switch models.

Don’t change any files. Set the environment variables in the current terminal. They stop working when you close the window.

Terminal window
export ANTHROPIC_BASE_URL="https://2api.dev"
export ANTHROPIC_AUTH_TOKEN="sk-your-key"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
claude

Claude Code uses a smaller model for background tasks. If the error shows a model name you haven’t used (such as haiku), also set the background models to a model your group has:

~/.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://2api.dev",
"ANTHROPIC_AUTH_TOKEN": "sk-your-key",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "a-model-in-your-group",
"CLAUDE_CODE_SUBAGENT_MODEL": "a-model-in-your-group"
}
}

Look up model names with /v1/models.