Gemini.Types.Request.GenerateContentRequest (GeminiEx v0.2.1)
View SourceRequest structure for content generation.
Supports all generation parameters including safety settings, system instructions, tools, and generation configuration.
Summary
Functions
Create a new GenerateContentRequest with validation.
Convert request to map suitable for JSON encoding.
Types
@type t() :: %Gemini.Types.Request.GenerateContentRequest{ contents: [Gemini.Types.Content.t()], generation_config: Gemini.Types.GenerationConfig.t() | nil, safety_settings: [Gemini.Types.SafetySetting.t()], system_instruction: Gemini.Types.Content.t() | nil, tool_config: map() | nil, tools: [map()] }
Functions
@spec new( String.t() | [Gemini.Types.Content.t()], keyword() ) :: {:ok, t()} | {:error, String.t()}
Create a new GenerateContentRequest with validation.
Parameters
contents
- List of Content structs or single stringopts
- Keyword list of options::generation_config
- GenerationConfig struct:safety_settings
- List of SafetySetting structs:system_instruction
- System instruction as Content or string:tools
- List of tool definitions:tool_config
- Tool configuration
Examples
iex> GenerateContentRequest.new("Hello world")
{:ok, %GenerateContentRequest{contents: [%Content{...}]}}
iex> GenerateContentRequest.new([Content.text("Hello")])
{:ok, %GenerateContentRequest{...}}
Convert request to map suitable for JSON encoding.
Removes nil fields to create clean JSON payload.