Configuration Reference

Complete reference for all ModelTrack configuration options: environment variables, JSON config files, and runtime settings.

Proxy environment variables

VariableDefaultDescription
PROXY_PORT8080Port the proxy listens on
DATA_DIR../dataDirectory for JSONL cost events and config files
ANTHROPIC_BASE_URLhttps://api.anthropic.comUpstream Anthropic API endpoint
OPENAI_BASE_URLhttps://api.openai.comUpstream OpenAI API endpoint
LOG_LEVELinfoLogging verbosity (debug, info, warn, error)

Cache settings

The proxy includes an in-memory LRU response cache. Identical requests (same model, messages, system prompt, and temperature) return cached responses, saving both cost and latency.

VariableDefaultDescription
CACHE_ENABLEDtrueEnable or disable the response cache
CACHE_TTL_SECONDS3600Time-to-live for cached entries (seconds)
CACHE_MAX_ENTRIES1000Maximum number of cached responses

The cache key is a SHA-256 hash of the model, messages, system prompt, and temperature. Streaming requests are not cached.

API environment variables

VariableDefaultDescription
PORT3001API server listen port
DATA_DIR/dataDirectory for cost events and config files
DB_PATH/data/modeltrack.dbSQLite database file path
SLACK_WEBHOOK_URL-Slack incoming webhook for alerts and reports

Budget configuration

Budgets are defined in data/budgets.json. The proxy reads this file on startup and watches for changes.

data/budgets.json
{
  "budgets": [
    {
      "team": "ml-research",
      "app": "",
      "monthly_limit": 500.00,
      "action": "block"
    },
    {
      "team": "product",
      "app": "chatbot",
      "monthly_limit": 200.00,
      "action": "warn"
    },
    {
      "team": "product",
      "app": "search",
      "monthly_limit": 100.00,
      "action": "block"
    }
  ]
}
FieldTypeDescription
teamstringTeam name (matched against X-ModelTrack-Team header)
appstringApp name (empty string means all apps for that team)
monthly_limitnumberMonthly budget in USD
actionstringblock (reject requests) or warn (log + allow)

Routing configuration

Routing rules are defined in data/routing.json. They allow the proxy to automatically downgrade to cheaper models when teams approach their budget limits.

data/routing.json
{
  "rules": [
    {
      "name": "budget-downgrade",
      "trigger": "budget_percent_above",
      "threshold": 70,
      "from_models": ["claude-sonnet-4-6"],
      "to_model": "claude-haiku-4-5",
      "provider": "anthropic",
      "action": "downgrade",
      "enabled": true
    },
    {
      "name": "openai-budget-downgrade",
      "trigger": "budget_percent_above",
      "threshold": 80,
      "from_models": ["gpt-4o"],
      "to_model": "gpt-4o-mini",
      "provider": "openai",
      "action": "downgrade",
      "enabled": true
    }
  ]
}
FieldTypeDescription
namestringHuman-readable rule name
triggerstringTrigger type (e.g., budget_percent_above)
thresholdnumberBudget percentage that activates the rule (0-100)
from_modelsstring[]Models to downgrade from
to_modelstringCheaper model to route to
providerstringProvider (anthropic, openai)
actionstringAction to take (downgrade)
enabledbooleanWhether the rule is active

Collector namespace map

The collector uses data/namespace_map.json to map Kubernetes namespaces to ModelTrack teams for infrastructure cost attribution.

data/namespace_map.json
{
  "ml-research": "ml-research",
  "product-chatbot": "product",
  "default": "platform"
}

Keys are Kubernetes namespace names, values are ModelTrack team names. This allows the collector to attribute infrastructure costs (GPU, compute) to the correct team in the dashboard.

Proxy route paths

The proxy routes requests based on URL path:

PathProviderDescription
/v1/messagesAnthropicAnthropic Messages API
/v1/chat/completionsOpenAIOpenAI Chat Completions API
/bedrock/v1/messagesAWS BedrockAWS Bedrock Messages API
/azure/v1/chat/completionsAzure OpenAIAzure OpenAI Chat Completions API
/healthz-Health check endpoint
/stats-Proxy statistics
/cache/stats-Cache hit rate and savings
/routing/stats-Routing decisions and savings