pub struct ContentBuilder {
pub contents: Vec<Content>,
/* private fields */
}
Expand description
Builder for content generation requests
Fields§
§contents: Vec<Content>
Implementations§
Source§impl ContentBuilder
impl ContentBuilder
Sourcepub fn with_system_prompt(self, text: impl Into<String>) -> Self
pub fn with_system_prompt(self, text: impl Into<String>) -> Self
Add a system prompt to the request
Sourcepub fn with_system_instruction(self, text: impl Into<String>) -> Self
pub fn with_system_instruction(self, text: impl Into<String>) -> Self
Set the system instruction directly (matching the API format in the curl example)
Sourcepub fn with_user_message(self, text: impl Into<String>) -> Self
pub fn with_user_message(self, text: impl Into<String>) -> Self
Add a user message to the request
Sourcepub fn with_model_message(self, text: impl Into<String>) -> Self
pub fn with_model_message(self, text: impl Into<String>) -> Self
Add a model message to the request
Sourcepub fn with_inline_data(
self,
data: impl Into<String>,
mime_type: impl Into<String>,
) -> Self
pub fn with_inline_data( self, data: impl Into<String>, mime_type: impl Into<String>, ) -> Self
Add a inline data (blob data) to the request
Sourcepub fn with_function_response(
self,
name: impl Into<String>,
response: Value,
) -> Self
pub fn with_function_response( self, name: impl Into<String>, response: Value, ) -> Self
Add a function response to the request using a JSON value
Sourcepub fn with_function_response_str(
self,
name: impl Into<String>,
response: impl Into<String>,
) -> Result<Self, Error>
pub fn with_function_response_str( self, name: impl Into<String>, response: impl Into<String>, ) -> Result<Self, Error>
Add a function response to the request using a JSON string
Sourcepub fn with_message(self, message: Message) -> Self
pub fn with_message(self, message: Message) -> Self
Add a message to the request
Sourcepub fn with_messages(self, messages: impl IntoIterator<Item = Message>) -> Self
pub fn with_messages(self, messages: impl IntoIterator<Item = Message>) -> Self
Add multiple messages to the request
Sourcepub fn with_generation_config(self, config: GenerationConfig) -> Self
pub fn with_generation_config(self, config: GenerationConfig) -> Self
Set the generation config for the request
Sourcepub fn with_temperature(self, temperature: f32) -> Self
pub fn with_temperature(self, temperature: f32) -> Self
Set the temperature for the request
Sourcepub fn with_top_p(self, top_p: f32) -> Self
pub fn with_top_p(self, top_p: f32) -> Self
Set the top-p value for the request
Sourcepub fn with_top_k(self, top_k: i32) -> Self
pub fn with_top_k(self, top_k: i32) -> Self
Set the top-k value for the request
Sourcepub fn with_max_output_tokens(self, max_output_tokens: i32) -> Self
pub fn with_max_output_tokens(self, max_output_tokens: i32) -> Self
Set the maximum output tokens for the request
Sourcepub fn with_candidate_count(self, candidate_count: i32) -> Self
pub fn with_candidate_count(self, candidate_count: i32) -> Self
Set the candidate count for the request
Sourcepub fn with_stop_sequences(self, stop_sequences: Vec<String>) -> Self
pub fn with_stop_sequences(self, stop_sequences: Vec<String>) -> Self
Set the stop sequences for the request
Sourcepub fn with_response_mime_type(self, mime_type: impl Into<String>) -> Self
pub fn with_response_mime_type(self, mime_type: impl Into<String>) -> Self
Set the response mime type for the request
Sourcepub fn with_response_schema(self, schema: Value) -> Self
pub fn with_response_schema(self, schema: Value) -> Self
Set the response schema for structured output
Sourcepub fn with_function(self, function: FunctionDeclaration) -> Self
pub fn with_function(self, function: FunctionDeclaration) -> Self
Add a function declaration as a tool
Sourcepub fn with_function_calling_mode(self, mode: FunctionCallingMode) -> Self
pub fn with_function_calling_mode(self, mode: FunctionCallingMode) -> Self
Set the function calling mode for the request
Sourcepub fn with_thinking_config(self, thinking_config: ThinkingConfig) -> Self
pub fn with_thinking_config(self, thinking_config: ThinkingConfig) -> Self
Set the thinking configuration for the request (Gemini 2.5 series only)
Sourcepub fn with_thinking_budget(self, budget: i32) -> Self
pub fn with_thinking_budget(self, budget: i32) -> Self
Set the thinking budget for the request (Gemini 2.5 series only)
Sourcepub fn with_dynamic_thinking(self) -> Self
pub fn with_dynamic_thinking(self) -> Self
Enable dynamic thinking (model decides the budget) (Gemini 2.5 series only)
Sourcepub fn with_thoughts_included(self, include: bool) -> Self
pub fn with_thoughts_included(self, include: bool) -> Self
Include thought summaries in the response (Gemini 2.5 series only)
pub fn build(self) -> GenerateContentRequest
Sourcepub async fn execute(self) -> Result<GenerationResponse>
pub async fn execute(self) -> Result<GenerationResponse>
Execute the request
Sourcepub async fn execute_stream(
self,
) -> Result<Pin<Box<dyn Stream<Item = Result<GenerationResponse>> + Send>>>
pub async fn execute_stream( self, ) -> Result<Pin<Box<dyn Stream<Item = Result<GenerationResponse>> + Send>>>
Execute the request with streaming