Configuration¶
All application settings are driven by environment variables. The application uses Pydantic Settings which reads from a .env file or the system environment.
The .env File¶
Create a .env file in the project root. This file is never committed to source control (.gitignore excludes it).
.env
OPENAI_API_KEY="sk-..." # (Required) Your OpenAI API key
DATABASE_URL="dbn-poc-database.db" # (Optional) SQLite database path
VANNA_MODEL="gpt-4o" # (Optional) OpenAI model to use
APP_NAME="DBN Analytics POC API" # (Optional) Display name for the API
Configuration Reference¶
All settings are defined in core/config.py:
core/config.py
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
app_name: str = "DBN Analytics POC API"
openai_api_key: str = "" # (1)
database_url: str = "dbn-poc-database.db" # (2)
vanna_model: str = "gpt-4o" # (3)
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore" # (4)
)
- Required. Application will fail to start without a valid key.
- Relative path to the SQLite database. Can be an absolute path for production.
- Specifies the OpenAI model used by Vanna for SQL generation.
- Ignores extra variables in the
.envfile (e.g., secrets used by other services).
Environment Variables¶
| Variable | Required | Default | Description |
|---|---|---|---|
OPENAI_API_KEY |
✅ Yes | — | Your OpenAI API key |
DATABASE_URL |
❌ No | dbn-poc-database.db |
Path to the SQLite database |
VANNA_MODEL |
❌ No | gpt-4o |
OpenAI model for SQL generation |
APP_NAME |
❌ No | DBN Analytics POC API |
API title displayed in Swagger UI |
Production Secrets
Never hard-code secrets. For production deployments (e.g., Fly.io), use:
See the Deployment: Environment Variables page.