adk_gemini/lib.rs
1//! # adk-gemini
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 adk_gemini::prelude::*;
26//! ```
27//!
28//! For more specialized types, import them directly from the crate root or their
29//! respective modules.
30
31pub mod backend;
32pub mod client;
33pub mod model_info;
34mod models;
35pub mod pricing;
36
37/// Convenient re-exports of commonly used types
38pub mod prelude;
39
40/// Batch processing for multiple generation requests
41pub mod batch;
42
43/// Content caching for reusable contexts and system instructions
44pub mod cache;
45
46/// Common utilities and serialization helpers
47pub mod common;
48
49/// Text embedding generation for semantic analysis
50pub mod embedding;
51
52/// File upload and management
53pub mod files;
54
55/// Content generation including text, images, and audio
56pub mod generation;
57
58/// Content moderation and safety settings
59pub mod safety;
60
61/// Function calling and tool integration
62pub mod tools;
63
64#[cfg(test)]
65mod tests;
66
67#[cfg(test)]
68mod response_parsing_tests;
69
70// ========== Core Types ==========
71// These are the fundamental types used throughout the API
72
73/// The main client error type
74pub use client::Error as ClientError;
75/// The main Gemini API client
76pub use client::Gemini;
77/// Builder for creating a new Gemini client
78pub use client::GeminiBuilder;
79/// Available Gemini models
80pub use client::Model;
81
82/// Core primitive types for building requests and parsing responses
83pub use models::{Blob, Content, FileDataRef, Message, Modality, Part, Role};
84
85// ========== Content Generation ==========
86// Types for generating text, images, and audio content
87
88pub use generation::{
89 builder::ContentBuilder, model::BlockReason, model::Candidate, model::CitationMetadata,
90 model::CitationSource, model::FinishReason, model::GenerateContentRequest,
91 model::GenerationConfig, model::GenerationResponse, model::GroundingChunk,
92 model::GroundingMetadata, model::GroundingSegment, model::GroundingSupport,
93 model::MultiSpeakerVoiceConfig, model::PrebuiltVoiceConfig, model::PromptFeedback,
94 model::PromptTokenDetails, model::SpeakerVoiceConfig, model::SpeechConfig,
95 model::ThinkingConfig, model::ThinkingLevel, model::UsageMetadata, model::VoiceConfig,
96 model::WebGroundingChunk,
97};
98
99// ========== Text Embeddings ==========
100// Types for generating and working with text embeddings
101
102pub use embedding::{
103 builder::EmbedBuilder, model::BatchContentEmbeddingResponse, model::BatchEmbedContentsRequest,
104 model::ContentEmbedding, model::ContentEmbeddingResponse, model::EmbedContentRequest,
105 model::TaskType,
106};
107
108// ========== Safety & Content Filtering ==========
109// Types for content moderation and safety settings
110
111pub use safety::model::{
112 HarmBlockThreshold, HarmCategory, HarmProbability, SafetyRating, SafetySetting,
113};
114
115// ========== Function Calling & Tools ==========
116// Types for integrating external tools and function calling
117
118pub use tools::model::{
119 FunctionCall, FunctionCallingConfig, FunctionCallingMode, FunctionDeclaration,
120 FunctionResponse, FunctionResponsePart, Tool, ToolConfig,
121};
122
123// ========== Batch Processing ==========
124// Types for processing multiple requests in batch operations
125
126pub use batch::{
127 Error as BatchError, builder::BatchBuilder, handle::BatchGenerationResponseItem,
128 handle::BatchHandle, handle::BatchHandle as Batch, handle::BatchStatus,
129 handle::Error as BatchHandleError, model::BatchConfig, model::BatchGenerateContentRequest,
130 model::BatchOperation, model::BatchStats, model::IndividualRequestError,
131 model::RequestMetadata,
132};
133
134// ========== File Management ==========
135// Types for uploading and managing files
136
137pub use files::{
138 Error as FilesError, builder::FileBuilder, handle::FileHandle, model::File, model::FileState,
139};
140
141// ========== Content Caching ==========
142// Types for caching contexts and system instructions
143
144pub use cache::{
145 builder::CacheBuilder, handle::CachedContentHandle, model::CacheExpirationRequest,
146 model::CacheExpirationResponse, model::CachedContent, model::CreateCachedContentRequest,
147};
148
149// ========== Pricing ==========
150// Token cost estimation for Gemini models
151
152pub use pricing::{CostBreakdown, GeminiPricing, estimate_cost, estimate_cost_long};