examples/google-live/README.md
You can run this example with:
npx promptfoo@latest init --example google-live
cd google-live
This example demonstrates how to use promptfoo with Google's WebSocket-based Live API, which enables low-latency bidirectional interactions with Gemini models. The example includes four different configurations:
npm install -g promptfoo or brew install promptfoo)GOOGLE_API_KEYpip install flask)You can obtain a Google AI Studio API key from the Google AI Studio website.
You can initialize this example with:
npx promptfoo@latest init --example google-live
This will create a directory with all necessary configuration files. After running any evaluation, you can view the results by running:
promptfoo view
The basic configuration in promptfooconfig.yaml demonstrates a simple query to the Gemini model:
promptfoo eval -c promptfooconfig.yaml -j 3
Note: Rate limits of 3 concurrent sessions per API key apply, which is why we use
-j 3to limit concurrency.
The multiline configuration in promptfooconfig.multiline.yaml demonstrates a multi-turn conversation:
promptfoo eval -c promptfooconfig.multiline.yaml -j 3
The tools configuration in promptfooconfig.tools.yaml demonstrates function calling (where the model can invoke defined functions) and built-in tools like Google Search and code execution:
promptfoo eval -c promptfooconfig.tools.yaml -j 3
This example runs a local Python API that maintains state between function calls:
promptfoo eval -c promptfooconfig.statefulapi.yaml -j 3
Setup:
pip install flask)python3 command by defaultpythonExecutable in config or use PROMPTFOO_PYTHON environment variableIf you encounter errors, check that:
All examples use the google:live:gemini-2.5-flash-native-audio-preview-12-2025 model with various configurations:
providers:
# Using gemini-2.5-flash-native-audio for Live API (supports both text and audio)
- id: 'google:live:gemini-2.5-flash-native-audio-preview-12-2025'
config:
generationConfig:
response_modalities: ['text']
timeoutMs: 10000
The function calling examples use JSON configuration files that define:
For the stateful API, counter_api.py implements a simple counter service with endpoints for adding to and retrieving a count value.
For more information about the Google Live API and other Google AI models, see the Google AI documentation.