Babulus Configuration Setup
Overview
Babulus uses a single configuration file (~/.babulus/config.yml) as the universal source of truth for all API keys and provider settings. This file works across all environments:
- ✅ CLI tools (local development)
- ✅ Web app in Node mode (Next.js server)
- ✅ Web app in Electron mode (desktop)
- ✅ Cloud Lambda functions
- ✅ CI/CD test runs
Key Benefits:
- 🔒 No Cloud Dependencies - Works offline without AWS Secrets Manager
- 📁 Single Source of Truth - One config file for all environments
- 🔑 No Vendor Lock-in - Take your keys with you
- 🚀 Simple Deployment - Lambda reads from config during deploy
Quick Start
1. Create Config File
Create the config directory and file:
mkdir -p ~/.babulus
touch ~/.babulus/config.yml
chmod 600 ~/.babulus/config.yml # Secure permissions2. Add Your API Keys
Edit ~/.babulus/config.yml:
# ~/.babulus/config.yml
providers:
# OpenAI TTS (Recommended for development - cheapest)
openai:
api_key: "sk-proj-..." # Get from https://platform.openai.com/api-keys
model: "gpt-4o-mini-tts" # Fast and cheap
voice: "alloy" # Options: alloy, echo, fable, onyx, nova, shimmer
# ElevenLabs TTS (Premium quality)
elevenlabs:
api_key: "sk_..." # Get from https://elevenlabs.io/app/settings/api-keys
voice_id: "21m00Tcm4TlvDq8ikWAM" # Rachel voice
model_id: "eleven_multilingual_v2" # Or eleven_turbo_v2_5 for speed
# Optional: Music generation
music_model_id: "music_v1"
# Optional: Sound effects
sfx_model_id: "eleven_text_to_sound_v2"
# AWS Polly TTS (Uses AWS credentials, no API key needed)
aws_polly:
region: "us-east-1"
voice_id: "Joanna"
engine: "standard" # Or "neural" for better quality
# Azure Cognitive Services TTS
azure_speech:
api_key: "..." # Get from Azure portal
region: "eastus"
voice: "en-US-JennyNeural"
# Default provider selection
tts:
default_provider: openai # Change to elevenlabs for production
audio:
default_sfx_provider: elevenlabs
default_music_provider: elevenlabs3. Test Configuration
Verify your config works:
# Test with CLI
npx babulus generate examples/hello.babulus.yml
# Or run tests
npm testConfiguration Search Order
Babulus searches for config in this order:
BABULUS_PATHenvironment variable (highest priority)export BABULUS_PATH=/path/to/custom/config.ymlProject directory
./.babulus/config.yml- Useful for project-specific overrides
- Inherits from home directory config
Current working directory
$(pwd)/.babulus/config.ymlHome directory
~/.babulus/config.yml(recommended default)
Example Override:
# Use project-specific config
cd /path/to/project
mkdir .babulus
cp ~/.babulus/config.yml .babulus/config.yml
# Edit .babulus/config.yml with project-specific keysProvider-Specific Setup
OpenAI TTS
Get API Key:
- Go to https://platform.openai.com/api-keys
- Click "Create new secret key"
- Copy the key (starts with
sk-proj-...)
Config:
providers:
openai:
api_key: "sk-proj-..."
model: "gpt-4o-mini-tts" # $2/1M chars (cheapest)
voice: "alloy" # Options: alloy, echo, fable, onyx, nova, shimmerCost: 0.002per1000characters( 2 per million)
Best For: Development, iteration, high volume
ElevenLabs
Get API Key:
- Go to https://elevenlabs.io/app/settings/api-keys
- Click "Create API Key"
- Copy the key (starts with
sk_...)
Get Voice ID:
- Go to https://elevenlabs.io/voice-library
- Select a voice
- Copy the Voice ID from the URL or API
Config:
providers:
elevenlabs:
api_key: "sk_..."
voice_id: "21m00Tcm4TlvDq8ikWAM" # Rachel
model_id: "eleven_multilingual_v2" # Premium quality
# Optional: Voice settings
voice_settings:
stability: 0.5
similarity_boost: 0.75Cost: ~$0.30 per 1000 characters (varies by tier)
Best For: Production, premium quality, custom voices
AWS Polly
Prerequisites:
- AWS account with Polly access
- AWS credentials configured (
~/.aws/credentials)
Config:
providers:
aws_polly:
region: "us-east-1"
voice_id: "Joanna"
engine: "standard" # Or "neural" for $16/1M charsAuthentication: Uses AWS SDK default credential chain:
- Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - AWS credentials file (
~/.aws/credentials) - IAM role (for Lambda/ECS)
Cost: $4 per million characters (standard), $16 (neural)
Best For: AWS-native deployments, compliance requirements
Azure Cognitive Services
Get API Key:
- Go to https://portal.azure.com
- Create a Speech Service resource
- Copy the API key and region from "Keys and Endpoint"
Config:
providers:
azure_speech:
api_key: "..."
region: "eastus"
voice: "en-US-JennyNeural"Cost: $16 per million characters (neural voices)
Best For: Microsoft ecosystem, Azure-native deployments
Lambda Deployment
How It Works
When you deploy to AWS Lambda with npx ampx deploy:
- Build Time: Amplify reads your
~/.babulus/config.yml - Injection: Extracts API keys and injects as Lambda environment variables
- Runtime: Lambda code reads from
process.env.OPENAI_API_KEY
Config File Location:
// apps/studio-web/amplify/functions/generation-worker/resource.ts
import { loadConfig, getProviderConfig } from '../../../../../src/config.js';
const config = loadConfig(); // Reads ~/.babulus/config.yml
const openaiConfig = getProviderConfig(config, 'openai');
export const generationWorker = defineFunction({
environment: {
OPENAI_API_KEY: String(openaiConfig.api_key ?? ''),
ELEVENLABS_API_KEY: String(elevenlabsConfig.api_key ?? ''),
// ...
},
});Security:
- Environment variables are encrypted at rest by AWS
- Not visible in AWS console without IAM permissions
- Redeployed when config changes
Security Best Practices
1. File Permissions
Restrict access to your config file:
chmod 600 ~/.babulus/config.ymlThis ensures only you can read the file.
2. Never Commit Config
Add to your global .gitignore:
# ~/.gitignore_global
**/.babulus/config.ymlConfigure git to use it:
git config --global core.excludesfile ~/.gitignore_global3. Project-Level Secrets
For team projects, use project-specific config:
# Project directory
cd /path/to/project
mkdir .babulus
cp ~/.babulus/config.yml .babulus/config.yml
# Add to project .gitignore
echo ".babulus/config.yml" >> .gitignore⚠️ Warning: Only commit project configs to private repos with proper access control.
4. CI/CD Secrets
For GitHub Actions or similar:
# .github/workflows/test.yml
- name: Setup Babulus Config
run: |
mkdir -p ~/.babulus
echo "$BABULUS_CONFIG" > ~/.babulus/config.yml
env:
BABULUS_CONFIG: ${{ secrets.BABULUS_CONFIG }}Store the full config file as a GitHub secret.
Troubleshooting
Config Not Found
Symptom: Error: OpenAI TTS requires providers.openai.api_key in config
Solutions:
- Verify config exists:
cat ~/.babulus/config.yml - Check file permissions:
ls -la ~/.babulus/config.yml - Test config loading:
BABULUS_PATH=~/.babulus/config.yml npx babulus generate ...
Invalid API Key
Symptom: Error: OpenAI TTS failed (401): Unauthorized
Solutions:
- Verify key format (should start with
sk-for OpenAI, ElevenLabs) - Check key hasn't expired
- Test key with curl:
curl https://api.openai.com/v1/models \ -H "Authorization: Bearer $(grep api_key ~/.babulus/config.yml | awk '{print $2}' | tr -d '\"')"
Config Not Loaded in Lambda
Symptom: Lambda logs show "API key not found"
Solutions:
- Verify config exists locally:
cat ~/.babulus/config.yml - Redeploy:
npx ampx deploy - Check Lambda environment variables in AWS console
- Ensure deployment ran from machine with config file
YAML Parsing Error
Symptom: Error: Invalid config: ~/.babulus/config.yml
Solutions:
- Validate YAML syntax: https://www.yamllint.com/
- Check indentation (use spaces, not tabs)
- Ensure colons have space after them:
key: valuenotkey:value
Migration from Environment Variables
If you're currently using export OPENAI_API_KEY=...:
Option 1: Keep Environment Variables (Easiest)
Environment variables take precedence over config:
# Still works!
export OPENAI_API_KEY="sk-proj-..."
npx babulus generate ...Option 2: Migrate to Config File (Recommended)
Extract current keys:
echo "providers:" > ~/.babulus/config.yml echo " openai:" >> ~/.babulus/config.yml echo " api_key: \"$OPENAI_API_KEY\"" >> ~/.babulus/config.ymlRemove from environment:
# Edit ~/.bashrc or ~/.zshrc # Remove: export OPENAI_API_KEY=...Test:
unset OPENAI_API_KEY npx babulus generate ... # Should still work
Advanced: Custom Config Locations
Per-Project Config
cd /path/to/project
mkdir .babulus
cat > .babulus/config.yml << EOF
providers:
openai:
api_key: "sk-proj-project-specific-key"
EOFEnvironment-Specific Configs
# Development
export BABULUS_PATH=~/.babulus/config.dev.yml
# Production
export BABULUS_PATH=~/.babulus/config.prod.yml
# Staging
export BABULUS_PATH=~/.babulus/config.staging.ymlDocker/Container Config
Mount config as volume:
docker run -v ~/.babulus:/root/.babulus my-babulus-appOr use environment variables:
ENV OPENAI_API_KEY="sk-proj-..."
ENV ELEVENLABS_API_KEY="sk_..."Next Steps
- ✅ Create config file:
~/.babulus/config.yml - ✅ Add API keys: Start with OpenAI for development
- ✅ Test locally: Run
npx babulus generate - ✅ Deploy to Lambda:
npx ampx deploy - ✅ Monitor usage: Check provider dashboards
For more examples, see:
Support
Questions? Open an issue at https://github.com/anthropics/babulus/issues
Security Concerns? Email security@babulus.ai (do not post keys publicly)