Configuration
All settings are configured via environment variables, loaded through Pydantic BaseSettings.
Required Settings
| Setting | Type | Description |
|---|---|---|
DATABASE_URL | string | PostgreSQL connection string (e.g., postgresql://user:pass@host:5432/dbname) |
OPENAI_API_KEY | string | OpenAI API key for embeddings and LLM calls |
API Security
| Setting | Type | Default | Description |
|---|---|---|---|
API_KEY | string | "" | REST API authentication key. If empty, API runs without auth |
CORS_ORIGINS | list[string] | ["*"] | Allowed CORS origins |
RATE_LIMIT_ENABLED | boolean | false | Enable endpoint rate limiting |
Connection Pool
| Setting | Type | Default | Description |
|---|---|---|---|
POOL_MIN_SIZE | integer | 2 | Minimum pool connections |
POOL_MAX_SIZE | integer | 10 | Maximum pool connections |
POOL_TIMEOUT | float | 5.0 | Seconds to wait for a connection |
POOL_MAX_IDLE | float | 300.0 | Seconds before closing an idle connection |
DB_STATEMENT_TIMEOUT | integer | 30 | Query timeout in seconds |
API Server
| Setting | Type | Default | Description |
|---|---|---|---|
API_HOST | string | "0.0.0.0" | REST API bind address |
API_PORT | integer | 8000 | REST API port |
LOG_LEVEL | string | "INFO" | Logging level |
Search
| Setting | Type | Default | Description |
|---|---|---|---|
MIN_SIMILARITY_THRESHOLD | float | 0.3 | Default minimum similarity for search results |
Embeddings
| Setting | Type | Default | Description |
|---|---|---|---|
EMBEDDING_MODEL | string | "text-embedding-3-small" | OpenAI embedding model |
EMBEDDING_BATCH_SIZE | integer | 500 | Texts per API batch call |
Enrichment
| Setting | Type | Default | Description |
|---|---|---|---|
ENRICHMENT_MODEL | string | "gpt-5.4-nano" | LLM for HTS6 enrichment |
ENRICHMENT_TEMPERATURE | float | 0.1 | LLM temperature |
ENRICHMENT_BATCH_SIZE | integer | 50 | Codes per batch |
ENRICHMENT_MAX_WORKERS | integer | 25 | Concurrent enrichment threads |
Graph Pipeline: Edge Generation
| Setting | Type | Default | Description |
|---|---|---|---|
GRAPH_KNN_K | integer | 30 | Nearest neighbors per code |
GRAPH_KNN_MIN_SIMILARITY | float | 0.65 | Minimum cosine similarity |
GRAPH_KNN_LEVEL | string | "hts8" | Embedding level for KNN |
GRAPH_KNN_VARIANT | string | "full" | Embedding variant for KNN |
Graph Pipeline: Edge Classification
| Setting | Type | Default | Description |
|---|---|---|---|
GRAPH_CLASSIFICATION_MODEL | string | "gpt-5.4-nano" | LLM for edge classification |
GRAPH_CLASSIFICATION_TEMPERATURE | float | 0.1 | LLM temperature |
GRAPH_CLASSIFICATION_MAX_TOKENS | integer | 1500 | Max response tokens |
GRAPH_CLASSIFICATION_CONCURRENCY | integer | 200 | Concurrent LLM calls |
GRAPH_CLASSIFICATION_BATCH_SIZE | integer | 500 | Database flush batch size |
GRAPH_CLASSIFICATION_CHUNK_SIZE | integer | 1000 | Candidates per processing chunk |
GRAPH_CLASSIFICATION_CHUNK_DELAY | float | 1.0 | Seconds between chunks (rate limit pacing) |
Example .env
# Required
DATABASE_URL=postgresql://user:password@db.supabase.co:5432/postgres
OPENAI_API_KEY=sk-...
# API Security (optional)
API_KEY=your-secret-api-key
RATE_LIMIT_ENABLED=true
# Connection Pool
POOL_MIN_SIZE=2
POOL_MAX_SIZE=10
# Search
MIN_SIMILARITY_THRESHOLD=0.3
# Graph Pipeline
GRAPH_KNN_K=30
GRAPH_CLASSIFICATION_CONCURRENCY=200