The Google Genai Java SDK provides the application-facing path to Gemini communication. Prefer it over hand-built REST handling: explicitly naming the SDK led to a cleaner provider integration and avoided unnecessary custom communication code. section 6.4.3
Use the SDK within a provider boundary rather than coupling application services directly to Gemini:
- Define a LanguageModelClient interface and inject provider-specific implementations. section 6.4.3
- Select the provider through ai.provider, while retaining OpenAI as the configuration default. section 6.4.3
- Avoid silent runtime fallback: provider failures should remain visible so benchmarking metrics are not contaminated by an unmeasured secondary provider. section 6.4.3
Gemini configuration
Configure the API key and model through application properties, for example with GOOGLE_AI_API_KEY and GOOGLE_AI_MODEL environment variables; the documented model default is gemini-2.5-flash. section 6.4.3
Listing 6.20 Setting the Gemini API properties
google:
ai:
api:
key: ${GOOGLE_AI_API_KEY:}
model: ${GOOGLE_AI_MODEL:gemini-2.5-flash} #A
Browse the concrete YAML listing for Gemini API-key and model configuration. section 6.4.3
