Overview
This guide covers two types of API keys in Dakora:- LLM Provider Keys - For executing templates with external AI models (OpenAI, Anthropic, etc.)
- Dakora API Keys - For authenticating programmatic access to Dakora APIs (see Authentication Guide)
Dakora API Keys
For authentication and API access, see the Authentication Guide.Management API (Project‑Scoped)
Use these endpoints to manage project API keys. Creating and revoking keys typically requires a JWT (user context) or an admin API key.id, name, key (only on creation), key_prefix, created_at, expires_at, and masked key_preview values for reads.
Dakora API keys allow you to:
- Authenticate API requests without browser login
- Access Dakora APIs from external services
- Implement service-to-service communication
- Control access at the project level
LLM Provider API Keys
Dakora uses LiteLLM to execute templates against 100+ LLM providers. Each provider requires an API key.Getting API Keys
1
2
Create API Key
Follow your provider’s documentation to create an API key. Keep it secure!
3
Set Environment Variable
Configure the key as an environment variable (see methods below)
Configuration Methods
Method 1: Environment Variables (Recommended)
- macOS/Linux
- Windows
Add to your Then reload:
~/.bashrc, ~/.zshrc, or ~/.bash_profile:Method 2: .env File (Development)
Create.env in your project root:
Method 3: In Code (Not Recommended)
For testing only:Verify Configuration
Check which API keys are configured:Provider-Specific Keys
OpenAI
gpt-4, gpt-4-turbo, gpt-3.5-turbo
Anthropic
claude-3-opus, claude-3-sonnet, claude-3-haiku
gemini-pro, gemini-1.5-pro
Azure OpenAI
azure/gpt-4, azure/gpt-35-turbo
Local Models (Ollama)
No API key required:Security Best Practices
Use Environment Variables
Use Environment Variables
Store API keys in environment variables, not in code
Add .env to .gitignore
Add .env to .gitignore
Never commit
.env files to version controlRotate Keys Regularly
Rotate Keys Regularly
Rotate API keys periodically for security
Use Separate Keys for Dev/Prod
Use Separate Keys for Dev/Prod
Use different API keys for development and production environments
Monitor Usage
Monitor Usage
Track API usage to detect unauthorized access
Troubleshooting
AuthenticationError
AuthenticationError
Error:
AuthenticationError: Invalid API keySolution:- Verify your API key is correct
- Check the environment variable name matches the provider
- Ensure the key hasn’t expired
Key Not Found
Key Not Found
Error:
API key not found for providerSolution:- Run
dakora config --provider openaito verify - Check environment variable is set:
echo $OPENAI_API_KEY - Restart your terminal/IDE after setting variables
.env Not Loading
.env Not Loading
Error: Keys in
.env file not being readSolution:- Install python-dotenv:
pip install python-dotenv - Add
load_dotenv()before importing Dakora - Ensure
.envis in the current working directory