Skip to content

feat: Add Berget AI support with automatic API provider selection#1

Open
irony wants to merge 1 commit intooloflarsson:masterfrom
irony:feat/add-berget-ai-support
Open

feat: Add Berget AI support with automatic API provider selection#1
irony wants to merge 1 commit intooloflarsson:masterfrom
irony:feat/add-berget-ai-support

Conversation

@irony
Copy link
Copy Markdown

@irony irony commented Jan 28, 2026

Summary

Adds support for Berget AI alongside the existing Evroc API, with automatic provider detection based on which API key is configured.
image

Changes

Core Functionality

  • Dual API support: Add BERGET_API_KEY alongside EVROC_API_KEY
  • Automatic provider selection: Bot detects which API key is set and configures the corresponding base URL:
    • Berget AI: https://api.berget.ai/v1
    • Evroc: https://models.think.cloud.evroc.com/v1
  • Dynamic system prompt: Bot personality updates based on active provider

Code Changes

  • main.py: Refactored API configuration to support both providers
  • piper-start.sh: Fixed locale issue with decimal separators (LC_ALL=C)
  • .gitignore: Added .env to prevent accidental API key commits

Documentation

  • Updated README.md and AGENTS.md with dual API setup instructions
  • Clear guidance on which provider to use (Berget AI preferred)

Swedish Pronunciation

  • Added pronunciation fix: "Berget" → "bärjett"
  • Updated Whisper prompt to recognize "Berget AI"

Usage

# Preferred: Berget AI
export BERGET_API_KEY="sk_ber_..."

# OR: Legacy Evroc
export EVROC_API_KEY="..."

The bot automatically uses whichever API key is configured. Both providers support the same models:

  • STT: KBLab/kb-whisper-large
  • LLM: openai/gpt-oss-120b

Testing

✅ 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

- 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
Copilot AI review requested due to automatic review settings January 28, 2026 18:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread README.md
![TalkToBerget Screenshot](screenshot.png)

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.
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +52 to 58
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
```
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread main.py
Comment on lines +61 to +69
# 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"
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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}")

Copilot uses AI. Check for mistakes.
Comment thread main.py
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")
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'"

Suggested change
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'"
)

Copilot uses AI. Check for mistakes.
Comment thread main.py
Comment on lines +155 to +159
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.
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread main.py
Comment on lines +1 to +5
"""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
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread README.md
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)**
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
🎙️ **[Try the live demo →](https://talktoevroc.olof.tech)**
🎙️ **[Try the live demo →](https://talktoberget.olof.tech)**

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants