feat: Add Berget AI support with automatic API provider selection#1
feat: Add Berget AI support with automatic API provider selection#1irony wants to merge 1 commit intooloflarsson:masterfrom
Conversation
- Add BERGET_API_KEY support alongside existing EVROC_API_KEY - Automatically detect and use whichever API key is configured - Update system prompt to dynamically reference the active provider - Add Swedish pronunciation fix for "Berget" → "bärjett" - Update documentation to reflect dual API support - Fix Piper TTS locale issue with decimal separators (LC_ALL=C) - Add .env to .gitignore to prevent API key leaks Users can now use either Berget AI (api.berget.ai/v1) or Evroc (models.think.cloud.evroc.com/v1) by setting the corresponding environment variable. Both providers support the same models: - STT: KBLab/kb-whisper-large - LLM: openai/gpt-oss-120b
There was a problem hiding this comment.
Pull request overview
This PR adds support for Berget AI as an alternative to Evroc, implementing automatic API provider selection based on which environment variable is set. The changes enable the voice bot to work with either Berget AI or Evroc APIs while maintaining the same model endpoints.
Changes:
- Added dual API provider support with automatic selection (Berget AI preferred, Evroc as fallback)
- Updated system prompts to dynamically reference the selected provider
- Fixed locale issue in piper-start.sh for decimal separator handling
- Updated documentation (README.md, AGENTS.md) to reflect dual-provider capability
- Added .env to .gitignore for security
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| main.py | Added Berget AI API configuration alongside Evroc, dynamic provider selection, updated system prompts with provider variables, and added Berget pronunciation fix |
| piper-start.sh | Fixed locale issue by setting LC_ALL=C for awk command to ensure correct decimal separator handling |
| README.md | Updated title to TalkToBerget, revised documentation to mention both providers, updated setup instructions for dual API keys |
| AGENTS.md | Updated service descriptions to reflect provider-agnostic setup with dual API key support |
| .gitignore | Added .env file to prevent accidental API key commits |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|  | ||
|
|
||
| A real-time Swedish voice assistant demo built with [Pipecat](https://github.com/pipecat-ai/pipecat) and [Evroc](https://evroc.com/) cloud services. | ||
| A real-time Swedish voice assistant demo built with [Pipecat](https://github.com/pipecat-ai/pipecat) and [Berget AI](https://berget.ai/) cloud services. |
There was a problem hiding this comment.
The description states the demo is "built with Berget AI cloud services" but the code supports both Berget AI and Evroc. This creates misleading documentation that doesn't reflect the dual-provider capability being added in this PR.
| A real-time Swedish voice assistant demo built with [Pipecat](https://github.com/pipecat-ai/pipecat) and [Berget AI](https://berget.ai/) cloud services. | |
| A real-time Swedish voice assistant demo built with [Pipecat](https://github.com/pipecat-ai/pipecat) and [Berget AI](https://berget.ai/) / Evroc cloud services. |
| Set **either** `BERGET_API_KEY` or `EVROC_API_KEY`: | ||
|
|
||
| ```bash | ||
| export EVROC_API_KEY="your-api-key" | ||
| export BERGET_API_KEY="your-api-key" # Preferred - Berget AI | ||
| # OR | ||
| export EVROC_API_KEY="your-api-key" # Legacy - Evroc | ||
| ``` |
There was a problem hiding this comment.
The prerequisites section still states "Evroc API keys for STT and LLM services" but should be updated to reflect that either Berget AI or Evroc API keys are needed, consistent with the new dual-provider support.
| # Determine which API to use based on available API key | ||
| if BERGET_API_KEY: | ||
| API_KEY = BERGET_API_KEY | ||
| BASE_URL = "https://api.berget.ai/v1" | ||
| API_PROVIDER = "Berget AI" | ||
| elif EVROC_API_KEY: | ||
| API_KEY = EVROC_API_KEY | ||
| BASE_URL = "https://models.think.cloud.evroc.com/v1" | ||
| API_PROVIDER = "Evroc" |
There was a problem hiding this comment.
When both BERGET_API_KEY and EVROC_API_KEY are set, the code silently prioritizes Berget AI without warning the user. Consider logging which provider is being used, or documenting this priority behavior clearly in the code comments and documentation to avoid confusion.
| # Determine which API to use based on available API key | |
| if BERGET_API_KEY: | |
| API_KEY = BERGET_API_KEY | |
| BASE_URL = "https://api.berget.ai/v1" | |
| API_PROVIDER = "Berget AI" | |
| elif EVROC_API_KEY: | |
| API_KEY = EVROC_API_KEY | |
| BASE_URL = "https://models.think.cloud.evroc.com/v1" | |
| API_PROVIDER = "Evroc" | |
| # Determine which API to use based on available API key. | |
| # Note: If both BERGET_API_KEY and EVROC_API_KEY are set, Berget AI is used. | |
| if BERGET_API_KEY: | |
| if EVROC_API_KEY: | |
| logger.warning( | |
| "Both BERGET_API_KEY and EVROC_API_KEY are set; defaulting to Berget AI." | |
| ) | |
| API_KEY = BERGET_API_KEY | |
| BASE_URL = "https://api.berget.ai/v1" | |
| API_PROVIDER = "Berget AI" | |
| logger.info(f"Using API provider: {API_PROVIDER}") | |
| elif EVROC_API_KEY: | |
| API_KEY = EVROC_API_KEY | |
| BASE_URL = "https://models.think.cloud.evroc.com/v1" | |
| API_PROVIDER = "Evroc" | |
| logger.info(f"Using API provider: {API_PROVIDER}") |
| BASE_URL = "https://models.think.cloud.evroc.com/v1" | ||
| API_PROVIDER = "Evroc" | ||
| else: | ||
| raise ValueError("Either BERGET_API_KEY or EVROC_API_KEY must be set") |
There was a problem hiding this comment.
The error message could be more helpful by indicating where these environment variables should be set and providing an example. Consider expanding it to guide users on the next steps, for example: "Either BERGET_API_KEY or EVROC_API_KEY must be set as an environment variable. Example: export BERGET_API_KEY='your-key-here'"
| raise ValueError("Either BERGET_API_KEY or EVROC_API_KEY must be set") | |
| raise ValueError( | |
| "Either BERGET_API_KEY or EVROC_API_KEY must be set as an environment variable. " | |
| "Example (bash): export BERGET_API_KEY='your-key-here'" | |
| ) |
| OM BERGET AI: | ||
| - En svensk AI-plattform för utvecklare och företag. | ||
| - Fokus på öppna AI-modeller och europeisk datasuveränitet. | ||
| - All data inom EU med full GDPR-efterlevnad. | ||
| - Fokus på hållbarhet och förnybar energi. | ||
| - Mål: 10 hyperscale-datacenter till 2030. | ||
|
|
||
| EVROCS TJÄNSTER: | ||
| - Cloud: Compute, Storage, Kubernetes, Serverless, IAM, Databaser. | ||
| - AI: NVIDIA B200 och H100 GPU-kluster, Think Studio, Think Models. | ||
|
|
||
| VARFÖR EVROC: | ||
| - Europeisk datasuveränitet, inte utländska lagar. | ||
| - Över 80 procent av Europas molnmarknad är utländsk, Evroc ändrar det. | ||
| - Tillhandahåller både LLM- och STT-tjänster via OpenAI-kompatibelt API. |
There was a problem hiding this comment.
The system prompt contains hardcoded information about "BERGET AI" (lines 155-159) that will be included regardless of which API provider is selected. When using Evroc, this section will incorrectly describe Berget AI instead of Evroc. The prompt should conditionally include provider-specific information based on the selected API_PROVIDER.
| """TalkToBerget Voice Bot - Swedish chatbot using Berget AI services. | ||
|
|
||
| A Pipecat voice bot using: | ||
| - STT: Evroc KBLab Whisper (Swedish) | ||
| - LLM: Evroc GPT-OSS-120B | ||
| - STT: Berget AI Whisper (Swedish) | ||
| - LLM: Berget AI GPT-OSS-120B |
There was a problem hiding this comment.
The module docstring hardcodes "Berget AI services" in the description, but the code now supports both Berget AI and Evroc. The docstring should reflect that the bot can use either provider, not just Berget AI.
| A real-time Swedish voice assistant demo built with [Pipecat](https://github.com/pipecat-ai/pipecat) and [Evroc](https://evroc.com/) cloud services. | ||
| A real-time Swedish voice assistant demo built with [Pipecat](https://github.com/pipecat-ai/pipecat) and [Berget AI](https://berget.ai/) cloud services. | ||
|
|
||
| 🎙️ **[Try the live demo →](https://talktoevroc.olof.tech)** |
There was a problem hiding this comment.
The title has been changed to "TalkToBerget" but the live demo URL still points to "talktoevroc.olof.tech", creating a naming inconsistency. Either the title should remain more generic or the URL reference should be updated to match.
| 🎙️ **[Try the live demo →](https://talktoevroc.olof.tech)** | |
| 🎙️ **[Try the live demo →](https://talktoberget.olof.tech)** |
Summary
Adds support for Berget AI alongside the existing Evroc API, with automatic provider detection based on which API key is configured.

Changes
Core Functionality
BERGET_API_KEYalongsideEVROC_API_KEYhttps://api.berget.ai/v1https://models.think.cloud.evroc.com/v1Code Changes
main.py: Refactored API configuration to support both providerspiper-start.sh: Fixed locale issue with decimal separators (LC_ALL=C).gitignore: Added.envto prevent accidental API key commitsDocumentation
README.mdandAGENTS.mdwith dual API setup instructionsSwedish Pronunciation
Usage
The bot automatically uses whichever API key is configured. Both providers support the same models:
KBLab/kb-whisper-largeopenai/gpt-oss-120bTesting
✅ Tested with Berget AI API - voice conversation working correctly
✅ Swedish STT (Whisper) transcribing accurately
✅ LLM responding with Berget AI context
✅ TTS with Swedish pronunciation fixes