Skip to main content

Crate adk_gemini

Crate adk_gemini 

Source
Expand description

§adk-gemini

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 audio
  • embedding - Text embedding generation for semantic analysis
  • batch - Batch processing for multiple requests
  • files - File upload and management
  • cache - Content caching for reusable contexts
  • safety - Content moderation and safety settings
  • tools - Function calling and tool integration
  • models - Core primitive types shared across modules
  • prelude - Convenient re-exports of commonly used types

§Quick Start

For most use cases, import from the prelude:

use adk_gemini::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::GroundingChunk;
pub use generation::model::GroundingMetadata;
pub use generation::model::GroundingSegment;
pub use generation::model::GroundingSupport;
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::ThinkingLevel;
pub use generation::model::UsageMetadata;
pub use generation::model::VoiceConfig;
pub use generation::model::WebGroundingChunk;
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::FunctionResponsePart;
pub use tools::model::Tool;
pub use tools::model::ToolConfig;
pub use batch::Error as BatchError;
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 files::Error as FilesError;
pub use files::builder::FileBuilder;
pub use files::handle::FileHandle;
pub use files::model::File;
pub use files::model::FileState;
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;
pub use pricing::CostBreakdown;
pub use pricing::GeminiPricing;
pub use pricing::estimate_cost;
pub use pricing::estimate_cost_long;
pub use schema_adapter::GeminiSchemaAdapter;

Modules§

backend
Backend abstraction for Gemini API providers (AI Studio REST vs Vertex AI). Backend abstraction for Gemini API providers.
batch
Batch processing for multiple generation requests Batch processing for multiple generation requests.
cache
Content caching for reusable contexts and system instructions Content caching for reusable contexts and system instructions.
client
Gemini API client, builder, model enum, and error types.
common
Common utilities and serialization helpers
embedding
Text embedding generation for semantic analysis
files
File upload and management File upload and management for the Gemini API.
generation
Content generation including text, images, and audio Content generation including text, images, and audio.
model_info
Model metadata discovery (list/get model info). Types for the Gemini Models API (models.list and models.get).
prelude
Convenient re-exports of commonly used types
pricing
Token cost estimation for Gemini models. Token pricing for Gemini models.
safety
Content moderation and safety settings Content moderation and safety settings for the Gemini API.
schema_adapter
Provider-specific schema normalization for Gemini function-calling API. Gemini-specific schema normalization adapter.
tools
Function calling and tool integration Function calling and tool integration for the Gemini API.

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
FileDataRef
Core primitive types for building requests and parsing responses Reference to an external file by URI, used in Gemini wire format.
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