Language: 中文 | English
用于 Google Gemini API 和 Vertex AI 的 Rust SDK。本项目致力于与官方 Go、JavaScript、Python SDK 保持功能对齐,同时充分利用 Rust 的安全性和性能优势。
- 基于 Tokio 的异步优先客户端
- 支持 Gemini API 和 Vertex AI 后端
- Models、Chats、Files、Caches、Batches、Operations API
- 流式响应(SSE)
- 函数调用和工具系统
- 自动函数调用(AFC)与可调用工具
- Live API、会话恢复、Live Music(实验性)
- Interactions API(Beta)和 Deep Research(Preview)
- Grounding 元数据、logprobs、媒体分辨率设置
- Count/Compute Tokens (Vertex AI) + 可选本地估算(feature:
kitoken) - Recontext / Segment Image (Vertex AI)
- MCP 支持(feature:
mcp,实验性)
| Feature | MSRV |
|---|---|
默认(无 mcp) |
Rust 1.88+ |
启用 mcp feature |
Rust 1.88+ |
当前 MSRV 为 Rust 1.88+;mcp feature 同样需要 1.88+(上游依赖 rmcp → darling)。
[dependencies]
rust-genai = "0.1.1"use rust_genai::Client;
use rust_genai::types::content::Content;
#[tokio::main]
async fn main() -> rust_genai::Result<()> {
let client = Client::from_env()?;
let response = client
.models()
.generate_content("gemini-2.5-flash", vec![Content::text("你好,Rust!")])
.await?;
println!("{response:?}");
Ok(())
}- 快速开始:
docs/getting-started.md - 最佳实践:
docs/best-practices.md - MCP:
docs/mcp.md - 发布流程:
docs/release.md - API 文档:
cargo doc --open
查看 rust-genai/examples/ 目录,涵盖核心功能、错误处理、性能与 Live Music。
rust-genai:主客户端 crate(公共 API)rust-genai-types:共享类型定义rust-genai-macros:过程宏
Apache-2.0。详见 LICENSE。
Language: 中文 | English
Rust SDK for the Google Gemini API and Vertex AI. This workspace aims to stay feature-aligned with the official Go, JavaScript, and Python SDKs while taking advantage of Rust's safety and performance.
- Async-first client with Tokio
- Gemini API and Vertex AI backends
- Models, Chats, Files, Caches, Batches, Operations
- Streaming (SSE)
- Function calling and tool system
- Automatic function calling (AFC) with callable tools
- Live API, session resumption, and Live Music (experimental)
- Interactions API (Beta) and Deep Research (Preview)
- Grounding metadata, logprobs, and media resolution
- Count/Compute Tokens (Vertex AI) + optional local estimation (feature:
kitoken) - Recontext / Segment Image (Vertex AI)
- MCP support (feature:
mcp, experimental)
| Feature | MSRV |
|---|---|
Default (no mcp) |
Rust 1.88+ |
With mcp feature |
Rust 1.88+ |
Current MSRV is Rust 1.88+; the mcp feature also requires 1.88+ due to upstream dependencies (rmcp → darling).
[dependencies]
rust-genai = "0.1.1"use rust_genai::Client;
use rust_genai::types::content::Content;
#[tokio::main]
async fn main() -> rust_genai::Result<()> {
let client = Client::from_env()?;
let response = client
.models()
.generate_content("gemini-2.5-flash", vec![Content::text("Hello from Rust!")])
.await?;
println!("{response:?}");
Ok(())
}- Getting Started:
docs/getting-started.md - Best Practices:
docs/best-practices.md - MCP:
docs/mcp.md - Release Flow:
docs/release.md - API Reference:
cargo doc --open
See rust-genai/examples/ for core features, error handling, performance, and Live Music.
rust-genai: main client crate (public API)rust-genai-types: shared type definitionsrust-genai-macros: procedural macros
Apache-2.0. See LICENSE.