google-ai provider supports Google’s generateContent and streamGenerateContent endpoints for Gemini models.
Quick Start
Authentication
Set your Google API key as an environment variable:Configuration Options
BAML-Specific Options
These options modify the API request sent to Google AI.Passed as the
x-goog-api-key header.The base URL for the Google AI API.
Additional headers to send with requests.
Supported Models
The Gemini model to use.
You can specify any model name - BAML won’t validate whether it exists.See the Google Model Documentation for the latest models.
| Model | Use Case | Context | Key Features |
|---|---|---|---|
| gemini-2.5-pro | Complex tasks, coding, STEM | 1M | Adaptive thinking, multimodal |
| gemini-2.5-flash | Production apps, balanced performance | 1M | Best price/performance |
| gemini-2.5-flash-lite | High-volume, cost-sensitive | 1M | Lowest cost, fastest |
Model Parameters
generationConfig parameters:
temperature- Controls randomness (0-2)maxOutputTokens- Maximum tokens to generatetopP- Nucleus sampling parametertopK- Top-k sampling parameterstopSequences- Array of sequences that stop generation
Media Handling
Google AI uses
send_base64_unless_google_url by default for images, which preserves Google Cloud Storage URLs (gs://) while converting other URLs to base64.Features
- Streaming: Automatically uses
streamGenerateContentwhen you call the streaming interface - Multimodal: Supports text, image, audio, and video inputs
- Large Context: Up to 1M tokens context window
- Function Calling: Native support for tool use
Do Not Set
BAML automatically constructs this from your prompt.