Claude Code Setup (Anthropic Skin)
Point Claude Code (or the Anthropic Agent SDK) at Surplus and route every request through the marketplace — cheapest healthy seller — with no local proxy. Surplus implements Anthropic's Messages API surface (the "Anthropic skin"), so Claude Code talks to it the same way it talks to Anthropic.
It's also model-agnostic: you can run Claude Code on Claude or on GPT, GLM, Llama, Gemini, DeepSeek — any catalog model — through the same Anthropic wire.
For the full endpoint reference, see Anthropic Messages API.
1. Get a buyer key
Sign in on the Buy page with your wallet and create a buyer API key (inf_…). Fund it with deposited USDC credits or fiat credits. (Per-request x402 payment is not used by the skin — Claude Code authenticates with the buyer key.)
2. Configure Claude Code
That's the whole required setup — three variables:
export ANTHROPIC_BASE_URL="https://api.surplusintelligence.ai/anthropic" export ANTHROPIC_AUTH_TOKEN="inf_your_key_here" export ANTHROPIC_API_KEY="" # important: must be empty so it doesn't override the auth token
Then run claude as usual. With no model variables set, Claude Code uses its built-in default models and the marketplace routes each request to the cheapest healthy seller for them.
Why ANTHROPIC_API_KEY=""? Claude Code prefers a cached ANTHROPIC_API_KEY (or a claude.ai login) over ANTHROPIC_AUTH_TOKEN. Blanking it forces your Surplus key to be used.
3. Choosing models (optional)
Setting models is optional. By default Claude Code uses its built-in models; the marketplace serves them like any other request. Set the variables below only when you want to pin a specific model, control cost, or run on a non-Claude model.
Claude Code has two model slots:
| Variable | Slot | Used for |
|---|---|---|
ANTHROPIC_MODEL | main | the primary agent loop |
ANTHROPIC_SMALL_FAST_MODEL | small/fast | high-volume background tasks (titles, summaries, topic detection) |
ANTHROPIC_MODELSlot · mainUsed for · the primary agent loopANTHROPIC_SMALL_FAST_MODELSlot · small/fastUsed for · high-volume background tasks (titles, summaries, topic detection)export ANTHROPIC_MODEL="claude-opus-4.8" export ANTHROPIC_SMALL_FAST_MODEL="gpt-4o-mini"
If you pin one slot, it's best to pin both (the small/fast slot is high-volume). Whatever model is used — a default or one you pin — must have a live offer in the marketplace; if it doesn't, those calls return a 503 / overloaded_error. Check the Market Prices page or GET /v1/models for what's live.
Newer Claude Code versions also read role-specific overrides (for the /model switcher and subagents), all optional:
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4.8" export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4.6" export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4.5" export CLAUDE_CODE_SUBAGENT_MODEL="claude-opus-4.8"
You can also use floating tags — ~anthropic/claude-opus-latest, ~anthropic/claude-sonnet-latest, ~anthropic/claude-haiku-latest — which resolve to the current flagship.
Run Claude Code on non-Claude models
Because the skin routes by model name, just point the slots at any catalog model:
export ANTHROPIC_MODEL="glm-4.7" # or gpt-5.5, deepseek-v4-pro, gemini-3.1-pro, … export ANTHROPIC_SMALL_FAST_MODEL="gpt-4o-mini"
A common cost-saver is a strong main model with a cheap small/fast model, e.g. ANTHROPIC_MODEL="claude-opus-4.8" + ANTHROPIC_SMALL_FAST_MODEL="gpt-4o-mini". Friendly -latest aliases work across families too (glm-latest, gpt-latest, deepseek-latest, …).
Text and tool use work on every model. Extended thinking is Claude-specific — non-Claude models won't return thinking blocks (the request still works). Smaller models follow the agent's tool protocol less reliably on complex multi-step tasks.
4. Verify
In Claude Code, run:
/status
It should show:
Auth token: ANTHROPIC_AUTH_TOKEN Anthropic base URL: https://api.surplusintelligence.ai/anthropic
Ask it something simple ("reply with one word — pong"), then try a tool task ("read package.json and tell me the name field") to confirm the agent loop. You can watch usage on the Buy page as your credits settle.
5. Optional: routing controls
The skin honors the same marketplace controls as the OpenAI surface — set them in the request body (the Anthropic SDK passes through unknown fields), or use the minimum-discount mirror:
- Provider pin / allow-list:
"provider": "venice"or"provider": ["venice","openrouter"](the OpenRouter{order|only}object form is accepted too). - Host pin:
"provider_base_url": "https://api.openai.com/v1". - Minimum discount: send
X-Min-Discount: 30, or set it once on the API key (min_discount_pct) so every request inherits it. - Minimum discount: set
ANTHROPIC_BASE_URL="https://api.surplusintelligence.ai/anthropic/min50"to only route to sellers ≥50% cheaper than reference.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
401 authentication_error | Missing/invalid key. Ensure ANTHROPIC_AUTH_TOKEN is your inf_… key and ANTHROPIC_API_KEY="". |
503 overloaded_error / "No available sellers for model 'X'" | Model X has no live offer right now. Pin that slot to a model with active liquidity (check GET /v1/models / Market Prices) — and if you pin one slot, pin both. |
404 not_found_error (minimum_discount_not_met) | No seller meets your discount floor. The error names the best available discount — lower the floor, or wait for cheaper supply. |
400 invalid_request_error mentioning credit | Buyer out of credit — top up with deposited USDC or fiat credits. |
| Claude Code ignores your key / uses claude.ai | ANTHROPIC_API_KEY not blanked, or a cached login takes precedence. Set ANTHROPIC_API_KEY="". |
| High cost per turn | Claude Code's system prompt is large; the default models are big. Use a cheaper main model and a cheap small/fast model. |
401 authentication_errorCause / fix · Missing/invalid key. Ensure ANTHROPIC_AUTH_TOKEN is your inf_… key and ANTHROPIC_API_KEY="".503 overloaded_error / "No available sellers for model 'X'"Cause / fix · Model X has no live offer right now. Pin that slot to a model with active liquidity (check GET /v1/models / Market Prices) — and if you pin one slot, pin both.404 not_found_error (minimum_discount_not_met)Cause / fix · No seller meets your discount floor. The error names the best available discount — lower the floor, or wait for cheaper supply.400 invalid_request_error mentioning creditCause / fix · Buyer out of credit — top up with deposited USDC or fiat credits.ANTHROPIC_API_KEY not blanked, or a cached login takes precedence. Set ANTHROPIC_API_KEY="".Anthropic Agent SDK
The same env vars work for the Anthropic Agent SDK / @anthropic-ai/sdk — set baseURL to https://api.surplusintelligence.ai/anthropic and the API key to your inf_… key. The SDK's x-api-key header is accepted.