SDKs
Rust SDK
The Hanzo Rust Cloud SDK — async Tokio client. Coming soon on crates.io; usable today as a git dependency.
Rust SDK
The Rust Cloud SDK is an async Tokio client for the Open AI Cloud (/v1/*).
Coming soon
cargo add hanzo is not yet published to crates.io. The source is complete and
usable today as a git dependency — see below. This page will switch to the
crates.io install the moment it lands.
Install
Once published (GA):
cargo add hanzoToday, depend on it directly from the per-language org:
# Cargo.toml
[dependencies]
hanzo = { git = "https://github.com/hanzo-rs/sdk" }
tokio = { version = "1", features = ["full"] }Set your key:
export HANZO_API_KEY="hk-..." # from console.hanzo.aiQuick start
use hanzo::Client;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = Client::from_env()?; // reads HANZO_API_KEY
let response = client
.chat()
.completions()
.create("zen5", "Explain quantum computing")
.await?;
println!("{}", response.choices[0].message.content);
Ok(())
}Streaming
use futures::StreamExt;
let mut stream = client
.chat()
.completions()
.stream("zen5-coder", "Write a haiku about AI")
.await?;
while let Some(chunk) = stream.next().await {
if let Some(delta) = chunk?.choices.first().and_then(|c| c.delta.content.as_deref()) {
print!("{delta}");
}
}Resources
- Cloud SDK — org hanzo-rs · hanzo-rs/sdk
- Umbrella — hanzoai/sdk
- API reference — every
/v1endpoint →
How is this guide?
Last updated on