Skip to main content

Overview

The AI services provide intelligent features powered by Google Gemini (for natural language understanding and generation) and ElevenLabs (for text-to-speech and speech-to-text).

Available Endpoints

Narrative Generation

  • POST /api/ai/generate-narrative - Generate human-readable narratives from simulation results
  • POST /api/ai/generate-briefing - Generate narrative with optional audio briefing
  • POST /api/ai/recommendations - Generate personalized financial recommendations

Voice Interactions

  • POST /api/ai/transcribe - Convert speech to text (Speech-to-Text)
  • POST /api/ai/generate-audio - Convert text to speech (Text-to-Speech)
  • POST /api/ai/stream-audio - Stream audio generation for real-time playback
  • POST /api/ai/voice-goal - Voice-based goal setting conversation
  • POST /api/ai/voice-results - Voice-based results discussion
  • GET /api/ai/voices - List available voice options

Authentication

AI endpoints require API keys configured in environment variables:
  • GEMINI_API_KEY - Required for all narrative and conversation features
  • ELEVENLABS_API_KEY - Required for voice features (TTS/STT)

Service Configuration

The API gracefully degrades when services are not configured:
// Check if ElevenLabs is configured
const response = await fetch('/api/ai/voices')
const { configured, voices } = await response.json()

if (!configured) {
  // Voice features not available
  console.log('ElevenLabs not configured - voice features disabled')
}

Next Steps

Narrative Generation

Generate readable summaries from simulation results

Voice Interactions

Enable speech-to-text and text-to-speech features

Recommendations

Get AI-powered financial advice

What-If Scenarios

Generate actionable scenarios for goal improvement

Build docs developers (and LLMs) love