Skip to content

Conversation

@jgonzalezd
Copy link

Summary

This PR improves compatibility between Google AI Studio (Gemini API) and Vertex AI by making configuration parameters conditional based on the API provider being used.

Changes

1. Added missing APP_NAME environment variable to .env template

  • Added APP_NAME to both Google AI Studio and Vertex AI .env template examples in README
  • This variable is required for session management but was missing from the boilerplate

2. Made SessionResumptionConfig.transparent conditional on API provider

  • The transparent parameter is supported by Vertex AI but not by the Gemini API
  • Added conditional logic in server/main.py to enable transparent=True only when using Vertex AI
  • Prevents errors when using Google AI Studio while preserving functionality for Vertex AI users

3. Made model name selection conditional on API provider

  • Model naming conventions differ between providers:
    • Vertex AI: gemini-live-2.5-flash-preview-native-audio (with "live" prefix)
    • Gemini API: gemini-2.5-flash-native-audio-preview-12-2025 (with date suffix)
  • Extracted model selection logic into _get_model_name() helper function with proper type hints
  • Improved code organization with constants and documentation
  • Automatically selects the correct model based on GOOGLE_GENAI_USE_VERTEXAI environment variable

Benefits

  • ✅ Works seamlessly with both Google AI Studio and Vertex AI without code changes
  • ✅ Eliminates configuration errors when switching between providers
  • ✅ Better code organization and maintainability
  • ✅ Proper documentation of provider-specific differences

@google-cla
Copy link

google-cla bot commented Dec 30, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Extract model name selection logic into a helper function that
chooses the appropriate model based on GOOGLE_GENAI_USE_VERTEXAI.
Improve code organization with constants and proper type hints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant