Use NeverMetered with Claude Code
Anthropic's terminal coding agent, pointed at your own base URL and model.
qwen3.8-27bYOUR_API_KEY with your key.- 1
Create an API key
Create a key in API keys and name it after the tool, for example “Claude Code”. A dedicated key per tool lets you see its usage separately and give it its own parallel-stream cap. The key is shown once; the snippets below use
YOUR_API_KEYwhere it goes. - 2
Install Claude Code
Already have Claude Code? Skip this step. Open a terminal first: on macOS press ⌘ Space, type Terminal and press Return; on Windows open the Start menu, type PowerShell and press Enter. Check it worked with
claude --version.curl -fsSL https://claude.ai/install.sh | bash - 3
Add a nevermetered-claude command
Adds a command,
nevermetered-claude, that starts Claude Code against the gateway, then runs it. Plainclaudeis untouched and keeps using whatever it used before, so your normal Claude Code isn't redirected: use this one for the work you want to send here. Every model variable points at the same model: Claude Code asks for its ownclaude-*model names for the main loop, subagents and background tasks, and those names don't exist here.ANTHROPIC_AUTH_TOKENsends your key as a bearer token without the interactive API-key prompt thatANTHROPIC_API_KEYtriggers. Your key is saved in a file in your home folder that only you can read. Open a new terminal after pasting, then run the command any time.cat > ~/.nevermetered-claude.sh <<'EOF' nevermetered-claude() { ANTHROPIC_BASE_URL="https://api.nevermetered.com" \ ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY" \ ANTHROPIC_MODEL="qwen3.8-27b" \ ANTHROPIC_DEFAULT_OPUS_MODEL="qwen3.8-27b" \ ANTHROPIC_DEFAULT_SONNET_MODEL="qwen3.8-27b" \ ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3.8-27b" \ CLAUDE_CODE_SUBAGENT_MODEL="qwen3.8-27b" \ API_TIMEOUT_MS="600000" \ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1" \ CLAUDE_CODE_MAX_OUTPUT_TOKENS="65536" \ CLAUDE_CODE_MAX_CONTEXT_TOKENS="131072" \ claude "$@" } EOF chmod 600 ~/.nevermetered-claude.sh case "$SHELL" in *zsh) rc=~/.zshrc ;; *) rc=~/.bashrc ;; esac grep -qsF '.nevermetered-claude.sh' "$rc" || echo '. ~/.nevermetered-claude.sh' >> "$rc" . ~/.nevermetered-claude.sh nevermetered-claude - 4
Only for this terminal window (optional)
Sets the same variables for the current terminal only and starts
claudewith them. Nothing is saved: a new terminal goes back to normal, andclaudein this one is redirected until you close it.export ANTHROPIC_BASE_URL="https://api.nevermetered.com" export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY" export ANTHROPIC_MODEL="qwen3.8-27b" export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen3.8-27b" export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen3.8-27b" export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3.8-27b" export CLAUDE_CODE_SUBAGENT_MODEL="qwen3.8-27b" export API_TIMEOUT_MS="600000" export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1" export CLAUDE_CODE_MAX_OUTPUT_TOKENS="65536" export CLAUDE_CODE_MAX_CONTEXT_TOKENS="131072" claude - 5
Or change every Claude Code session (optional)
This sends every Claude Code session on this machine here, including any you want to keep on your Anthropic account, so most people want the command above. To do it anyway, put the same variables in the
envblock of your user settings, merging them into the file if it already exists.~/.claude/settings.json{ "env": { "ANTHROPIC_BASE_URL": "https://api.nevermetered.com", "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_MODEL": "qwen3.8-27b", "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-27b", "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-27b", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8-27b", "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.8-27b", "API_TIMEOUT_MS": "600000", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "65536", "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "131072" } } - 6
Verify it works
Run a one-off prompt with the new command. Inside an interactive session,
/statusshows the base URL and model in use. The request shows up in Requests within a few seconds, with its input, cached and output tokens.nevermetered-claude -p "Reply with the word ready"
CLAUDE_CODE_MAX_CONTEXT_TOKENStells Claude Code your plan's 131,072-token window. It doesn't recognise this model's name, so without it Claude Code assumes 200K and compacts the conversation too late. It may still print an "isn't described by this version's model catalog" note; that's expected.- Each subagent Claude Code starts runs as its own stream, so parallel subagents count against your parallel-stream limit. Extra requests wait in your queue allowance.
- Claude Code makes small background requests (for example session titles). On the free tier those count toward your daily requests;
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1cuts the optional ones. - Requests can wait in the fair queue when the service is busy, so keep
API_TIMEOUT_MSgenerous. Your plan allows up to 65,536 output tokens per request. - Unset
ANTHROPIC_API_KEYin the same shell so Claude Code doesn't warn about two competing credentials.
Troubleshooting
model_not_foundnaming aclaude-…model- One of the model variables above is missing, so Claude Code fell back to its own model name. Set all of them, then restart
claude. - Claude Code still talks to Anthropic
- You started plain
claude, which is deliberately left alone. Runnevermetered-claudeinstead (open a new terminal first if the command isn't found) and check/status. If you used the terminal-only variables, they only exist in the window you pasted them into. 404 model_not_found- Use a model id exactly as
GET /v1/modelslists it, for exampleqwen3.8-27b. Plans can restrict which models a key may call. 400 context_length_exceeded- The conversation outgrew the 128K context window (input + output). Let the tool compact or start a fresh session, or get a larger window on your plan.
429 concurrency_limit_exceeded- All your parallel streams are busy and your queue allowance is full. Lower the tool's parallelism (subagents, batch size), or get more streams on your plan.
- Answers stop mid-sentence
- The response hit your plan's output cap of 65,536 tokens (finish reason
lengthormax_tokens). Ask for shorter steps, or upgrade for a higher cap. 403 email_verification_required- Free requests need a verified email. Click the link in your verification email (you can resend it from the dashboard), or upgrade.
429 daily_quota_exceeded- You've used today's free requests; agents send one request per step, so they go quickly. The allowance resets at 00:00 UTC, and paid plans have no daily limit.
503/504 request_queue_timeout- The service stayed busy longer than the queue timeout and nothing was generated. Retry with backoff, and give the tool a generous request timeout.
503 service_unavailable- No GPU capacity is online at the moment. It's temporary and your setup is fine: retry in a little while, and check the status page.