gemini_chat
Generate text using Google's Gemini AI models through the Gemini API.
Overview
Generate text using Google's Gemini AI models through the Gemini API. This step provides access to Google's Gemini family of models including Gemini Pro and Gemini Pro Vision (for multimodal tasks). Gemini offers strong performance across text generation, code, reasoning, and analysis tasks. You can customize system instructions, control generation parameters (temperature, top_p, top_k), set token limits, and configure safety settings. The step tracks usage statistics for monitoring costs. Ideal for content generation, question answering, summarization, translation, and creative applications.
Quick Start
steps:
- type: gemini_chat
api_key: AIzaSyA-REDACTED123
model: gemini-1.5-flashConfiguration
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key | string | Yes | Google API key appended to each request as the 'key' query parameter. |
model | string | Yes | Gemini model identifier (for example 'gemini-1.5-flash'). |
input_key | string | No | Dot path for the user message content. When omitted, the entire event is serialized to JSON. |
system | string | No | Static system instruction applied when 'system_key' does not resolve. |
system_key | string | No | Dot path whose value overrides the static 'system' instruction when present. |
output_key | string | No | Event key storing primary response text.
Default: "gemini" |
include_usage | boolean | No | When True, usage metadata is stored under '<output_key>_usage'.
Default: true |
temperature | string | No | Sampling temperature (0.0-1.0). Lower values bias toward deterministic output. |
max_output_tokens | string | No | Maximum number of tokens Gemini should generate (if supported by the model). |
top_p | string | No | Nucleus sampling probability cutoff expressed as a 0-1 float. |
top_k | string | No | Top-K sampling cutoff controlling the number of candidate tokens considered. |
safety_settings | string | No | List of safety settings dictionaries forwarded verbatim to the Gemini API. |
base_url | string | No | Base endpoint URL for the Gemini API; override when routing through a proxy.
Default: "https://generativelanguage.googleapis.com" |
raw_on_error | boolean | No | When True, preserve the raw response text under '<output_key>_raw' if parsing fails.
Default: true |
swallow_on_error | boolean | No | If True, skip injecting error details and return the original event on failures.
Default: false |
extra_headers | string | No | Additional HTTP headers merged into each request alongside the defaults (Content-Type, Accept, User-Agent). |
Examples
Basic text generation
Simple prompt completion with Gemini Pro
type: gemini_chat
api_key: ${env:gemini_api_key}
model: gemini-pro
input_from: user_prompt
output_to: ai_response
Customer service assistant
Specialized assistant with system instructions
type: gemini_chat
api_key: ${env:gemini_api_key}
model: gemini-pro
system: You are a helpful customer service assistant for an e-commerce platform. Be professional, empathetic, and solution-oriented.
input_from: customer_inquiry
output_to: service_response
temperature: 0.7
max_output_tokens: 500
Creative content generation
High temperature for creative, diverse outputs
type: gemini_chat
api_key: ${env:gemini_api_key}
model: gemini-pro
system: You are a creative content writer. Generate engaging, original content.
input_from: content_brief
output_to: generated_content
temperature: 0.9
top_p: 0.95
top_k: 40
max_output_tokens: 2048
Precise information extraction
Low temperature for consistent, factual outputs
type: gemini_chat
api_key: ${env:gemini_api_key}
model: gemini-pro
system: Extract key facts and data points from the text. Be precise and factual.
input_from: document
output_to: extracted_facts
temperature: 0.1
max_output_tokens: 1000
include_usage: true
Advanced Options
These options are available on all steps for error handling and retry logic:
| Parameter | Type | Default | Description |
|---|---|---|---|
retries | integer | 0 | Number of retry attempts (0-10) |
backoff_seconds | number | 0 | Backoff (seconds) applied between retry attempts |
retry_propagate | boolean | false | If True, raise last exception after exhausting retries; otherwise swallow. |