ExLLM.Gemini.Content (ex_llm v0.5.0)
View SourceGoogle Gemini Content Generation API implementation.
Provides functionality for generating content using Gemini models including text generation, streaming, multimodal inputs, function calling, and structured outputs.
Summary
Functions
Converts Content struct to JSON format for API requests.
Generates content using a Gemini model.
Streams content generation using a Gemini model.
Types
Functions
@spec content_to_json(ExLLM.Gemini.Content.Content.t()) :: map()
Converts Content struct to JSON format for API requests.
@spec generate_content( String.t(), ExLLM.Gemini.Content.GenerateContentRequest.t(), options() ) :: {:ok, ExLLM.Gemini.Content.GenerateContentResponse.t()} | {:error, term()}
Generates content using a Gemini model.
Parameters
model
- The model name (e.g., "gemini-2.0-flash")request
- A GenerateContentRequest structopts
- Options including:config_provider
Examples
request = %GenerateContentRequest{
contents: [
%Content{
role: "user",
parts: [%Part{text: "Hello!"}]
}
]
}
{:ok, response} = ExLLM.Gemini.Content.generate_content("gemini-2.0-flash", request)
@spec stream_generate_content( String.t(), ExLLM.Gemini.Content.GenerateContentRequest.t(), options() ) :: {:ok, Enumerable.t()} | {:error, term()}
Streams content generation using a Gemini model.
Returns a stream of GenerateContentResponse chunks.