cd /news/ai-tools/one-openai-compatible-key-for-claude… · home › topics › ai-tools › article
[ARTICLE · art-177590] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

One OpenAI-compatible key for Claude, Gemini, DeepSeek, GLM and Kimi: the base_url swap, and what still differs

Alex, who runs the MartLLM gateway, demonstrated that developers can call Claude, Gemini, DeepSeek, GLM and Kimi models through the existing OpenAI SDK by swapping only the base_url and api_key, with model IDs in a maker/model format and a usage.cost_usd field added to every response. The endpoint also translates Anthropic's Messages API, letting tools like Claude Code run on non-Claude models. MartLLM's published pricing table shows live seller prices and seven-day average billed rates running well below list prices for several models.

recommendation

Route multi-vendor model calls through one OpenAI-compatible base_url and compare live seller prices against list rates before budgeting, since the source shows seven-day paid rates far below list for several models.

more in playbook: Controlling LLM cost
by read5 min views9 publishedNov 28, 2026

Disclosure: I'm Alex, and I run MartLLM, the endpoint in these examples. The base_url pattern works with any OpenAI-compatible gateway. The routing fields near the end are MartLLM's own.

Most LLM code in production is written against the OpenAI Python or TypeScript SDK, even when the model isn't OpenAI's. The SDK is good, the wire format is everywhere, and every framework (LangChain, LlamaIndex, LiteLLM, the Vercel AI SDK, Pydantic AI) can talk to it. So the cheapest way to try Claude, Gemini or DeepSeek in an existing codebase usually isn't a new SDK. It's a different base_url.

This post shows that swap against one endpoint that serves all of them, then covers the parts that don't carry over cleanly.

MartLLM implements the OpenAI Chat Completions API at https://api.martllm.com/v1. The OpenAI SDK guide puts it plainly: set base_url and api_key, and messages, tools, response_format, stream, max_tokens and temperature stay the same.

import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.martllm.com/v1",  # the trailing /v1 is required
    api_key=os.environ["MARTLLM_API_KEY"],
)

MODELS = [
    "anthropic/claude-sonnet-5.5",
    "google/gemini-3.8-flash",
    "deepseek/deepseek-v4.1-flash",
    "z-ai/glm-5.3",
    "moonshotai/kimi-k3",
]

for model in MODELS:
    resp = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "In one sentence: what is a vector database?"}],
        max_tokens=120,
    )
    u = resp.usage
    cost = getattr(u, "cost_usd", None)  # MartLLM adds usage.cost_usd to every reply
    print(f"{resp.model:32} {u.prompt_tokens:>4} in {u.completion_tokens:>4} out  ${cost}")
    print("   ", resp.choices[0].message.content.strip()[:160])

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);

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.

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).

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:

extra_content field, and the model needs it back on the next turn. If you rebuild tool-call messages by hand from only name and arguments, multi-step tool use on Gemini degrades. Append the assistant message you received as is.reasoning and reasoning_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.400 rather than a silent drop. Check input_modalities in GET /v1/models before 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.top_k, verbosity, thinking and 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_parameters in the model list).client.responses.create works on every chat model. previous_response_id and stored conversations need saving turned on for the key. Otherwise send the full conversation each call. 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={
        "models": ["z-ai/glm-5.3", "google/gemini-3.8-flash"],
        "provider": {"max_price": {"prompt": 0.5, "completion": 1.5}},
    },
)
print(resp.model)  # the model that actually answered

models`` provider.max_price``prompt and completion set, the request is never billed above those rates for the tokens it used. If no provider sells that low right now, you get 400 max_price_exceeded and pay nothing. 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

── more in #ai-tools 4 stories · sorted by recency
── more on @martllm 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/one-openai-compatibl…] indexed:0 read:5min 2026-11-28 · —