One OpenAI-compatible key for Claude, Gemini, DeepSeek, GLM and Kimi: the base_url swap, and what still differs
Five makers, one client, one loop. Model ids are maker/model. GET /v1/models returns the ones you can call right now, in the OpenAI list shape.
TypeScript is the same two settings:
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.martllm.com/v1", apiKey: process.env.MARTLLM_API_KEY, }); const resp = await client.chat.completions.create({ model: "anthropic/claude-sonnet-5.5", messages: [{ role: "user", content: "Explain idempotency keys in two sentences." }], }); console.log(resp.choices[0].message.content);
If your code uses the Anthropic SDK instead
The same endpoint also speaks Anthropic’s Messages API. Note the base URL has no /v1 here, because the SDK adds /v1/messages itself:
from anthropic import Anthropic client = Anthropic(base_url="https://api.martllm.com", api_key=os.environ["MARTLLM_API_KEY"]) msg = client.messages.create( model="google/gemini-3.8-flash", # any catalog model, not only Claude max_tokens=256, messages=[{"role": "user", "content": "Say hello in one sentence."}], ) print(msg.content[0].text)
The gateway translates between the two shapes, streaming included (Anthropic SDK guide). That’s also how tools like Claude Code can run on non-Claude models.
What it costs: live prices for the five models
Read from the public catalog on 2026-11-28 at 03:51 UTC, per million tokens (input / output). “List” is the maker’s official price. “Cheapest offer now” is the lowest live seller price at that moment. “Paid, last 7 days” is the average buyers were actually billed over the previous week, which is the more honest number for budgeting.
| Model | List | Cheapest offer now | Paid, last 7 days |
|---|---|---|---|
anthropic/claude-sonnet-5.5 |
$2.00 / $10.00 | $1.008 / $5.04 | $1.07 / $5.37 |
google/gemini-3.8-flash |
$0.75 / $3.75 | $0.126 / $0.63 | $0.120 / $0.602 |
deepseek/deepseek-v4.1-flash |
$0.21 / $0.78 | $0.1345 / $0.4996 | $0.0208 / $0.0771 |
z-ai/glm-5.3 |
$1.40 / $4.40 | $0.0243 / $0.0901 | $0.0492 / $0.1827 |
moonshotai/kimi-k3 |
$3.00 / $15.00 | $0.2764 / $1.4175 | $0.1064 / $0.5457 |
Each request is sent to a third-party provider serving that model and billed what the provider charged, so the price moves with the market. The full board is at martllm.com/llm-api-pricing. If you need a hard ceiling, set one per request (below).
What carries over, and what doesn’t
Carries over unchanged: messages, system prompts, stream, max_tokens, temperature, response_format, tool definitions. A reply that calls a tool always ends with finish_reason: "tool_calls", whichever provider served it. The reply shape is normalized too. You get the standard fields (id, model, choices, usage), and provider-specific extras are stripped, so code that parses resp.choices[0].message doesn’t need per-model branches.
Needs care:
- Tool calls round-trip as received. Some providers attach extra data to a tool call. Gemini’s thought signature arrives in an
extra_contentfield, and the model needs it back on the next turn. If you rebuild tool-call messages by hand from onlynameandarguments, multi-step tool use on Gemini degrades. Append the assistant message you received as is. - Reasoning text has two names. Reasoning models put their thinking in both
reasoningandreasoning_content, with the same text, so a client that reads either works. Models that don’t reason have neither field. Don’t assume it exists. - Modalities differ. Sending an image to a text-only model gets a clear
400rather than a silent drop. Checkinput_modalitiesinGET /v1/modelsbefore you route pictures, audio or files to a model. Of the five models above, the catalog lists Claude Sonnet 5.5, Gemini 3.8 Flash, DeepSeek V4.1 Flash and Kimi K3 as taking images (Gemini also takes audio and video). GLM 5.3 is text only. - Tuning knobs aren’t universal. Fields that only tune the answer (
top_k,verbosity,thinkingand similar) are dropped for providers that refuse them instead of failing the call. If your evals depend on one of them, confirm the model supports it (supported_parametersin the model list). - Stateful Responses API.
client.responses.createworks on every chat model.previous_response_idand stored conversations need saving turned on for the key. Otherwise send the full conversation each call.
Two request fields worth knowing
These are MartLLM extensions, passed through the OpenAI SDK’s extra_body (details in models and routing):
resp = client.chat.completions.create( model="deepseek/deepseek-v4.1-flash", messages=[{"role": "user", "content": "Summarize this ticket: ..."}], extra_body={ # Tried in order only if nobody can serve the first model right now. "models": ["z-ai/glm-5.3", "google/gemini-3.8-flash"], # Never pay more than this per million tokens; refused (and free) if nobody sells that low. "provider": {"max_price": {"prompt": 0.5, "completion": 1.5}}, }, ) print(resp.model) # the model that actually answered
-
models: fallbacks, at most 5 models in total. The next one is tried only when the one before has no available provider (or none within your price cap). A bad request or an empty balance is answered right away, not passed down the list. -
provider.max_price: with bothpromptandcompletionset, the request is never billed above those rates for the tokens it used. If no provider sells that low right now, you get400 max_price_exceededand pay nothing.
When this pattern is the wrong choice
One OpenAI-compatible key is a good fit when you want to compare models on your own prompts, keep one code path, and pay one prepaid balance. It’s a worse fit when you need a maker’s newest feature on day one, if it only exists in their native SDK, or when a contract requires you to buy from the maker directly. In those cases, keep the native SDK for that one model and route everything else through the shared client.
For everything in between, the change really is two lines.
Alex, CEO, MartLLM
Fuente: Artículo original