gemini_rust/lib.rs
1//! # gemini-rust
2//!
3//! A Rust client library for Google's Gemini 2.0 API.
4//!
5//! ## Crate Organization
6//!
7//! This crate is organized into domain-specific modules that align with the Gemini API's
8//! capabilities:
9//!
10//! - **`generation`** - Content generation, including text, images, and audio
11//! - **`embedding`** - Text embedding generation for semantic analysis
12//! - **`batch`** - Batch processing for multiple requests
13//! - **`files`** - File upload and management
14//! - **`cache`** - Content caching for reusable contexts
15//! - **`safety`** - Content moderation and safety settings
16//! - **`tools`** - Function calling and tool integration
17//! - **`models`** - Core primitive types shared across modules
18//! - **`prelude`** - Convenient re-exports of commonly used types
19//!
20//! ## Quick Start
21//!
22//! For most use cases, import from the prelude:
23//!
24//! ```rust
25//! use gemini_rust::prelude::*;
26//! ```
27//!
28//! For more specialized types, import them directly from the crate root or their
29//! respective modules.
30
31mod client;
32mod models;
33
34/// Convenient re-exports of commonly used types
35pub mod prelude;
36
37/// Batch processing for multiple generation requests
38pub mod batch;
39
40/// Content caching for reusable contexts and system instructions
41pub mod cache;
42
43/// Common utilities and serialization helpers
44pub mod common;
45
46/// Text embedding generation for semantic analysis
47pub mod embedding;
48
49/// File upload and management
50pub mod files;
51
52/// Content generation including text, images, and audio
53pub mod generation;
54
55/// Content moderation and safety settings
56pub mod safety;
57
58/// Function calling and tool integration
59pub mod tools;
60
61#[cfg(test)]
62mod tests;
63
64// ========== Core Types ==========
65// These are the fundamental types used throughout the API
66
67/// The main client error type
68pub use client::Error as ClientError;
69/// The main Gemini API client
70pub use client::Gemini;
71/// Available Gemini models
72pub use client::Model;
73
74/// Core primitive types for building requests and parsing responses
75pub use models::{Blob, Content, Message, Modality, Part, Role};
76
77// ========== Content Generation ==========
78// Types for generating text, images, and audio content
79
80pub use generation::{
81 builder::ContentBuilder, model::BlockReason, model::Candidate, model::CitationMetadata,
82 model::CitationSource, model::FinishReason, model::GenerateContentRequest,
83 model::GenerationConfig, model::GenerationResponse, model::MultiSpeakerVoiceConfig,
84 model::PrebuiltVoiceConfig, model::PromptFeedback, model::PromptTokenDetails,
85 model::SpeakerVoiceConfig, model::SpeechConfig, model::ThinkingConfig, model::UsageMetadata,
86 model::VoiceConfig,
87};
88
89// ========== Text Embeddings ==========
90// Types for generating and working with text embeddings
91
92pub use embedding::{
93 builder::EmbedBuilder, model::BatchContentEmbeddingResponse, model::BatchEmbedContentsRequest,
94 model::ContentEmbedding, model::ContentEmbeddingResponse, model::EmbedContentRequest,
95 model::TaskType,
96};
97
98// ========== Safety & Content Filtering ==========
99// Types for content moderation and safety settings
100
101pub use safety::model::{
102 HarmBlockThreshold, HarmCategory, HarmProbability, SafetyRating, SafetySetting,
103};
104
105// ========== Function Calling & Tools ==========
106// Types for integrating external tools and function calling
107
108pub use tools::model::{
109 FunctionCall, FunctionCallingConfig, FunctionCallingMode, FunctionDeclaration,
110 FunctionParameters, FunctionResponse, PropertyDetails, Tool, ToolConfig,
111};
112
113// ========== Batch Processing ==========
114// Types for processing multiple requests in batch operations
115
116pub use batch::{
117 builder::BatchBuilder, handle::BatchGenerationResponseItem, handle::BatchHandle,
118 handle::BatchHandle as Batch, handle::BatchStatus, handle::Error as BatchHandleError,
119 model::BatchConfig, model::BatchGenerateContentRequest, model::BatchOperation,
120 model::BatchStats, model::IndividualRequestError, model::RequestMetadata, Error as BatchError,
121};
122
123// ========== File Management ==========
124// Types for uploading and managing files
125
126pub use files::{
127 builder::FileBuilder, handle::FileHandle, model::File, model::FileState, Error as FilesError,
128};
129
130// ========== Content Caching ==========
131// Types for caching contexts and system instructions
132
133pub use cache::{
134 builder::CacheBuilder, handle::CachedContentHandle, model::CacheExpirationRequest,
135 model::CacheExpirationResponse, model::CachedContent, model::CreateCachedContentRequest,
136};