Skip to content

Environment Variables

The application uses pydantic-settings to manage configuration via app/core/config.py.

Configuration Table

Variable Default / Example Purpose
ENV local local or prod / production. Enforces strict validation in prod.
OPENAI_API_KEY sk-... Critical. Used for embeddings, reranking, and chat.
SUPABASE_URL https://... Critical. Supabase project URL for database and vector operations.
SUPABASE_SERVICE_ROLE_KEY ... Critical. Service role key used for backend operations.
SUPABASE_JWT_SECRET None Used for validating client requests and signing tokens.
TRANSLATION_PROVIDER openai Translation provider: openai or google.
GOOGLE_TRANSLATE_API_KEY ... Required if TRANSLATION_PROVIDER is google.
GOOGLE_TRANSLATE_PROJECT_ID ... Required if TRANSLATION_PROVIDER is google.
OPENAI_CHAT_MODEL gpt-4o Main chat model.
OPENAI_REASONING_MODEL o4-mini Reasoning model.
OPENAI_RERANK_MODEL gpt-4o-mini Cost-effective model for reranking candidates.
OPENAI_EMBEDDING_MODEL text-embedding-3-small Embedding model for vector generation.
EMBEDDING_DIMENSIONS 1536 Dimensions for the generated embeddings.
CHUNK_SIZE 1000 Size of chunks for ingestion.
CHUNK_OVERLAP 150 Overlap size for chunks.
RETRIEVAL_TOP_K 20 Number of documents to retrieve initially.
RERANK_TOP_N 5 Number of documents to keep after reranking.
BASE_CHAT_COST 5 Tokens deducted per chat message.
TOKEN_BUFFER 10 Extra tokens reserved to prevent mid-request failures.
STALE_JOB_TIMEOUT_MINUTES 30 Timeout before considering background jobs stale.
CORS_ALLOWED_ORIGINS http://localhost:3000 Allowed origins for CORS (comma-separated).

Note: SUPABASE_ANON_KEY and SUPABASE_KEY have been removed. The backend uses only SUPABASE_SERVICE_ROLE_KEY for all operations. The SUPABASE_SERVICE_KEY alias is maintained for backward compatibility and is auto-populated from SUPABASE_SERVICE_ROLE_KEY.

.env.example Usage

Always keep .env.example updated with safe placeholder values. - DO NOT commit the actual .env file. - Add new variables to app/core/config.py first, then update .env.example.

Back to Index