Expand description
§gemini-rust
A Rust client library for Google’s Gemini 2.0 API.
§Crate Organization
This crate is organized into domain-specific modules that align with the Gemini API’s capabilities:
generation
- Content generation, including text, images, and audioembedding
- Text embedding generation for semantic analysisbatch
- Batch processing for multiple requestsfiles
- File upload and managementcache
- Content caching for reusable contextssafety
- Content moderation and safety settingstools
- Function calling and tool integrationmodels
- Core primitive types shared across modulesprelude
- Convenient re-exports of commonly used types
§Quick Start
For most use cases, import from the prelude:
use gemini_rust::prelude::*;
For more specialized types, import them directly from the crate root or their respective modules.
Re-exports§
pub use client::Error as ClientError;
pub use client::Gemini;
pub use client::GeminiBuilder;
pub use client::Model;
pub use generation::builder::ContentBuilder;
pub use generation::model::BlockReason;
pub use generation::model::Candidate;
pub use generation::model::CitationMetadata;
pub use generation::model::CitationSource;
pub use generation::model::FinishReason;
pub use generation::model::GenerateContentRequest;
pub use generation::model::GenerationConfig;
pub use generation::model::GenerationResponse;
pub use generation::model::MultiSpeakerVoiceConfig;
pub use generation::model::PrebuiltVoiceConfig;
pub use generation::model::PromptFeedback;
pub use generation::model::PromptTokenDetails;
pub use generation::model::SpeakerVoiceConfig;
pub use generation::model::SpeechConfig;
pub use generation::model::ThinkingConfig;
pub use generation::model::UsageMetadata;
pub use generation::model::VoiceConfig;
pub use embedding::builder::EmbedBuilder;
pub use embedding::model::BatchContentEmbeddingResponse;
pub use embedding::model::BatchEmbedContentsRequest;
pub use embedding::model::ContentEmbedding;
pub use embedding::model::ContentEmbeddingResponse;
pub use embedding::model::EmbedContentRequest;
pub use embedding::model::TaskType;
pub use safety::model::HarmBlockThreshold;
pub use safety::model::HarmCategory;
pub use safety::model::HarmProbability;
pub use safety::model::SafetyRating;
pub use safety::model::SafetySetting;
pub use tools::model::FunctionCall;
pub use tools::model::FunctionCallingConfig;
pub use tools::model::FunctionCallingMode;
pub use tools::model::FunctionDeclaration;
pub use tools::model::FunctionResponse;
pub use tools::model::Tool;
pub use tools::model::ToolConfig;
pub use batch::builder::BatchBuilder;
pub use batch::handle::BatchGenerationResponseItem;
pub use batch::handle::BatchHandle;
pub use batch::handle::BatchHandle as Batch;
pub use batch::handle::BatchStatus;
pub use batch::handle::Error as BatchHandleError;
pub use batch::model::BatchConfig;
pub use batch::model::BatchGenerateContentRequest;
pub use batch::model::BatchOperation;
pub use batch::model::BatchStats;
pub use batch::model::IndividualRequestError;
pub use batch::model::RequestMetadata;
pub use batch::Error as BatchError;
pub use files::builder::FileBuilder;
pub use files::handle::FileHandle;
pub use files::model::File;
pub use files::model::FileState;
pub use files::Error as FilesError;
pub use cache::builder::CacheBuilder;
pub use cache::handle::CachedContentHandle;
pub use cache::model::CacheExpirationRequest;
pub use cache::model::CacheExpirationResponse;
pub use cache::model::CachedContent;
pub use cache::model::CreateCachedContentRequest;
Modules§
- batch
- Batch processing for multiple generation requests
- cache
- Content caching for reusable contexts and system instructions
- client
- common
- Common utilities and serialization helpers
- embedding
- Text embedding generation for semantic analysis
- files
- File upload and management
- generation
- Content generation including text, images, and audio
- prelude
- Convenient re-exports of commonly used types
- safety
- Content moderation and safety settings
- tools
- Function calling and tool integration
Structs§
- Blob
- Core primitive types for building requests and parsing responses Blob for a message part
- Content
- Core primitive types for building requests and parsing responses Content of a message
- Message
- Core primitive types for building requests and parsing responses Message in a conversation
Enums§
- Modality
- Core primitive types for building requests and parsing responses Content modality type - specifies the format of model output
- Part
- Core primitive types for building requests and parsing responses Content part that can be included in a message
- Role
- Core primitive types for building requests and parsing responses Role of a message in a conversation