mirror of
https://github.com/hanzoai/sdk.git
synced 2026-10-30 15:00:56 +00:00
- Add complete multi-language SDK matrix (Python, TS, Go, Rust, PHP, Ruby, Dart, Java, Kotlin, Swift, C++, C#, Fetch, Angular, CLI) - Fix dedicated org repository links (hanzo-php/sdk, hanzo-ruby/sdk, hanzo-dart/sdk, hanzo-go/sdk, etc.) - Add OpenAPI 3.1 canonical specification (spec/openapi.json) for /v1 routes and Kai decision governance - Add wire conformance test fixtures (auth, chat, SSE streaming, tool calls, Kai decisions, embeddings, errors) - Add standalone zero-dependency Python conformance runner and local mock gateway (conformance/runner.py) - Add runnable multi-language quickstarts in examples/ - Add GitHub Actions CI workflow for conformance verification (.github/workflows/conformance.yml) Co-authored-by: Hanzo Dev <[email protected]>
37 lines
981 B
Rust
37 lines
981 B
Rust
//! Rust Quickstart for Hanzo AI SDK
|
|
//!
|
|
//! Add to Cargo.toml:
|
|
//! [dependencies]
|
|
//! hanzo-client = "1.0"
|
|
//! tokio = { version = "1", features = ["full"] }
|
|
|
|
use hanzo_client::{Client, ChatMessage, Role};
|
|
use std::env;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let api_key = env::var("HANZO_API_KEY").unwrap_or_else(|_| "sk-test-key".into());
|
|
let client = Client::new(&api_key);
|
|
|
|
println!("--- 1. List Models ---");
|
|
let models = client.models().list().await?;
|
|
println!("Retrieved {} models", models.data.len());
|
|
|
|
println!("\n--- 2. Chat Completion ---");
|
|
let response = client
|
|
.chat()
|
|
.create_completion("zen5", vec![
|
|
ChatMessage {
|
|
role: Role::User,
|
|
content: "Hello from Rust!".into(),
|
|
}
|
|
])
|
|
.await?;
|
|
|
|
if let Some(choice) = response.choices.first() {
|
|
println!("Reply: {}", choice.message.content);
|
|
}
|
|
|
|
Ok(())
|
|
}
|