Evaluate Voice AI Conversations
Prompt chain demonstrating xAI Grok Voice Agent API evaluation with promptfoo for testing real-time voice AI conversation workflows.
Why it matters
Evaluate real-time voice AI conversations using xAI's Grok Voice Agent API. This asset helps assess the performance and quality of voice-based AI interactions.
Outcomes
What it gets done
Integrate with xAI Grok Voice Agent API
Evaluate voice AI conversation quality
Automate voice AI performance testing
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/pfoo-voice | bash Capabilities
What this chain does
Handles multi-turn conversations within a defined domain.
Converts audio or video speech to written text.
Condenses long documents or threads into key takeaways.
Overview
Voice
What it does
This prompt chain integrates xAI's Grok Voice Agent API with promptfoo to enable systematic evaluation of real-time voice AI conversations. It provides a structured workflow for testing voice interaction quality, response accuracy, and conversational behavior through promptfoo's evaluation framework.
How it connects
Use this when you need to test and validate voice AI implementations built on xAI's Grok Voice Agent API. It fits scenarios where you're developing conversational voice applications and require repeatable, automated testing of voice interaction quality before production deployment.
Source README
xai/voice (xAI Grok Voice Agent)
This example demonstrates how to use xAI's Grok Voice Agent API with promptfoo for evaluating real-time voice AI conversations.
Prerequisites
- An xAI API key with access to the Voice Agent API
- Set
XAI_API_KEYenvironment variable
Setup
npx promptfoo@latest init --example xai/voice
cd xai/voice
export XAI_API_KEY=your-api-key
Run
npx promptfoo@latest eval
Configuration Options
Models
grok-voice-think-fast-1.0- The voice model documented by xAI's Voice Agent API guide. The model is selected via the?model=query parameter on the realtime WebSocket URL.
Voices
xAI Voice supports 5 different voices:
Ara(default) - Female voiceRex- Male voiceSal- Male voiceEve- Female voiceLeo- Male voice
Built-in Tools
The Voice API includes several built-in tools:
web_search- Search the web for informationx_search- Search posts on X (Twitter)file_search- Search uploaded files in vector stores
Custom Functions
You can define custom function tools that the voice agent can call. Tools can be defined inline or loaded from external files:
Inline definition:
tools:
- type: function
name: get_weather
description: Get the current weather for a location
parameters:
type: object
properties:
location:
type: string
description: The city and state
required: ['location']
Load from external file:
# promptfooconfig.yaml
config:
tools: file://tools.yaml
# tools.yaml
- type: function
name: get_weather
description: Get the current weather for a location
parameters:
type: object
properties:
location:
type: string
description: The city and state
required:
- location
- type: function
name: set_reminder
description: Set a reminder for the user
parameters:
type: object
properties:
message:
type: string
time:
type: string
required:
- message
- time
External files can be YAML or JSON format.
Audio Configuration
Configure input/output audio formats:
config:
audio:
input:
format:
type: audio/pcm
rate: 24000
output:
format:
type: audio/pcm
rate: 24000
Supported formats: audio/pcm, audio/pcmu, audio/pcma
Supported sample rates: 8000, 16000, 22050, 24000, 32000, 44100, 48000 Hz
Custom WebSocket URL
For local testing, proxies, or endpoints with query parameters:
config:
websocketUrl: 'wss://custom-endpoint.example.com/path?token=xyz'
Function Call Assertions
When using custom function tools, you can assert on the function calls:
tests:
- vars:
question: 'Set the volume to 50%'
assert:
- type: javascript
value: |
const calls = output.functionCalls || [];
return calls.some(c => c.name === 'set_volume');
Pricing
xAI Voice API is billed at $0.05 per minute of audio.
Resources
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.