Python
API reference
Zukko works with the official SDKs — no code changes, just base_url and the key.
| SDK | Base URL | Key |
|---|---|---|
OpenAI (openai) | https://api.zukko.pro/v1 | fetch_... |
Anthropic (anthropic) | https://api.zukko.pro | fetch_... |
1OpenAI SDK
bash
pip install openaipython
from openai import OpenAI
client = OpenAI(base_url="https://api.zukko.pro/v1", api_key="fetch_...")
r = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Hello!"}],
)
print(r.choices[0].message.content)model also accepts GPT models such as gpt-5.6-sol and the cheap GLM model glm-5.3-flash.
Streaming
python
stream = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Write a haiku about code"}],
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="", flush=True)
elif chunk.usage:
print(f"\n[tokens: {chunk.usage.prompt_tokens} in, {chunk.usage.completion_tokens} out]")The if chunk.choices check is required. Zukko enables stream_options.include_usage, so the stream ends with a separate chunk that has usage and an empty choices — without the check chunk.choices[0] raises IndexError.
Request cost
The X-Zukko-Cost-Micros header (in microdollars) is available via with_raw_response:
python
raw = client.chat.completions.with_raw_response.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": "Hello!"}],
)
print(raw.headers.get("x-zukko-cost-micros"))
r = raw.parse()The header is present only on regular (non-streaming) responses.
2Anthropic SDK
bash
pip install anthropicpython
from anthropic import Anthropic
client = Anthropic(base_url="https://api.zukko.pro", api_key="fetch_...")
msg = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(msg.content[0].text)Streaming
python
with client.messages.stream(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku about code"}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)3Key from environment variables
Keep the key out of your code:
bash
export OPENAI_BASE_URL="https://api.zukko.pro/v1"
export OPENAI_API_KEY="fetch_..."python
from openai import OpenAI
client = OpenAI() # reads OPENAI_BASE_URL and OPENAI_API_KEYAny catalog model works in model — see GET /v1/models. Error codes are in API errors.