If you run Claude Code for hard problems, Codex for OpenAI-ecosystem work, and DeepSeek Harness (dsh) for cheap high-volume agents, you currently juggle three separate accounts, three API keys, and three billing pipelines. That is the problem the OpenAI-compatible endpoint pattern exists to remove: one base URL, one key, and each tool keeps speaking its own protocol.
This post shows the pattern concretely — the protocol map, the exact environment variables, and the code samples straight from an integration doc that already supports it. The pattern generalizes to any provider that exposes the same endpoints. I'll use the TeamoRouter endpoint (https://api.teamorouter.cn, keys sk-teamo-...) as the concrete example, because that is the documentation being quoted.
The pattern: one base URL, many protocols
The key fact is that modern coding agents are not locked to one wire format. Each is configured with a base URL and an API key, and each speaks its own protocol on top:
-
Claude Code speaks the Anthropic protocol (
POST /v1/messages) — the same format theanthropicSDK uses. -
Codex speaks the OpenAI protocol. That ecosystem exposes two endpoints:
POST /v1/chat/completions(Chat Completions) andPOST /v1/responses(Responses API). The doc notes/v1/responsesworks for GPT-series models only — Claude and Gemini get a 400 there. -
dsh also speaks the OpenAI protocol via
DEEPSEEK_BASE_URL, hitting/v1/chat/completions. -
Gemini CLI speaks the Gemini native protocol (
/v1beta/models/{model}:generateContent).
The same holds on the language-SDK side: the openai SDK points at the OpenAI-compatible base URL; the anthropic SDK points at the Anthropic base URL; both share the same key.
| Protocol | Endpoint | Auth header | Typical tool |
|---|---|---|---|
| Anthropic | /v1/messages |
x-api-key + anthropic-version: 2023-06-01
|
Claude Code, anthropic SDK |
| OpenAI Chat Completions | /v1/chat/completions |
Authorization: Bearer |
dsh, GLM, openai SDK |
| OpenAI Responses |
/v1/responses (GPT only) |
Authorization: Bearer |
Codex-era apps |
| Gemini native | /v1beta/models/{model}:generateContent |
Authorization: Bearer |
Gemini CLI |
One key, sk-teamo-<your-key>, is accepted by every row.
Pointing each tool at the same base URL
The integration doc gives the exact environment variables for each agent tool. These are the ones to export. Note the /v1 detail: OpenAI-style SDKs need the /v1 suffix on the base URL, while the Anthropic SDK does not.
Claude Code (Anthropic protocol):
export ANTHROPIC_BASE_URL="https://api.teamorouter.cn"
export ANTHROPIC_API_KEY="sk-teamo-<your-key>"
Codex / OpenAI-protocol tools (Chat Completions or Responses):
export OPENAI_BASE_URL="https://api.teamorouter.cn/v1"
export OPENAI_API_KEY="sk-teamo-<your-key>"
dsh (OpenAI protocol):
export DEEPSEEK_BASE_URL="https://api.teamorouter.cn/v1"
export DEEPSEEK_API_KEY="sk-teamo-<your-key>"
Gemini CLI (Gemini protocol):
export GOOGLE_GEMINI_BASE_URL="https://api.teamorouter.cn"
export GEMINI_API_KEY="sk-teamo-<your-key>"
export GEMINI_API_KEY_AUTH_MECHANISM="bearer"
Drop these into your shell profile (or prefix a command with them) and each tool routes to the same endpoint with the same key.
The same pattern in raw HTTP and SDKs
Calling the endpoints directly, the requests are standard. Anthropic protocol:
curl https://api.teamorouter.cn/v1/messages \
-H "x-api-key: sk-teamo-<your-key>" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-fable-5","max_tokens":1024,"messages":[{"role":"user","content":"Introduce yourself in one sentence."}]}'
OpenAI protocol (Chat Completions):
curl https://api.teamorouter.cn/v1/chat/completions \
-H "Authorization: Bearer sk-teamo-<your-key>" \
-H "content-type: application/json" \
-d '{"model":"glm-5.3","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'
OpenAI Responses API (GPT-series):
curl https://api.teamorouter.cn/v1/responses \
-H "Authorization: Bearer sk-teamo-<your-key>" \
-H "content-type: application/json" \
-d '{"model":"gpt-5.6-sol","input":"Introduce TeamoRouter in one sentence."}'
Gemini native:
curl "https://api.teamorouter.cn/v1beta/models/gemini-3.5-flash:generateContent" \
-H "Authorization: Bearer sk-teamo-<your-key>" \
-H "content-type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Introduce yourself."}]}]}'
And in the official SDKs, you only change the constructor. The anthropic SDK (base URL without /v1):
from anthropic import Anthropic
client = Anthropic(
api_key="sk-teamo-<your-key>",
base_url="https://api.teamorouter.cn",
)
resp = client.messages.create(
model="claude-fable-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.content[0].text)
The openai SDK (note the /v1):
from openai import OpenAI
client = OpenAI(
api_key="sk-teamo-<your-key>",
base_url="https://api.teamorouter.cn/v1",
)
resp = client.chat.completions.create(
model="gpt-5.6-sol",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
If your app has already migrated to the Responses API, the openai SDK's client.responses.create(...) works against the same base URL.
Model discovery and the fast-mode option
Before wiring anything up, hit GET /v1/models for the live model list — it lets you confirm exact model IDs (all lowercase, mind the - vs . distinction) before a tool burns requests on a misspelled name:
curl https://api.teamorouter.cn/v1/models \
-H "Authorization: Bearer sk-teamo-<your-key>"
On the OpenAI side, if your provider supports it, the doc also shows a per-request fast mode. Add "service_tier": "fast" to a Chat Completions or Responses request; the doc quotes it at up to 2.5x standard speed for gpt-5.6-sol, bills at 2x the standard rate, and still accepts the older "priority" value. That is a per-request speed/cost trade you can now make without switching keys.
Why this matters
The win is structural, not cosmetic:
- One key, one billing. The source puts it directly: one integration, unified billing — you stop registering and topping up across four platforms. One key switches you between DeepSeek, Claude, GPT, and Gemini.
- Route by task, not by tool. The comparison post's own workflow: hard problems to Claude Code (flagship Claude), daily high-frequency work to dsh (cheap DeepSeek). Both tools point at the same endpoint and the same key.
- Protocol correctness is a cost lever. This is the subtle one, and the doc is explicit: calling Claude through the OpenAI-compatible format can lose prompt cache and thinking capabilities, which means higher cost and degraded capability — fine for simple chat, wrong for agent workloads. The pattern's discipline — Anthropic protocol for Claude, OpenAI protocol for OpenAI models — is what preserves the caching that keeps bills down.
Honest risks of third-party endpoints
The pattern concentrates your stack on a third-party gateway, and the docs themselves are candid about the edges:
-
Rate limits on free tiers. The free preview models are capped daily:
deepseek-v4-pro-freeat 50 requests per day,deepseek-v4-flash-freeandglm-5.3-flash-freeat 200 requests per day. When the quota is spent, you must switch to the paid equivalents. -
Protocol narrowness.
/v1/responsesis GPT-series only — Claude and Gemini return a 400. Gemini has its own native endpoint; there is no shortcut around picking the right protocol per model. -
Latency on big models. Opus/Fable-class models can take seconds to tens of seconds to emit a first token during the thinking phase; the doc says that is normal, not a failure, and recommends streaming (
"stream": true) plus client read timeouts up to the server's 600-second cap. - You are adding a dependency. A third-party endpoint is another system that can rate-limit, degrade, or go down. The source's own FAQ is even-handed: connecting to the official API is the simplest path; a gateway like this makes sense when you want one key across many models, a free tier to start with, or better connectivity from your region.
-
Key hygiene. Keys prefixed
sk-teamo-belong in environment variables or a secret manager — never hardcoded, never committed to Git, never shipped in a client. If a key leaks, revoke it and replace it.
Conclusion
The OpenAI-compatible endpoint pattern decouples your agent tools from your model provider: one base URL, one key, and each tool keeps its native protocol — Anthropic for Claude Code, OpenAI for Codex and dsh, Gemini for Gemini CLI. The cost is a new dependency on the gateway, so keep official keys handy for the cases where the third-party route adds more risk than it removes. The payoff is one billing pipeline, unified access to every major model family, and the freedom to route each task to the cheapest model that can actually do it.
Top comments (0)