Guides
Migration
unoblox is a drop-in for the OpenAI and Anthropic APIs. In most codebases the switch is two lines — the base URL and the key — because the request and response schemas are the ones your SDK already speaks.
From OpenAI
The gateway implements the OpenAI Chat Completions API natively at /v1/chat/completions. Point the OpenAI SDK at the gateway, use your ub-gw-… key, and change model names to author/model slugs. Fields you already send — messages, tools, tool_choice, response_format, stream — are forwarded to the model untouched.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.unoblox.ai/v1", # changed
api_key=os.environ["UNOBLOX_API_KEY"], # changed (ub-gw-…)
)
# Everything else is identical. Model ids become author/model slugs —
# browse /models for a real one.
resp = client.chat.completions.create(
model="<model-id>", # was e.g. "gpt-4o"
messages=[{"role": "user", "content": "Hello"}],
# tools, tool_choice, response_format, stream, temperature, …
# all pass straight through to the model.
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.unoblox.ai/v1", // changed
apiKey: process.env.UNOBLOX_API_KEY, // changed (ub-gw-…)
});
const resp = await client.chat.completions.create({
model: "<model-id>", // was e.g. "gpt-4o"
messages: [{ role: "user", content: "Hello" }],
});From Anthropic
The gateway also exposes the Anthropic Messages API at /v1/messages, so you can keep your Anthropic-shaped payloads. One important difference:
unoblox accepts both Anthropic authentication forms.
The gateway accepts both Authorization: Bearer <key> and x-api-key: <key> on /v1/messages. With the Anthropic SDK, use auth_token for Bearer authentication or api_key for the default x-api-key header.
curl https://api.unoblox.ai/v1/messages \
-H "Authorization: Bearer $UNOBLOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model-id>",
"max_tokens": 256,
"messages": [{ "role": "user", "content": "Hello" }]
}'import os
from anthropic import Anthropic
# unoblox accepts either Authorization: Bearer or x-api-key.
# Use auth_token for Bearer authentication, or api_key for x-api-key.
# base_url omits /v1: the SDK appends /v1/messages itself.
client = Anthropic(
base_url="https://api.unoblox.ai",
auth_token=os.environ["UNOBLOX_API_KEY"],
)
msg = client.messages.create(
model="<model-id>",
max_tokens=256, # required by the Messages API
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)Prefer to consolidate on one client? Anthropic users can also just use the OpenAI SDK against /v1/chat/completions (shown above) and select an anthropic/… model — the gateway translates for you.
What changes, what doesn't
| Aspect | Before | With unoblox |
|---|---|---|
| Base URL | api.openai.com / api.anthropic.com | api.unoblox.ai/v1 |
| Key | sk-… / x-api-key | ub-gw-… as Authorization: Bearer |
| Model id | gpt-4o, claude-… | an author/model slug from /models |
| messages, tools, response_format, stream | as you send them | mostly forwarded — see each skin's own reference page for what it validates or rejects |
| Billing | a separate foreign-currency invoice per provider | one prepaid ₹ balance, metered per token |
The gateway validates model and a non-empty messages array first; most other fields are then forwarded to the model, but each skin also rejects a handful of fields it does not support (unsupported tool types, certain Responses/Anthropic-only fields, the :online/:batch suffixes) rather than passing them through silently — see API reference.
Frameworks
Anything built on the OpenAI protocol works the same way. For LangChain, construct ChatOpenAI with the gateway base URL and your key:
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://api.unoblox.ai/v1",
api_key=os.environ["UNOBLOX_API_KEY"],
model="<model-id>",
)LlamaIndex, the Vercel AI SDK, LiteLLM and similar tools follow the same pattern — set the OpenAI base URL to https://api.unoblox.ai/v1 and the key to your ub-gw-… token.
Migrate incrementally.
unoblox extensions — multi-model models: [] failover, unoblox/auto routing, BYOK — are all optional additions to the same request. Move traffic over first, adopt them when you want them.