HTTP service for the Gemini embeddings API.
Gemini's embedding models express the task in two incompatible ways, so the model name selects a family:
:task_type(gemini-embedding-001,text-embedding-004) - the task is ataskTypeenum field on the request, and truncated output is not normalized, so it is scaled client-side.:prefix(gemini-embedding-2) - there is notaskTypefield; the task is written into the text itself, and truncated output is self-normalizing.
Requests always go through batchEmbedContents with one Content per input.
A flat multi-input list returns a single aggregated vector on
gemini-embedding-2, which would silently corrupt an entire index.
Summary
Functions
@spec embed(ExAgent.Providers.Gemini.t(), [ExAgent.Embeddings.input()], keyword()) :: {:ok, ExAgent.Embeddings.t()} | {:error, ExAgent.Error.t()}
Generates embeddings for inputs.
Options
:model- defaults to"gemini-embedding-001". Never the provider's chat model.:dimensions- setsoutputDimensionality:task- one of[:retrieval_query, :retrieval_document, :similarity, :classification, :clustering, :question_answering, :fact_verification, :code_query]:embedding_family-:task_typeor:prefix, to use a model this library does not know yet:args- Gemini exposes nothing beyond the above, so any key here is rejected rather than silently ignored by the API:receive_timeout- milliseconds to wait for the response; defaults to the provider's:receive_timeout
@spec tasks() :: [ExAgent.Embeddings.task()]
Returns the task atoms this service accepts.