Use the OpenAI SDK with Claude and Gemini
Change base_url and the API key to call Claude, GPT and Gemini from one OpenAI client in Python or Node.js, and learn where that shortcut stops working.
The OpenAI SDK is the most widely supported client in the ecosystem, and it lets you change two things: the base URL and the API key. Point them at Half Off Dev and the same client can call GPT, Claude and Gemini models, so switching a model is a one-word change. This page shows the setup in Python and Node.js, how to list models, and, importantly, what you give up compared with each vendor's own API.
The two-line change
from openai import OpenAI
client = OpenAI(base_url="https://halfoff.dev/v1", api_key="ho-...")
reply = client.chat.completions.create(
model="claude-sonnet-5.5",
messages=[{"role": "user", "content": "Say hello in French."}],
)
print(reply.choices[0].message.content)Keep /v1 on the base URL here: the OpenAI SDK adds only the path after it. Environment variables work too: OPENAI_BASE_URL and OPENAI_API_KEY are read by the official SDKs, so existing code and tools can be redirected without editing it.
List the models
for m in client.models.list():
print(m.id)GET https://halfoff.dev/v1/models is public and returns every model with its price. Use those ids exactly; the model list shows them too.
Where the shortcut stops
Chat Completions is OpenAI's format. When you send it to a Claude or Gemini model, the request is converted for that model, so features that exist only in the vendor's own API may be dropped or refused. In practice:
| You want | Use |
|---|---|
| Plain chat, streaming, function calling, JSON output | The OpenAI client works with every model |
Claude cache_control, extended thinking | The Anthropic SDK against https://halfoff.dev (guide) |
Gemini thinkingConfig, native audio and video input | The Gemini SDK or REST (guide) |
| GPT Responses API, Codex CLI | https://halfoff.dev/v1/responses (guide) |
If a price matters, the native format also matters: Claude's cache discount needs cache_control, which is only guaranteed in Anthropic format. Prompt caching explains each vendor's way.
Troubleshooting
401the key isn't reaching the server, or it was mistyped. Check the environment variable name your code reads.
404 mentioning the modelthe id isn't in GET /v1/models. Copy it from there.
404 with /v1/v1/ in the paththe base URL ends in /v1 and the tool adds it again. Remove it for tools that append /v1 themselves.
402the balance is empty or a spend cap was hit. See Billing.
The full list is in Errors.
Frequently asked questions
Can I use the OpenAI SDK with Claude?+
Yes. Set the base URL to https://halfoff.dev/v1, use your key, and set model to a Claude id such as claude-sonnet-5.5. For Claude-only features like prompt caching controls, use the Anthropic SDK instead.
Does the OpenAI Python library support a custom base URL?+
Yes: pass base_url to the client, or set OPENAI_BASE_URL. The same goes for the Node.js library with baseURL.
Is it OpenAI-compatible, or the real API?+
Both formats are served natively on the same host: OpenAI Chat Completions and Responses, Anthropic Messages and Gemini. Pick the one your code already speaks.
Which model should I start with?+
A mid-sized model from any vendor; compare with the calculator and the vendor price guides for Claude, GPT and Gemini.
How much does it cost?+
Every model is half of its official list price, billed per token from a prepaid balance. Create an account and make a key to start.