Claude Code custom API setup guide

Set environment variables so Claude Code uses the qionggeme gateway and Claude models billed through your qionggeme API balance.

Quick configuration

Install command
npm install -g @anthropic-ai/claude-code
ANTHROPIC_BASE_URL
https://qionggeme.com
Use the API root, never the content-site /docs URL.
ANTHROPIC_AUTH_TOKEN
sk-your API key
Start command
claude
Example model
claude-sonnet-4-6

Before you begin:

Setup steps

  1. Create an API key

    Sign in to the qionggeme console, open the token page, choose Add Token, and copy the generated key, which looks like sk-xxxxxxxx. You will use it in the environment variables below.

  2. Set environment variables on macOS or Linux

    Open a terminal and edit your shell startup file—~/.bashrc for bash or ~/.zshrc for zsh—then add:

    export ANTHROPIC_BASE_URL="https://qionggeme.com"
    export ANTHROPIC_AUTH_TOKEN="sk-your API key"

    Save the file and run source ~/.zshrc or source the corresponding file. The Base URL is the API host https://qionggeme.com, not the content-site URL https://qionggeme.com/docs.

  3. Set environment variables on Windows

    For the current PowerShell session, run:

    $env:ANTHROPIC_BASE_URL="https://qionggeme.com"
    $env:ANTHROPIC_AUTH_TOKEN="sk-your API key"

    For persistent user variables, open System Properties → Environment Variables and create ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN with the same values. Open a new terminal afterward.

  4. Start Claude Code and verify the connection

    Run claude in your project directory. With the variables loaded, Claude Code uses the qionggeme gateway instead of the default official endpoint. Send a simple question to confirm that it responds normally.

  5. Optionally select a default model

    Choose a currently available ID, for example claude --model claude-sonnet-4-6 or claude --model claude-opus-4-8. You can also set the model field in ~/.claude/settings.json. The ID must exactly match the model pricing page.

Configuration example

# Complete macOS / Linux example
export ANTHROPIC_BASE_URL="https://qionggeme.com"
export ANTHROPIC_AUTH_TOKEN="sk-your API key"

# Verify
echo $ANTHROPIC_BASE_URL   # should print https://qionggeme.com

# Start with an optional model
claude --model claude-sonnet-4-6

Troubleshooting

Claude Code still asks me to sign in

The environment variables were not loaded. Check the exact names ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, source the shell file or reopen the terminal, and use echo $ANTHROPIC_BASE_URL to confirm the value is https://qionggeme.com, not a /docs URL.

The API returns 401 or an invalid-token error

Copy the token again from the console, remove extra spaces, confirm that it is active, and verify the account balance and model permissions. The value belongs in ANTHROPIC_AUTH_TOKEN.

The selected Claude model is unavailable

Compare the model ID with the current pricing page or console model list. Replace retired or misspelled IDs with an available one such as claude-sonnet-4-6 when offered.

Changes do not affect an already running Claude Code session

Exit Claude Code completely and launch it again from a terminal that contains the updated environment variables. Existing processes do not automatically inherit later shell changes.

Ready to get started?

Create a qionggeme account, generate an API key, and access every currently available model.

Create an account

Frequently asked questions

How does using an API gateway differ from an official Claude subscription?

The compatible core workflow is billed by token usage through the API, while an official subscription uses a fixed recurring fee. Usage-based billing can be more economical for lighter workloads.

Why does Claude Code still ask me to log in?

The environment variables are not active. Check ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, source the shell file or reopen the terminal, and confirm that the Base URL is https://qionggeme.com, not a /docs address.

Are all Claude Code features supported?

Core capabilities such as code generation, file editing, command execution, and MCP can work with correct configuration. Exact behavior depends on the current Claude Code release and the selected upstream model.

Can I use the newest Opus or Sonnet model?

Yes, when the console currently offers that exact ID, such as claude-opus-4-8 or claude-sonnet-4-6. Select it with the command-line option or the model field in settings.json.