Rust SDK
Official Rust SDK for Tenzro Cloud. High-performance async client built on Tokio.
Installation
cargo add tenzro# or add to Cargo.toml:[dependencies]tenzro = "1.0"tokio = { version = "1", features = ["full"] }
Quick Start
use tenzro::{Tenzro, TenzroConfig};#[tokio::main]async fn main() -> Result<(), tenzro::Error> {let config = TenzroConfig::builder().api_key(std::env::var("TENZRO_API_KEY")?).build()?;let tenzro = Tenzro::new(config)?;// AI chat completionlet response = tenzro.ai().chat().model("gemini-2.5-flash").message("user", "Hello!").send().await?;println!("{}", response.response_text);Ok(())}
Vector Database
use tenzro::vec::VectorEntry;use serde_json::json;// Create vector databaselet db = tenzro.vec().create().project_id("project-id").db_name("embeddings").dimension(1536).send().await?;// Insert vectorstenzro.vec().upsert(&db.vec_db_id).vector(VectorEntry {id: "doc-1".into(),vector: embedding,metadata: json!({ "title": "Document 1" }),}).send().await?;// Search vectorslet results = tenzro.vec().search(&db.vec_db_id).vector(query_embedding).top_k(10).send().await?;
Key-Value Store
use std::time::Duration;// Set value with TTLtenzro.kev().set(&kev_db_id, "session:123").value(&user_data).ttl(Duration::from_secs(3600)).send().await?;// Get valuelet session: UserData = tenzro.kev().get(&kev_db_id, "session:123").send().await?;// Delete valuetenzro.kev().delete(&kev_db_id, "session:123").send().await?;
AI Agents
// Create agentlet agent = tenzro.agents().create().project_id("project-id").agent_name("assistant").system_prompt("You are a helpful assistant.").ai_model("gemini-2.5-flash").send().await?;// Chat with agentlet response = tenzro.agents().chat(&agent.agent_id).message("Hello!").conversation_id("conv-123").send().await?;println!("{}", response.response);
Streaming
use futures::StreamExt;// Stream AI responseslet mut stream = tenzro.ai().stream().model("gemini-2.5-flash").message("user", "Write a story").send().await?;while let Some(chunk) = stream.next().await {let chunk = chunk?;print!("{}", chunk.text);}
Error Handling
use tenzro::{Error, ApiError};match tenzro.ai().chat().model("gemini-2.5-flash").send().await {Ok(response) => println!("{}", response.response_text),Err(Error::Authentication(msg)) => {eprintln!("Invalid API key: {}", msg);}Err(Error::RateLimit { retry_after }) => {eprintln!("Rate limited, retry after: {:?}", retry_after);}Err(Error::Api(e)) => {eprintln!("API error {}: {}", e.status, e.message);}Err(e) => eprintln!("Error: {}", e),}
Builder Pattern
All operations use the builder pattern for type-safe request construction:
// Configure client with custom settingslet config = TenzroConfig::builder().api_key(api_key).base_url("https://api.tenzro.com").timeout(Duration::from_secs(30)).max_retries(3).build()?;let tenzro = Tenzro::new(config)?;// Fluent API for requestslet response = tenzro.ai().chat().model("gemini-2.5-flash").message("system", "You are a helpful assistant").message("user", "What is Rust?").temperature(0.7).max_tokens(1000).send().await?;
Available Services
| Service | Description |
|---|---|
tenzro.ai() | AI inference (chat, embeddings, multi-modal) |
tenzro.agents() | AI agent orchestration with tools and memory |
tenzro.vec() | Vector database for embeddings and similarity search |
tenzro.kev() | Key-value store for sessions, cache, and state |
tenzro.data() | PostgreSQL databases for structured data |
tenzro.graph() | Graph database for relationships and traversals |
tenzro.files() | Object storage for files and media |
tenzro.workflows() | Visual workflow execution |
tenzro.hub() | Model hub for browsing and downloading models |
tenzro.enclaves() | Secure enclaves for sensitive data |
tenzro.security() | Cryptographic operations and key management |