Gemini.Types.Request.BatchEmbedContentsRequest (GeminiEx v0.10.0)

Copy Markdown View Source

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

t()

@type t() :: %Gemini.Types.Request.BatchEmbedContentsRequest{
  requests: [Gemini.Types.Request.EmbedContentRequest.t()]
}

Functions

new(texts, opts \\ [])

@spec new(
  [String.t()],
  keyword()
) :: t()

Creates a new batch embedding request from a list of texts.

Uses auth-aware embedding model selection:

  • Gemini API: gemini-embedding-001 with taskType parameter
  • Vertex AI: embeddinggemma with prompt prefix formatting

Parameters

  • texts: List of text strings to embed
  • opts: 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
)

to_api_map(batch_embed_contents_request)

@spec to_api_map(t()) :: map()

Converts the batch request to API-compatible map format.