{"slug": "one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-base-url", "title": "One OpenAI-compatible key for Claude, Gemini, DeepSeek, GLM and Kimi: the base_url swap, and what still differs", "summary": "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.", "body_md": "*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.*\n\nMost 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`.\n\nThis post shows that swap against one endpoint that serves all of them, then covers the parts that don't carry over cleanly.\n\nMartLLM implements the OpenAI Chat Completions API at `https://api.martllm.com/v1`. The [OpenAI SDK guide](https://martllm.com/docs/openai-sdk) puts it plainly: set `base_url` and `api_key`, and messages, tools, `response_format`, `stream`, `max_tokens` and `temperature` stay the same.\n\n``` python\nimport os\n\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://api.martllm.com/v1\",  # the trailing /v1 is required\n    api_key=os.environ[\"MARTLLM_API_KEY\"],\n)\n\nMODELS = [\n    \"anthropic/claude-sonnet-5.5\",\n    \"google/gemini-3.8-flash\",\n    \"deepseek/deepseek-v4.1-flash\",\n    \"z-ai/glm-5.3\",\n    \"moonshotai/kimi-k3\",\n]\n\nfor model in MODELS:\n    resp = client.chat.completions.create(\n        model=model,\n        messages=[{\"role\": \"user\", \"content\": \"In one sentence: what is a vector database?\"}],\n        max_tokens=120,\n    )\n    u = resp.usage\n    cost = getattr(u, \"cost_usd\", None)  # MartLLM adds usage.cost_usd to every reply\n    print(f\"{resp.model:32} {u.prompt_tokens:>4} in {u.completion_tokens:>4} out  ${cost}\")\n    print(\"   \", resp.choices[0].message.content.strip()[:160])\n```\n\nFive 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.\n\nTypeScript is the same two settings:\n\n``` python\nimport OpenAI from \"openai\";\n\nconst client = new OpenAI({\n  baseURL: \"https://api.martllm.com/v1\",\n  apiKey: process.env.MARTLLM_API_KEY,\n});\n\nconst resp = await client.chat.completions.create({\n  model: \"anthropic/claude-sonnet-5.5\",\n  messages: [{ role: \"user\", content: \"Explain idempotency keys in two sentences.\" }],\n});\nconsole.log(resp.choices[0].message.content);\n```\n\nThe same endpoint also speaks Anthropic's Messages API. Note the base URL has **no** `/v1` here, because the SDK adds `/v1/messages` itself:\n\n``` python\nfrom anthropic import Anthropic\n\nclient = Anthropic(base_url=\"https://api.martllm.com\", api_key=os.environ[\"MARTLLM_API_KEY\"])\nmsg = client.messages.create(\n    model=\"google/gemini-3.8-flash\",   # any catalog model, not only Claude\n    max_tokens=256,\n    messages=[{\"role\": \"user\", \"content\": \"Say hello in one sentence.\"}],\n)\nprint(msg.content[0].text)\n```\n\nThe gateway translates between the two shapes, streaming included ([Anthropic SDK guide](https://martllm.com/docs/anthropic-sdk)). That's also how tools like Claude Code can run on non-Claude models.\n\nRead 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.\n\n| Model | List | Cheapest offer now | Paid, last 7 days | \n|---|---|---|---|\n| `anthropic/claude-sonnet-5.5` | $2.00 / $10.00 | $1.008 / $5.04 | $1.07 / $5.37 | \n| `google/gemini-3.8-flash` | $0.75 / $3.75 | $0.126 / $0.63 | $0.120 / $0.602 | \n| `deepseek/deepseek-v4.1-flash` | $0.21 / $0.78 | $0.1345 / $0.4996 | $0.0208 / $0.0771 | \n| `z-ai/glm-5.3` | $1.40 / $4.40 | $0.0243 / $0.0901 | $0.0492 / $0.1827 | \n| `moonshotai/kimi-k3` | $3.00 / $15.00 | $0.2764 / $1.4175 | $0.1064 / $0.5457 | \n\nEach 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](https://martllm.com/llm-api-pricing). If you need a hard ceiling, set one per request (below).\n\n**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.\n\n**Needs care:**\n\n`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.\nThese are MartLLM extensions, passed through the OpenAI SDK's `extra_body` (details in [models and routing](https://martllm.com/docs/models-and-routing)):\n\n```\nresp = client.chat.completions.create(\n    model=\"deepseek/deepseek-v4.1-flash\",\n    messages=[{\"role\": \"user\", \"content\": \"Summarize this ticket: ...\"}],\n    extra_body={\n        # Tried in order only if nobody can serve the first model right now.\n        \"models\": [\"z-ai/glm-5.3\", \"google/gemini-3.8-flash\"],\n        # Never pay more than this per million tokens; refused (and free) if nobody sells that low.\n        \"provider\": {\"max_price\": {\"prompt\": 0.5, \"completion\": 1.5}},\n    },\n)\nprint(resp.model)  # the model that actually answered\n```\n\n`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.\nOne 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.\n\nFor everything in between, the change really is two lines.\n\n*Alex, CEO, MartLLM*", "url": "https://wpnews.pro/news/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-base-url", "canonical_source": "https://dev.to/alex_martllm/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-baseurl-swap-and-what-138o", "published_at": "2026-11-28 04:35:05+00:00", "updated_at": "2026-11-28 04:43:10.438982+00:00", "lang": "en", "topics": ["ai-tools", "large-language-models", "developer-tools", "ai-infrastructure", "ai-agents"], "entities": ["MartLLM", "OpenAI", "Anthropic", "Google", "DeepSeek", "Z.ai", "Moonshot AI", "Claude Code"], "also_reported_by": [], "takeaway": "Pointing the OpenAI SDK at an OpenAI-compatible gateway's base_url (with the trailing /v1 required) lets one client loop call Claude, Gemini, DeepSeek, GLM and Kimi by maker/model ID, while the Anthropic SDK needs the base URL without /v1 because it appends /v1/messages itself.", "recommendation": {"advice": "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.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-base-url", "markdown": "https://wpnews.pro/news/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-base-url.md", "text": "https://wpnews.pro/news/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-base-url.txt", "jsonld": "https://wpnews.pro/news/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-base-url.jsonld"}}