Skip to content

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)
    )
  1. Required. Application will fail to start without a valid key.
  2. Relative path to the SQLite database. Can be an absolute path for production.
  3. Specifies the OpenAI model used by Vanna for SQL generation.
  4. Ignores extra variables in the .env file (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:

fly secrets set OPENAI_API_KEY="sk-..."
See the Deployment: Environment Variables page.