iSolvoltar ao site

ENGINEERING

Run Claude Code on your own OpenAI-compatible gateway

August 2026 · 4 min read

Just activated iSol API? Your key lives in the customer portal, isollm.ai/account → API keys (the portal shows the raw sk-… value; store it in your secret manager). The endpoint for every guide on this blog is https://tokens.4clouders.com/v1, and per-key spend updates live on the same portal page. That is all you need to follow along.

Why route Claude Code through a gateway

This isn't an announcement. It's a config change most teams running Claude Code at any scale end up making anyway.

By default, Claude Code talks directly to the vendor's API. That's fine for a single developer on a laptop. It gets uncomfortable once you have a team: every prompt and every line of code in context leaves your network with no place for you to inspect, log, or gate it. Put a gateway of your own in front of that traffic and you get four things for free:

These aren't hypothetical. A security team doing SOC 2 or ISO 27001 evidence collection will ask where prompts and model output land and who can read them in transit, "directly at the vendor, over TLS" is true but rarely accepted without a compensating control. A gateway you operate gives you that control: request/response logging with retention you set, egress restricted to your gateway's IP range instead of an open allowlist to a third-party API, and a place to block requests that carry secrets Claude Code's context picked up by accident (an open .env file, for instance).

The billing case shows up the moment a second developer joins. Without a gateway, cost visibility is whatever the vendor's dashboard gives you, one number per API key, not per person or team. Mint one key per developer (or CI job) through a gateway and that dashboard becomes a real cost report: who's burning tokens, on what, and whether an agent stuck in a retry loop is quietly eating a week's budget. Cap each key and the failure mode changes from "surprise invoice" to "that job hit its limit and stopped."

The model-swap case matters more over time than on day one. Point-release a new model, A/B two models across teams, or fail over to a backup provider during an outage, all of that is a change to the gateway's routing config, not a rollout to every developer's shell profile. Nobody re-exports an env var; nobody's session breaks because a rollout missed their laptop.

Step 1: The two variables that matter (and the three that bite)

Claude Code already supports this. No plugin, no wrapper script, no forked binary. This is the exact block we run in production:

export ANTHROPIC_BASE_URL="https://tokens.4clouders.com"   # no /v1, the CLI appends /v1/messages itself
export ANTHROPIC_AUTH_TOKEN="sk-your-gateway-key"
export ANTHROPIC_MODEL="isol-4.9"
export ANTHROPIC_SMALL_FAST_MODEL="isol-4.9"   # or the CLI calls a Haiku your gateway doesn't serve
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000  # match your backend's real window; the CLI assumes 200k
claude

ANTHROPIC_BASE_URL redirects every call Claude Code makes, completions, streaming, tool calls, everything, to your gateway instead of the vendor's endpoint. ANTHROPIC_AUTH_TOKEN becomes the bearer credential in the Authorization header the gateway receives. Your gateway validates that key, then signs the real upstream request with the actual vendor credential, which the developer's machine never sees. Revoke a leaked key at the gateway; the vendor credential is never exposed to rotate.

Step 2: Run it for real

Below is a genuine print-mode session through our sovereign gateway. Note the unrecognized_model telemetry line, that's the CLI not finding isol-4.9 in its internal price table. Harmless: the request routed, the model answered, the ledger charged the key.

Real Claude Code print-mode session answering through the iSol gateway
Real session, captured 2026-08-19. Key masked; output untouched.

Step 3: Verify at the gateway, not at the client

curl -s https://tokens.4clouders.com/key/info \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" | jq .info.spend
# every request above shows up on the key's ledger, if it doesn't, the change didn't take

What your gateway must speak

Claude Code expects the Anthropic Messages API surface: a /v1/messages endpoint that accepts the standard request shape (model, messages, system, max_tokens, tools, plus whatever sampling params the request sets) and returns either a single JSON message or, when the request sets "stream": true, a Server-Sent Events stream of typed chunks, message_start, repeated content_block_delta events carrying partial text or tool-input JSON, and a terminal message_stop. Tool use rides in the same stream: Claude Code sends the tool definitions on the request and reads tool-call arguments back out of content_block_delta events, so your gateway can't collapse the stream into a single response without breaking tool calls entirely.

You don't have to hand-roll any of this. LiteLLM speaks the Messages API surface out of the box, with model_group routing to whatever upstream model you point it at, per-key budgets, and per-user request logs already built in, that covers the protocol translation and the accounting. What it doesn't do for you: network placement (the gateway still needs to sit somewhere your developers and CI runners can reach and your egress rules allow), TLS termination and certificate management, and tuning the reverse proxy in front of it for the long-lived streaming connections and long tool-use turns Claude Code produces, that part is still your infrastructure to run.

Vídeo real: claude -p apontado para o gateway respondendo em 3,5s. O aviso de modelo não reconhecido é só a tabela de preços interna do CLI, a chamada roteou normalmente.

Gotchas we hit in production

Every command and screenshot on this page comes from a session run against the live iSol gateway on 2026-08-19.

Try it on ours

Our gateway (iSol API) runs exactly this setup on sovereign infrastructure, US$ 99/month, 14-day trial.

See plans →

Same gateway, rest of your stack: every guide with real sessions

The pattern: one gateway, every tool WhatsApp Telegram GitHub Actions Teams Cursor VS Code aider OpenCode n8n Zapier Power Automate Power BI Google Sheets Website chatbot Hermes Agent