Files

157 lines
3.7 KiB
JSON

[
[
{
"a": "Integrations",
"href": "/integrations"
},
{
"h1": "Use Hanzo AI with Rust"
},
{
"p": "Use Hanzo AI in Rust via the async-openai crate or raw reqwest HTTP calls. Full async support with Tokio, streaming, and type-safe API access."
},
{
"p": "Base URL: https://api.hanzo.ai/v1"
},
{
"code": "https://api.hanzo.ai/v1"
},
{
"p": "API Key: Get yours at platform.hanzo.ai/api-keys · Fully OpenAI-compatible · every model on the gateway available"
},
{
"a": "platform.hanzo.ai/api-keys",
"href": "https://platform.hanzo.ai/api-keys"
},
{
"p": "Created by Rust Foundation"
},
{
"a": "Rust Foundation",
"href": "https://rust-lang.org"
},
{
"p": "License: MIT / Apache-2.0 · View source on GitHub →"
},
{
"a": "View source on GitHub →",
"href": "https://github.com/rust-lang/rust"
},
{
"p": "Hanzo AI is OpenAI-compatible, so existing Rust code works with zero refactoring. We deeply appreciate the Rust Foundation team for building and maintaining this open-source project."
},
{
"h2": "Cargo.toml"
},
{
"code": "[ dependencies ] async-openai = \" 0.26 \" tokio = { version = \" 1 \" , features = [ \" full \" ] }"
},
{
"h2": "async-openai"
},
{
"code": "use async_openai:: { config::OpenAIConfig , Client , types::* }; #[ tokio::main ] async fn main () { let config = OpenAIConfig:: new () . with_api_base ( \" https://api.hanzo.ai/v1 \" ) . with_api_key ( std::env:: var ( \" HANZO_API_KEY \" ) . unwrap ()); let client = Client:: with_config ( config ); let request = CreateChatCompletionRequestArgs:: default () . model ( \" zen4-pro \" ) . messages ([ ChatCompletionRequestUserMessageArgs:: default () . content ( \" Hello from Rust! \" ) . build () . unwrap () . into ()]) . build () . unwrap (); let response = client. chat () . create ( request ) . await "
},
{
"h2": "reqwest raw HTTP"
},
{
"code": "use reqwest::Client ; use serde_json::json ; #[ tokio::main ] async fn main () { let client = Client:: new (); let resp = client . post ( \" https://api.hanzo.ai/v1/chat/completions \" ) . bearer_auth ( std::env:: var ( \" HANZO_API_KEY \" ) . unwrap ()) . json ( & json! ({ \" model \" : \" zen4-pro \" , \" messages \" : [{ \" role \" : \" user \" , \" content \" : \" Hello! \" }] })) . send () . await . unwrap (); println! ( \"{}\" , resp. text () . await . unwrap ()); }"
},
{
"h2": "Build and run"
},
{
"code": "export HANZO_API_KEY= \" your-hanzo-api-key \" cargo build --release ./target/release/my-ai-app"
},
{
"h2": "Ready to get started?"
},
{
"p": "Create a free account and get your API key. The Free plan includes free model requests and Kai decisions, no card."
},
{
"a": "Get API key — Free",
"href": "https://platform.hanzo.ai/api-keys"
},
{
"a": "Browse Models",
"href": "/models"
},
{
"h2": "More integrations"
},
{
"a": "OpenAI Python SDK",
"href": "/integrations/openai-sdk"
},
{
"a": "Anthropic SDK",
"href": "/integrations/anthropic-sdk"
},
{
"a": "LangChain",
"href": "/integrations/langchain"
},
{
"a": "LlamaIndex",
"href": "/integrations/llamaindex"
},
{
"a": "Vercel AI SDK",
"href": "/integrations/vercel-ai-sdk"
},
{
"a": "Hugging Face",
"href": "/integrations/huggingface"
},
{
"a": "AutoGen",
"href": "/integrations/autogen"
},
{
"a": "CrewAI",
"href": "/integrations/crewai"
},
{
"a": "DSPy",
"href": "/integrations/dspy"
},
{
"a": "Haystack",
"href": "/integrations/haystack"
},
{
"a": "Cursor",
"href": "/integrations/cursor"
},
{
"a": "Continue.dev",
"href": "/integrations/continue-dev"
},
{
"a": "GitHub Copilot",
"href": "/integrations/github-copilot"
},
{
"a": "Docker",
"href": "/integrations/docker"
},
{
"a": "Kubernetes",
"href": "/integrations/kubernetes"
},
{
"a": "Python",
"href": "/integrations/python"
},
{
"a": "TypeScript",
"href": "/integrations/typescript"
},
{
"a": "Go",
"href": "/integrations/go"
}
]
]