Hanzo
SDKs

Python SDK

The flagship Hanzo Python SDK — pip install hanzo for AI + agents, pip install hanzoai for the full Cloud SDK.

Python SDK

Python is Hanzo's flagship — the most complete of every language. It ships in two lines you can install independently or together.

hanzo — AI / agents (flagship)

pip install hanzo. Models, agents, tools, memory, MCP, and inference. Source: hanzoai/python-sdk.

hanzoai — Cloud SDK

pip install hanzoai. The full, generated client for the entire Open AI Cloud (/v1/*). OpenAI-compatible surface. Source: hanzo-py/sdk.

Install

pip install hanzo

Both are generally available on PyPI. Set your key once:

export HANZO_API_KEY="hk-..."   # from console.hanzo.ai

Quick start — Cloud SDK

The hanzoai client is a typed client for every /v1 endpoint, OpenAI-compatible for chat:

from hanzoai import Hanzo

client = Hanzo(api_key="hk-your-key")  # or reads HANZO_API_KEY

response = client.chat.completions.create(
    model="zen5",
    messages=[{"role": "user", "content": "Explain quantum computing"}],
)
print(response.choices[0].message.content)

Streaming

stream = client.chat.completions.create(
    model="zen5-coder",
    messages=[{"role": "user", "content": "Write a haiku about AI"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Async

import asyncio
from hanzoai import AsyncHanzo

async def main():
    client = AsyncHanzo(api_key="hk-your-key")
    response = await client.chat.completions.create(
        model="zen5",
        messages=[{"role": "user", "content": "Hello!"}],
    )
    print(response.choices[0].message.content)

asyncio.run(main())

Quick start — AI / agents (flagship)

The hanzo library is the AI-first flagship — agents, tools, memory, and MCP on top of the same cloud:

from hanzo import Agent

agent = Agent(model="zen5", tools=["search", "shell", "browser"])
result = agent.run("Find the latest release and summarize the changelog.")
print(result.output)

Bundled tooling

pip install "hanzo[all]" also installs the hanzo CLI (login, dev, bot, kms, iam, storage) plus hanzo-agent, hanzo-mcp, and hanzo-memory.

Function calling

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather for a location",
        "parameters": {
            "type": "object",
            "properties": {"location": {"type": "string"}},
            "required": ["location"],
        },
    },
}]

response = client.chat.completions.create(
    model="zen5",
    messages=[{"role": "user", "content": "Weather in Tokyo?"}],
    tools=tools,
    tool_choice="auto",
)

Configuration

client = Hanzo(
    api_key="hk-your-key",
    base_url="https://api.hanzo.ai/v1",  # default
    timeout=60.0,
    max_retries=2,
)

Resources

How is this guide?

Last updated on

On this page