Skip to main content

Google AI

The google-ai provider supports Google's Gemini models via the Generative Language API.

tip

BAML automatically selects streamGenerateContent when using the streaming interface.

Basic Example​

client<llm> MyClient {
provider google-ai
options {
model "gemini-2.5-flash"
}
}

BAML-Specific Options​

OptionTypeDefaultDescription
api_keystringenv.GOOGLE_API_KEYAPI key
base_urlstringhttps://generativelanguage.googleapis.com/v1betaBase URL
modelstringgemini-2.5-flashModel identifier
headersobject-Additional headers

Available Models​

ModelUse CaseContextFeatures
gemini-2.5-proComplex tasks, coding, STEM1MAdaptive thinking, multimodal
gemini-2.5-flashProduction apps, balanced1MBest price/performance
gemini-2.5-flash-liteHigh-volume, cost-sensitive1MLowest cost, fastest

See the Google Model Docs for the latest models.

Configuration Example​

tip

Parameters like temperature for Gemini models are specified in the generationConfig object.

client<llm> MyClient {
provider google-ai
options {
model "gemini-2.5-flash"
headers {
"X-My-Header" "my-value"
}
generationConfig {
temperature 0.5
}
}
}

Provider Parameters​

OptionTypeDescription
generationConfigobjectGeneration settings (temperature, maxOutputTokens, etc.)
safetySettingsarraySafety filter configuration
note

Google AI uses send_base64_unless_google_url by default for images, preserving Google Cloud Storage URLs (gs://) while converting other URLs to base64.

See the Google Gemini API documentation for all options.

See Also​