Skip to content

Settings

Bases: BaseSettings

Application settings loaded from the environment or a .env file.

All fields can be overridden by environment variables using the same name (case-insensitive). A .env file in the working directory is loaded automatically.

Attributes:

Name Type Description
openai_api_key SecretStr | None

OpenAI API key. Required for the OpenAI backend.

anthropic_api_key SecretStr | None

Anthropic API key. Required for the Anthropic backend.

default_model str

Model identifier used when no model is specified explicitly.

default_backend str

Backend name to use by default. Either "openai" or "anthropic".

openai_base_url str | None

Optional custom base URL for the OpenAI client (e.g., OpenRouter).

max_workers int

Default number of concurrent threads for extract_df.

chunk_size int

Default number of rows per LLM request chunk.


Environment variables and .env

All Settings fields map directly to environment variables of the same name. pydantic-settings is configured with case_sensitive=False, so the env var DEFAULT_MODEL binds to the default_model attribute; upper-case env var names and lower-case attribute names are equivalent. Set them in the shell or drop a .env file in the working directory:

# .env
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
DEFAULT_MODEL=gpt-4.1-mini
DEFAULT_BACKEND=openai
OPENAI_BASE_URL=                  # optional: OpenRouter or Gemini compat URL
MAX_WORKERS=20
CHUNK_SIZE=5

The .env file is loaded automatically by pydantic-settings when the Settings object is instantiated. Values passed explicitly to extract_df (e.g., api_key=, base_url=) always take precedence over settings.