Environment Variable Setup
Sifaka uses environment variables to manage API keys for various LLM providers. This guide explains how to set up your environment.
Quick Start
-
Copy the example environment file:
-
Edit
.envand add your API keys:
Automatic Loading
Sifaka automatically loads environment variables from .env files using python-dotenv:
- When importing sifaka:
from sifaka import improve - In example scripts that include
load_dotenv() - In the LLM client module
Provider Requirements
Not all API keys are required. You only need keys for the providers you plan to use:
- OpenAI: Required for GPT-3.5, GPT-4 models (default)
- Anthropic: Required for Claude models
- Google Gemini: Required for Gemini models
- Groq: Required for fast open-source model inference
Security Notes
- Never commit
.envfiles to version control - The
.envfile is already in.gitignore - Use
.env.exampleas a template for sharing required variables - Keep your API keys secure and rotate them regularly
Additional Configuration
Optional environment variables:
GUARDRAILS_API_KEY: For GuardrailsAI validatorsLOGFIRE_TOKEN: For observability with LogfireREDIS_URL: Redis connection string (default:redis://localhost:6379)REDIS_PASSWORD: Redis authentication password