Request structure for batch embedding multiple content items.
Allows generating embeddings for multiple text inputs in a single API call, which is more efficient than individual requests.
Fields
requests: List of individual embed content requests
Examples
%BatchEmbedContentsRequest{
requests: [
%EmbedContentRequest{
model: "models/gemini-embedding-001",
content: %Content{parts: [%Part{text: "First text"}]}
},
%EmbedContentRequest{
model: "models/gemini-embedding-001",
content: %Content{parts: [%Part{text: "Second text"}]}
}
]
}
Summary
Functions
Creates a new batch embedding request from a list of texts.
Converts the batch request to API-compatible map format.
Types
@type t() :: %Gemini.Types.Request.BatchEmbedContentsRequest{ requests: [Gemini.Types.Request.EmbedContentRequest.t()] }
Functions
Creates a new batch embedding request from a list of texts.
Uses auth-aware embedding model selection:
- Gemini API:
gemini-embedding-001with taskType parameter - Vertex AI:
embeddinggemmawith prompt prefix formatting
Parameters
texts: List of text strings to embedopts: Optional keyword list of options to apply to all requests:model: Model to use (default: auto-detected based on auth):task_type: Task type for optimized embeddings:output_dimensionality: Dimension reduction
Examples
BatchEmbedContentsRequest.new([
"What is AI?",
"How does machine learning work?",
"Explain neural networks"
])
BatchEmbedContentsRequest.new(
["Doc 1", "Doc 2"],
task_type: :retrieval_document,
output_dimensionality: 256
)
Converts the batch request to API-compatible map format.