gemini-live-api

Crates.iogemini-live-api
lib.rsgemini-live-api
version0.1.1
sourcesrc
created_at2025-05-09 20:12:43.052128+00
updated_at2025-05-09 21:36:20.471511+00
descriptionCrate to interact with the Gemini live API
homepage
repository
max_upload_size
id1667617
size159,434
(EstebanForero)

documentation

README

Gemini Live API

crates.io docs.rs License: MIT OR Apache-2.0

A Rust client for real-time, bidirectional communication with Google's Gemini large language models via WebSockets. This crate enables interactive conversations, function calling, and streaming responses, with flexible state management for your application.

It's built on tokio for asynchronous operations and serde for robust JSON handling.

Features

  • Real-time WebSocket Communication: Establishes a persistent WebSocket connection with the Gemini API.
  • Robust Function Calling:
    • Declare tool functions using the #[tool_function] procedural macro.
    • Automatic JSON schema generation for function parameters (derived from function signature).
    • Handles server-side function call requests and sends back responses.
  • Flexible Application State Management:
    • The GeminiLiveClient<S> is generic over a state type S.
    • Your custom state S (wrapped in Arc<S>) is accessible within tool functions and can be captured by event handlers.
    • Supports interior mutability patterns (e.g., Arc<Mutex<T>> within your state S) for concurrent modifications.
  • Event-Driven Architecture:
    • Register asynchronous handlers for server events like on_server_content (for model responses, text, turn completion) and on_usage_metadata.
  • Configurable:
    • Set generation parameters (temperature, max tokens, etc.).
    • Provide system instructions to guide the model's behavior.
  • Typed API: Rust structs for Gemini API requests and responses, ensuring type safety.
  • Asynchronous: Fully async/await based using tokio.
Commit count: 0

cargo fmt