Are you sure you want to delete this access key?
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_KEY
pip 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 3
to 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.0-flash-exp
model with various configurations:
providers:
- id: 'google:live:gemini-2.0-flash-exp'
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.
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?