Skip to content

Configuration Reference

This page documents all configuration options available in ContextRouter.

Configuration Loading

Settings are loaded in this order (later overrides earlier):

  1. Built-in defaults
  2. Environment variables (.env file and system env)
  3. TOML file (settings.toml)
  4. Runtime settings (passed to functions)
from contextrouter.core import get_core_config
# Automatic loading
config = get_core_config()
# Custom paths
config = get_core_config(
env_path="./custom.env",
toml_path="./custom-settings.toml"
)

Model Settings

[models]
default_llm = "vertex/gemini-2.0-flash"
default_embeddings = "vertex/text-embedding-004"
temperature = 0.7
max_output_tokens = 4096
timeout_sec = 60
max_retries = 3
SettingTypeDefaultDescription
default_llmstringrequiredDefault LLM in format provider/model
default_embeddingsstringrequiredDefault embedding model
temperaturefloat0.7Generation randomness (0-2)
max_output_tokensint4096Maximum response tokens
timeout_secint60Request timeout in seconds
max_retriesint3Retry attempts on failure

Provider Settings

Google Vertex AI

[vertex]
project_id = "your-gcp-project"
location = "us-central1"
datastore_id = "your-datastore-id"
SettingEnv VarDescription
project_idVERTEX_PROJECT_IDGCP project ID
locationVERTEX_LOCATIONGCP region
datastore_idVERTEX_DATASTORE_IDVertex AI Search datastore

PostgreSQL

[postgres]
host = "localhost"
port = 5432
database = "contextrouter"
user = "postgres"
password = "${POSTGRES_PASSWORD}"
pool_size = 10
ssl_mode = "prefer"
SettingDefaultDescription
hostlocalhostDatabase host
port5432Database port
database-Database name
user-Database user
password-Database password
pool_size10Connection pool size
ssl_modepreferSSL mode

OpenAI

[openai]
api_key = "${OPENAI_API_KEY}"
organization = "org-..."
base_url = "https://api.openai.com/v1"

Anthropic

[anthropic]
api_key = "${ANTHROPIC_API_KEY}"

Local Models

[local]
ollama_base_url = "http://localhost:11434/v1"
vllm_base_url = "http://localhost:8000/v1"
Env VarDescription
LOCAL_OLLAMA_BASE_URLOllama server URL
LOCAL_VLLM_BASE_URLvLLM server URL

RAG Settings

[rag]
# Provider selection
provider = "postgres"
# Reranking
reranking_enabled = true
reranker = "vertex"
# Hybrid search (Postgres only)
hybrid_fusion = "rrf"
enable_fts = true
rrf_k = 60
hybrid_vector_weight = 0.7
hybrid_text_weight = 0.3
# Result limits
general_retrieval_enabled = true
general_retrieval_final_count = 10
max_retrieval_queries = 3
# Per-source limits
max_books = 5
max_videos = 3
max_qa = 5
max_web = 3
max_knowledge = 5
# Citations
citations_enabled = true
citations_books = 3
citations_videos = 2
citations_qa = 3
citations_web = 2
# Knowledge graph
graph_facts_enabled = true
max_graph_facts = 50
# Caching
cache_enabled = false
cache_ttl_seconds = 3600
# Blue/green deployment
data_store_id_blue = ""
data_store_id_green = ""
active_store = "blue"
SettingTypeDefaultDescription
providerstringpostgresRetrieval backend
reranking_enabledbooltrueEnable second-pass reranking
rerankerstringvertexReranker: vertex, mmr, none
hybrid_fusionstringrrfFusion method: rrf, weighted
enable_ftsbooltrueEnable full-text search
general_retrieval_final_countint10Max total documents

Ingestion Settings

[ingestion.rag]
enabled = true
output_dir = "./ingestion_output"
[ingestion.rag.preprocess]
chunk_size = 1000
chunk_overlap = 200
min_chunk_size = 100
[ingestion.rag.taxonomy]
builder = "llm"
max_depth = 4
min_samples_per_category = 3
[ingestion.rag.graph]
builder_mode = "hybrid"
cognee_enabled = true
max_entities_per_chunk = 10
[ingestion.rag.shadow]
include_keywords = true
include_entities = true
include_summary = true
[ingestion.rag.skip]
preprocess = false
structure = false
index = false
export = false
deploy = false

Connector Settings

[connectors.web]
google_api_key = "${GOOGLE_API_KEY}"
google_cse_id = "${GOOGLE_CSE_ID}"
max_results = 10
[connectors.rss]
feeds = [
"https://example.com/feed.xml"
]
fetch_full_content = true
max_age_hours = 24

Security Settings

[security]
require_auth = true
allowed_origins = ["https://example.com"]
rate_limit_rpm = 60
[security.tokens]
secret_key = "${TOKEN_SECRET_KEY}"
expiry_hours = 24
algorithm = "HS256"

Observability Settings

[observability]
langfuse_enabled = true
langfuse_public_key = "${LANGFUSE_PUBLIC_KEY}"
langfuse_secret_key = "${LANGFUSE_SECRET_KEY}"
langfuse_host = "https://cloud.langfuse.com"
trace_all_requests = true
log_level = "INFO"
Env VarDescription
LANGFUSE_PUBLIC_KEYLangfuse public key
LANGFUSE_SECRET_KEYLangfuse secret key
LANGFUSE_HOSTLangfuse server URL
LOG_LEVELLogging level (DEBUG, INFO, WARNING, ERROR)

Plugin Settings

[plugins]
paths = [
"~/my-plugins",
"./custom-extensions"
]
auto_discover = true

Router Settings

[router]
graph = "rag_retrieval"
override_path = "" # Optional: path to custom graph function

Environment Variable Reference

VariableDescriptionRequired
VERTEX_PROJECT_IDGCP project IDFor Vertex AI
VERTEX_LOCATIONGCP regionFor Vertex AI
OPENAI_API_KEYOpenAI API keyFor OpenAI
ANTHROPIC_API_KEYAnthropic API keyFor Anthropic
GROQ_API_KEYGroq API keyFor Groq
OPENROUTER_API_KEYOpenRouter API keyFor OpenRouter
POSTGRES_PASSWORDDatabase passwordFor Postgres
GOOGLE_API_KEYGoogle API keyFor web search
GOOGLE_CSE_IDCustom Search Engine IDFor web search
LOCAL_OLLAMA_BASE_URLOllama server URLFor local models
LOCAL_VLLM_BASE_URLvLLM server URLFor local models
RAG_PROVIDERDefault RAG providerOptional
RAG_EMBEDDINGS_MODELOverride embedding modelOptional
LOG_LEVELLogging verbosityOptional