[ Docs ]
Python SDK
Planned IdonAI Python client — install target, chat completions, and streaming notes.
Status
The idonai package name is reserved. Public install lands when API keys ship. Until then, treat the snippets below as the intended client shape and validate prompts in Quark or against the REST contract.
Install (planned)
pip install idonai
Pin a version in production once the package is published. Prefer a virtualenv or lockfile so CI and local environments stay aligned.
Client init
import os
from idonai import IdonAI
client = IdonAI(api_key=os.environ["IDONAI_API_KEY"])
Never hardcode keys. Load from the environment or your secret manager. See Authentication.
Chat completion
response = client.models.generate(
model="origin",
messages=[
{"role": "user", "content": "Explain quantum entanglement."}
],
max_tokens=1024,
)
print(response.content)
Use model="nextgen" for harder reasoning. Model ids match Quark and the API reference.
Streaming
Pass stream=True (or the SDK’s stream helper when published) to iterate tokens as they arrive. Drain the iterator fully, and handle disconnects the same way you would for SSE over REST.
# Sketch — exact helper names may refine at publish time
for event in client.models.generate(
model="origin",
messages=[{"role": "user", "content": "Outline three steps."}],
stream=True,
):
print(event.content, end="", flush=True)
Async
An async client is planned for asyncio services:
import asyncio
from idonai import AsyncIdonAI
async def main():
client = AsyncIdonAI(api_key=os.environ["IDONAI_API_KEY"])
response = await client.models.generate(
model="origin",
messages=[{"role": "user", "content": "Hello."}],
)
print(response.content)
asyncio.run(main())
Errors
Catch SDK / HTTP errors for 401, 403, 429, and 5xx. On 429, back off using Retry-After when present — see Rate limits. Do not retry 400 without fixing the request body.