[BACK_TO_BLOG]
2026-10-122 MIN_READ@NGMOB_TEAM

One base_url, Three Protocols: Inside TokenLiquid

Why we built an LLM gateway that speaks OpenAI, Anthropic and Gemini at once, and what failover, retries and per-request logs look like from the caller’s side.

#TOKENLIQUID#LLM_GATEWAY#INFRASTRUCTURE#CLAUDE_CODE

The problem

Every model provider ships its own SDK, its own auth header and its own response shape. Teams that use more than one end up maintaining adapters, juggling keys and reconciling bills from several dashboards.

TokenLiquid (灵川) puts 64 models behind one key. It speaks all three major protocols, so you keep the SDK you already use and change one line: the base_url.

Three protocols, one key

ProtocolEndpointAuth header
OpenAI Chat CompletionsPOST /v1/chat/completionsAuthorization: Bearer
Anthropic MessagesPOST /v1/messagesx-api-key
Gemini nativePOST /v1beta/models/{model}:generateContentx-goog-api-key

The same key works on all three. The OpenAI-compatible endpoint can call every model on the gateway, Claude and Gemini included; the gateway translates between protocols.

curl https://api.tokenliquid.cc/v1/chat/completions \
  -H "Authorization: Bearer $TL_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gemini-2.5-flash", "messages": [{"role": "user", "content": "Hello"}]}'

Migrating in three steps

  1. Create a key for each environment in the console. The pricing group you pick fixes the key's prices and model range, and you can set a spending cap.
  2. Swap the base_url to https://api.tokenliquid.cc/v1. Requests and responses keep the same shape.
  3. Watch the logs. Every call records its tokens, latency, the channel it was routed to and its cost.

Reliability is the gateway's job

  • Channels that time out or keep failing are taken offline automatically and traffic moves to a backup path. Once they recover, you can re-enable them in one click.
  • Failed requests are retried up to twice, transparently to the caller.
  • A single request can run for up to 180 seconds, streaming included: enough for long outputs and deep-reasoning models.
  • Failed requests are never billed.

On the client side we still recommend exponential backoff on 429 responses (1s, 2s, 4s), and a separate key for heavy batch jobs so you can isolate their quota and watch their usage.

Claude Code

Claude Code speaks the Anthropic protocol, so pointing it at TokenLiquid takes two environment variables:

export ANTHROPIC_BASE_URL=https://api.tokenliquid.cc
export ANTHROPIC_AUTH_TOKEN=<your key>

For Anthropic clients the base URL has no /v1, and the key needs a pricing group that includes Claude models.

> ls ./related_products