pub struct BatchBuilder { /* private fields */ }
Expand description
A builder for creating and executing synchronous batch content generation requests.
This builder simplifies the process of constructing a batch request, allowing you to
add multiple GenerateContentRequest
items and then execute them as a single
long-running operation.
Implementations§
Source§impl BatchBuilder
impl BatchBuilder
Sourcepub fn with_name(self, name: String) -> Self
pub fn with_name(self, name: String) -> Self
Sets the user-friendly display name for the batch request.
Sourcepub fn with_requests(self, requests: Vec<GenerateContentRequest>) -> Self
pub fn with_requests(self, requests: Vec<GenerateContentRequest>) -> Self
Sets all requests for the batch operation, replacing any existing requests.
Sourcepub fn with_request(self, request: GenerateContentRequest) -> Self
pub fn with_request(self, request: GenerateContentRequest) -> Self
Adds a single GenerateContentRequest
to the batch.
Sourcepub fn build(self) -> BatchGenerateContentRequest
pub fn build(self) -> BatchGenerateContentRequest
Constructs the final BatchGenerateContentRequest
from the builder’s configuration.
This method consumes the builder.
Sourcepub async fn execute(self) -> Result<BatchHandle, Error>
pub async fn execute(self) -> Result<BatchHandle, Error>
Submits the batch request to the Gemini API and returns a Batch
handle.
This method consumes the builder and initiates the long-running batch operation.
Sourcepub async fn execute_as_file(self) -> Result<BatchHandle, Error>
pub async fn execute_as_file(self) -> Result<BatchHandle, Error>
Executes the batch request by first uploading the requests as a JSON file.
This method is ideal for large batch jobs that might exceed inline request limits. It consumes the builder, serializes the requests to the JSON Lines format, uploads the content as a file, and then starts the batch operation using that file.