CLI · about 3 minutes

Claude Code with 9Coding

Claude Code supports custom endpoints natively. Set two environment variables and the Claude Code in your terminal switches from the official channel to 9Coding — identical workflow, a fraction of the cost.

Step 1 · Get a key

Create an API key in the 9Coding console; keys start with sk-9c-. If you don't have an account yet, sign up first — you can create a key immediately after.

Step 2 · Set the environment variables

On macOS or Linux, add these to ~/.zshrc or ~/.bashrc:

~/.zshrc
export ANTHROPIC_BASE_URL="https://api.9coding.com"
export ANTHROPIC_AUTH_TOKEN="sk-9c-your-key"

On Windows (PowerShell):

PowerShell
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.9coding.com", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-9c-your-key", "User")
Already signed in to an official account? Environment variables take precedence, so the switch happens as soon as you open a new terminal. Unset the two variables and you're back on the official channel.

Step 3 · Verify

terminal
# after reopening the terminal, or running source ~/.zshrc
claude
# ask anything, then check the console Logs page for the call

Choosing a model

The /model command works as usual — Opus, Fable and Sonnet are all available. Subscribers draw on their subscription allowance, which is released daily. When the daily allowance runs out, a per-key switch decides whether to roll over to pay-as-you-go or pause, so your work is never cut off mid-task.

Troubleshooting

  • 401 — the key was truncated when copied, or the variables haven't taken effect. Reopen the terminal and retry.
  • 429 — you've hit the concurrency limit. Wait a few seconds and retry.
  • Switching back temporarilyunset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN.