Python AI API quickstart (₹ pricing, India)
Use OpenAI SDK or requests in Python with unoblox. Copy endpoint + key, deploy in minutes. Monthly ₹ GST invoice.
Python + unoblox: text generation in rupees
Python developers already know the OpenAI SDK. Point it at unoblox, pick a model, and call chat completions billed in rupees on a monthly GST invoice from India, with input tax credit.
Minimal example (3 minutes)
pip install openai
from openai import OpenAI
client = OpenAI(
base_url="https://api.unoblox.ai/v1",
api_key="ub-gw-YOUR_API_KEY" # from unoblox.ai/sign-in
)
response = client.chat.completions.create(
model="qwen/qwen3-235b-a22b-instruct-2507",
messages=[
{"role": "user", "content": "Summarize GST in India"}
]
)
print(response.choices[0].message.content)
Run it, then check the request and its ₹ cost at /dashboard any time.
Advanced: streaming, vision, and async
# Streaming (real-time tokens)
stream = client.chat.completions.create(
model="qwen/qwen3-235b-a22b-instruct-2507",
messages=[{"role": "user", "content": "..."}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
# Vision (if the model supports it)
response = client.chat.completions.create(
model="qwen/qwen3-235b-a22b-instruct-2507",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{"type": "image_url", "image_url": {"url": "https://..."}}
]
}
]
)
# Async, for concurrent requests
import asyncio
from openai import AsyncOpenAI
aclient = AsyncOpenAI(base_url="https://api.unoblox.ai/v1", api_key="ub-gw-...")
async def ask(prompt):
r = await aclient.chat.completions.create(
model="deepseek-ai/deepseek-v4-flash",
messages=[{"role": "user", "content": prompt}]
)
return r.choices[0].message.content
results = asyncio.run(asyncio.gather(*(ask(q) for q in ["q1", "q2", "q3"])))
Pricing: straightforward ₹ per token consumed
| Model | Input ₹/1M | Output ₹/1M | Use case |
|---|---|---|---|
| Qwen3.8-27B | ₹16.32 | ₹48.96 | general, vision |
| DeepSeek V3.2 | ₹26.21 | ₹38.30 | reasoning, coding |
| Qwen3 1.7B | ₹0 | ₹0 | free, rate-limited |
| Claude Sonnet | ₹201.6 | ₹1008 | production benchmark |
Deploying behind Django or FastAPI
FastAPI's async views pair naturally with AsyncOpenAI:
from fastapi import FastAPI
from openai import AsyncOpenAI
app = FastAPI()
client = AsyncOpenAI(base_url="https://api.unoblox.ai/v1", api_key="ub-gw-...")
@app.post("/chat")
async def chat(prompt: str):
r = await client.chat.completions.create(
model="deepseek-ai/deepseek-v4-flash",
messages=[{"role": "user", "content": prompt}]
)
return {"reply": r.choices[0].message.content}
Django is typically sync, so use the plain OpenAI client inside a view or a Celery task rather than AsyncOpenAI — Django's async view support works too if your project already uses it.
FAQ
Can I use asyncio for concurrent requests?
Yes — see the async example above. Use AsyncOpenAI instead of OpenAI, then await calls inside async functions for non-blocking I/O.
How do I handle errors (timeouts, invalid key)?
Catch openai.APIError and its subclasses (RateLimitError, AuthenticationError, and so on) — the same patterns as any OpenAI-compatible integration.
Do I need to install anything besides openai?
No. The openai package alone is enough, on Python 3.8+.
Can I log every request and response?
Yes. Attach a handler to Python's logging module and point the SDK's HTTP client logger at it, or wrap create() calls in your own logging decorator.
What's the difference between input and output tokens? Input is your prompt; output is the model's reply. Both are billed, usually at different rates, and unoblox itemizes both separately per request.
Can I batch multiple requests? unoblox doesn't offer an OpenAI-style batch endpoint yet. Loop individual requests instead — each is billed at the normal per-token rate.
Get started in rupees → https://unoblox.ai/sign-in
Start building in rupees
Call every major model through one OpenAI-compatible endpoint, billed in ₹ on a GST invoice.