pub struct GeminiModel { /* private fields */ }gemini only.Expand description
Gemini model client wrapping the adk-gemini crate for the Llm trait.
Implementations§
Source§impl GeminiModel
impl GeminiModel
Sourcepub fn new(
api_key: impl Into<String>,
model: impl Into<String>,
) -> Result<GeminiModel, AdkError>
Available on crate feature models only.
pub fn new( api_key: impl Into<String>, model: impl Into<String>, ) -> Result<GeminiModel, AdkError>
models only.Create a new Gemini model client with an API key and model name.
Sourcepub fn with_retry_config(self, retry_config: RetryConfig) -> GeminiModel
Available on crate feature models only.
pub fn with_retry_config(self, retry_config: RetryConfig) -> GeminiModel
models only.Set the retry configuration (builder pattern).
Sourcepub fn set_retry_config(&mut self, retry_config: RetryConfig)
Available on crate feature models only.
pub fn set_retry_config(&mut self, retry_config: RetryConfig)
models only.Set the retry configuration (mutable reference).
Sourcepub fn retry_config(&self) -> &RetryConfig
Available on crate feature models only.
pub fn retry_config(&self) -> &RetryConfig
models only.Returns the current retry configuration.
Sourcepub fn with_thinking_config(
self,
thinking_config: ThinkingConfig,
) -> GeminiModel
Available on crate feature models only.
pub fn with_thinking_config( self, thinking_config: ThinkingConfig, ) -> GeminiModel
models only.Set the default thinking configuration applied to every request.
Controls the model’s reasoning effort. For Gemini 3 series models,
use ThinkingLevel (Low/Medium/High). For Gemini 2.5 series, use
thinking_budget (token count).
§Example
use adk_gemini::{ThinkingConfig, ThinkingLevel};
// Gemini 3 — level-based thinking
let model = GeminiModel::new(api_key, "gemini-3.1-pro-preview")?
.with_thinking_config(
ThinkingConfig::new().with_thinking_level(ThinkingLevel::Low)
);
// Gemini 2.5 — budget-based thinking
let model = GeminiModel::new(api_key, "gemini-2.5-flash")?
.with_thinking_config(
ThinkingConfig::new().with_thinking_budget(2048)
);Sourcepub fn set_thinking_config(&mut self, thinking_config: ThinkingConfig)
Available on crate feature models only.
pub fn set_thinking_config(&mut self, thinking_config: ThinkingConfig)
models only.Set the thinking configuration (mutable reference variant).
Sourcepub fn thinking_config(&self) -> Option<&ThinkingConfig>
Available on crate feature models only.
pub fn thinking_config(&self) -> Option<&ThinkingConfig>
models only.Returns the current thinking configuration, if set.
Sourcepub async fn create_cached_content(
&self,
system_instruction: &str,
tools: &HashMap<String, Value>,
ttl_seconds: u32,
) -> Result<String, AdkError>
Available on crate feature models only.
pub async fn create_cached_content( &self, system_instruction: &str, tools: &HashMap<String, Value>, ttl_seconds: u32, ) -> Result<String, AdkError>
models only.Create a cached content resource with the given system instruction, tools, and TTL.
Returns the cache name (e.g., “cachedContents/abc123”) on success.
The cache is created using the model configured on this GeminiModel instance.