Guides
Quickstart
From zero to your first completion in about five minutes. unoblox speaks the OpenAI Chat Completions API, so any OpenAI SDK works — you change the base URL and the key, nothing else.
Before you begin
You need three things:
| What | Where | |
|---|---|---|
| 1 | A unoblox account and workspace | Sign in to the developer portal. |
| 2 | An API key (ub-gw-…) | Create one under API Keys. |
| 3 | A prepaid ₹ balance | Top up on the Credits page — requests draw from it per token. |
1. Set your API key
Keys are workspace-scoped and look like ub-gw-…. The secret is shown once at creation. Export it so the samples below can read it from the environment — never hard-code a key in source:
export UNOBLOX_API_KEY="ub-gw-user_xxx-xxxxxxxxxxxxxxxx"2. Install an SDK (optional)
curl needs nothing. For the SDK samples, install the official OpenAI client — the same one you would use against OpenAI:
# Python
pip install openai
# Node.js
npm install openai3. Send your first request
A model id is an author/model slug. The samples below use <model-id> as a placeholder — swap it for a real one from the catalog.
curl https://api.unoblox.ai/v1/chat/completions \
-H "Authorization: Bearer $UNOBLOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model-id>",
"messages": [
{ "role": "system", "content": "You are a concise assistant." },
{ "role": "user", "content": "Namaste! Give me one fact about UPI." }
]
}'import os
from openai import OpenAI
# unoblox is OpenAI-compatible — point the OpenAI SDK at the gateway.
client = OpenAI(
base_url="https://api.unoblox.ai/v1",
api_key=os.environ["UNOBLOX_API_KEY"], # ub-gw-...
)
resp = client.chat.completions.create(
model="<model-id>",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Namaste! Give me one fact about UPI."},
],
)
print(resp.choices[0].message.content)import OpenAI from "openai";
// unoblox is OpenAI-compatible — point the OpenAI SDK at the gateway.
const client = new OpenAI({
baseURL: "https://api.unoblox.ai/v1",
apiKey: process.env.UNOBLOX_API_KEY, // ub-gw-...
});
const resp = await client.chat.completions.create({
model: "<model-id>",
messages: [
{ role: "system", content: "You are a concise assistant." },
{ role: "user", content: "Namaste! Give me one fact about UPI." },
],
});
console.log(resp.choices[0].message.content);4. Stream the response
Set stream: true for token-by-token text/event-stream output. Add curl's -N flag to disable buffering:
curl -N https://api.unoblox.ai/v1/chat/completions \
-H "Authorization: Bearer $UNOBLOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model-id>",
"messages": [{ "role": "user", "content": "Count to five." }],
"stream": true
}'The stream is OpenAI-compatible and ends with a data: [DONE] sentinel. See Streaming for parsing details.
5. Let unoblox pick the model
Not sure which model to use? Send unoblox/auto and the router selects the best-value model that can serve the request, then fails over across providers automatically. See Routing.
# Let unoblox pick the model for you — best value across the catalog.
curl https://api.unoblox.ai/v1/chat/completions \
-H "Authorization: Bearer $UNOBLOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "unoblox/auto",
"messages": [{ "role": "user", "content": "Draft a 1-line release note." }]
}'If you can call OpenAI, you can call unoblox.
The request and response schemas match, so existing tools — the OpenAI SDKs, LangChain, LlamaIndex — work by changing only the base URL and key. Migrating an existing app? See Migration.