Configuration reference

Configuration file schema, environment variable overrides, tier resolution, and media policy settings.

Settings resolve in order: CLI flags, then WHAT_IF_* environment variables, then ${XDG_CONFIG_HOME:-~/.config}/what-if/config.toml (or --config), then built-in defaults.

Environment variables

Variable Default Purpose
WHAT_IF_CONFIG empty Explicit TOML config file path (overrides XDG default)
WHAT_IF_BASE_URL http://127.0.0.1:7700 Upstream API base URL
WHAT_IF_API_KEY empty Bearer token (Authorization: Bearer <key>)
WHAT_IF_API_KEY_FILE empty Path to file containing bearer token
WHAT_IF_WIRE auto auto, systemone, openai, openrouter, or liquid
WHAT_IF_MODEL empty Default / fast tier model (WHAT_IF_MODEL_FAST alias)
WHAT_IF_MODEL_ACCURATE empty accurate tier model
WHAT_IF_MODEL_OMNI empty omni tier model (auto-selected for audio/video)
WHAT_IF_MIN_CONFIDENCE 0.0 Default abstention threshold ([0, 1])
WHAT_IF_ALLOW_MODELS empty Comma-separated allowlist for raw model overrides
WHAT_IF_LOCK_TIERS false Restrict tool schemas and calls to configured tiers only
WHAT_IF_ENABLE_SPANS false Enable span / roundhouse.span question support
WHAT_IF_MEDIA_ROOTS $PWD Path-separator-delimited allowlist for local media files
WHAT_IF_FFMPEG_PATH ffmpeg Path or binary name for non-WAV audio transcoding
WHAT_IF_FFMPEG_TIMEOUT 30s Maximum runtime per ffmpeg transcode invocation
WHAT_IF_SERVER_TOKEN empty Optional bearer token guarding HTTP /_/mcp
WHAT_IF_SERVER_TOKEN_FILE empty Path to file containing HTTP /_/mcp static bearer token
WHAT_IF_AUTH_RESOURCE empty Explicit RFC 9728 resource URL (defaults from request host when unset)
WHAT_IF_AUTH_ISSUER empty Expected iss claim and RFC 8414 / OIDC discovery base URL
WHAT_IF_AUTH_AUTHORIZATION_SERVERS empty Comma-separated Authorization Server URLs advertised in RFC 9728 metadata
WHAT_IF_AUTH_JWKS_URI empty Explicit JWKS endpoint for local asymmetric JWT verification (RS*/PS*/ES*/EdDSA)
WHAT_IF_AUTH_INTROSPECTION_URL empty RFC 7662 token introspection endpoint for opaque tokens
WHAT_IF_AUTH_INTROSPECTION_CLIENT_ID empty Client ID authenticating introspection calls
WHAT_IF_AUTH_INTROSPECTION_CLIENT_SECRET empty Client secret authenticating introspection calls
WHAT_IF_AUTH_INTROSPECTION_CLIENT_SECRET_FILE empty Path to file containing introspection client secret
WHAT_IF_AUTH_INTROSPECTION_AUTH_METHOD client_secret_basic Introspection client auth: client_secret_basic or client_secret_post
WHAT_IF_AUTH_AUDIENCE empty Comma-separated accepted aud values (defaults to auth.resource when set)
WHAT_IF_AUTH_REQUIRED_SCOPES empty Comma-separated scopes required on inbound bearer tokens
WHAT_IF_AUTH_SCOPES_SUPPORTED empty Comma-separated scopes advertised in RFC 9728 metadata
WHAT_IF_AUTH_CLOCK_SKEW 30s Allowed exp/nbf clock skew tolerance
WHAT_IF_AUTH_JWKS_CACHE_TTL 15m In-memory JWKS cache TTL (0s disables caching)
WHAT_IF_AUTH_INTROSPECTION_CACHE_TTL 30s Positive introspection cache TTL (0s disables caching)
WHAT_IF_AUTH_ALLOW_MISSING_EXPIRATION false Allow verified tokens that omit an exp claim
WHAT_IF_AUTH_PASSTHROUGH false Forward caller-supplied upstream API keys from HTTP MCP requests
WHAT_IF_AUTH_PASSTHROUGH_HEADER empty Override pass-through header (default: X-Upstream-API-Key with A/B, Authorization standalone)
WHAT_IF_TIMEOUT 60s Per-request upstream HTTP timeout

Example config.toml

base_url = "http://127.0.0.1:7700"
api_key_env = "RH_KEY"
wire = "auto"
lock_tiers = false
media_roots = ["."]
max_media_bytes = 26214400
max_media_count = 8
max_items = 200
max_parallel = 8
ffmpeg_path = "ffmpeg"
ffmpeg_timeout = "30s"
server_token_env = "WHAT_IF_SERVER_TOKEN"
# server_token_file = "/run/secrets/mcp_token"

[tiers.fast]
model = "clef-flash"
min_confidence = 0.70

[tiers.accurate]
model = "clef-27b"
min_confidence = 0.75

[tiers.omni]
model = "clef-omni"
min_confidence = 0.70

[auth]
resource = "https://mcp.example.com/_/mcp"
issuer = "https://idp.example.com"
jwks_uri = "https://idp.example.com/.well-known/jwks.json"
introspection_url = "https://idp.example.com/oauth2/introspect"
introspection_client_id = "what-if-rs"
introspection_client_secret_env = "WHAT_IF_AUTH_INTROSPECTION_CLIENT_SECRET"
required_scopes = ["decide:read"]
passthrough = true
# passthrough_header = "X-Upstream-API-Key"

Each [tiers.<name>] section may override base_url, api_key, api_key_env, api_key_file, wire, and min_confidence independently for heterogeneous backends.

HTTP auth composition

Enabled Modes Inbound Check on /_/mcp Metadata Endpoints Upstream Key Source
Static (server_token) Constant-time Authorization: Bearer None Configured api_key
OAuth 2.1 (auth.*) JWKS/JWT + RFC 7662 + static server_token (if set) /.well-known/oauth-protected-resource and /.well-known/oauth-protected-resource/_/mcp Configured api_key
Pass-through (auth.passthrough) Standalone: requires Authorization: Bearer <key> (unless custom header set); binds session to hashed key None unless OAuth is also enabled Caller header (X-Upstream-API-Key when static/OAuth is active, Authorization standalone) for default base_url calls only

Connections

Local graph

Linked from