Observed since 20 Oct, 19:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Official Python client for the Aditya API (Indian-language AI models by Aditya Lab)
The official Python library for Aditya, a family of AI models built for Indian languages.
pip install adityalab
Python 3.9+. Its only dependency is httpx.
Create an API key at platform.adityalab.in, then:
export ADITYA_API_KEY="bk_..."
from adityalab import Aditya
client = Aditya() # reads ADITYA_API_KEY
reply = client.chat.completions.create(
model="aditya-latest",
messages=[{"role": "user", "content": "Explain an API in Hindi."}],
)
print(reply.text)
reply is the standard chat-completion object, so reply.choices[0].message.content and reply.usage.total_tokens work too.
with client.chat.completions.create(
model="aditya-latest",
messages=[{"role": "user", "content": "Tell me a short story in Tamil."}],
stream=True,
) as stream:
for piece in stream.text():
print(piece, end="", flush=True)
To read the raw chunks instead of only the text, iterate stream directly.
Pass conversation="new" on the first call. After that, send only the new message with the returned id, and the server supplies the earlier turns:
first = client.chat.completions.create(
model="aditya-latest",
messages=[{"role": "user", "content": "मेरा नाम रिया है।"}],
conversation="new",
)
cid = first.conversation_id
second = client.chat.completions.create(
model="aditya-latest",
messages=[{"role": "user", "content": "मेरा नाम क्या है?"}],
conversation=cid,
)
print(second.text)
Calls without conversation are stateless, and nothing is stored.
To list, read and delete stored conversations:
for conv in client.conversations.iter():
print(conv.id, conv.title)
page = client.conversations.messages(cid) # .items, .nextAfter
client.conversations.delete(cid)
client.models.list() # the models your key can call
client.credits.balance() # .balance (in credits), .planTier
client.credits.usage() # spend over the last 5 hours, day and 30 days
client.pricing.retrieve() # public price list
import asyncio
from adityalab import AsyncAditya
async def main():
async with AsyncAditya() as client:
reply = await client.chat.completions.create(
model="aditya-latest", messages=[{"role": "user", "content": "नमस्ते"}])
print(reply.text)
stream = await client.chat.completions.create(
model="aditya-latest", messages=[{"role": "user", "content": "नमस्ते"}], stream=True)
async for piece in stream.text():
print(piece, end="")
asyncio.run(main())
Every API error is raised as a typed exception. Each one has .status_code, .code (a stable string to branch on), .message and .request_id; quote the request id when you contact support.
import adityalab
try:
client.chat.completions.create(model="aditya-latest", messages=[...])
except adityalab.InsufficientCreditsError:
... # top up at platform.adityalab.in
except adityalab.RateLimitError as e:
... # e.code == "window_cap_reached" means your plan's 5-hour window is used up; see e.retry_after
except adityalab.AuthenticationError:
... # wrong, revoked or expired key
except adityalab.APIConnectionError:
... # network trouble, or a timeout (APITimeoutError)
| Exception | When |
|---|---|
BadRequestError | 400: the request is malformed |
AuthenticationError | 401: missing, invalid, revoked or expired key |
InsufficientCreditsError | out of credits |
PermissionDeniedError | 403 |
NotFoundError | 404: unknown model or conversation |
RateLimitError | 429 |
InternalServerError | 5xx, including a busy model (model_busy) |
StreamError | the model stopped partway through a stream |
The client retries automatically, up to max_retries times (default 2):
It never re-sends a conversation turn after the server may have stored it. It also does not wait out a long Retry-After, such as a used-up usage window; you get the error straight away.
client = Aditya(timeout=60, max_retries=3)
client.chat.completions.create(..., timeout=10) # per call
The API is also OpenAI-compatible, so existing OpenAI code works with base_url="https://api.adityalab.in/v1". Use this library to get typed errors, server-side conversations, and the credits and pricing calls.
| Option | Environment variable | Default |
|---|---|---|
api_key | ADITYA_API_KEY | none (required) |
base_url | ADITYA_BASE_URL | https://api.adityalab.in/v1 |
timeout | none | 120 seconds |
max_retries | none | 2 |
Pass http_client=httpx.Client(...) to set up proxies or custom TLS.
Apache-2.0
pypistats · 10 observations shown. Missing days are unknown. Source category: overall: without mirrors.
| Date / source period | Value | Observed at |
|---|---|---|
| 2026-10-19 – 2026-10-19 | 2 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-18 – 2026-10-18 | 1 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-17 – 2026-10-17 | 2 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-15 – 2026-10-15 | 3 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-14 – 2026-10-14 | 3 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-13 – 2026-10-13 | 1 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-11 – 2026-10-11 | 2 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-10 – 2026-10-10 | 3 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-09 – 2026-10-09 | 20 | 2026-10-20T20:15:15.8521266Z |
| 2026-10-08 – 2026-10-08 | 83 | 2026-10-20T20:15:15.8521266Z |
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 8 Oct 2026 | 2 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 19:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:22ce882fe8a39949427ba5eec754bb3d3186d113f0e59dcb0f61f2e9ef2f57e8