Skip to main content
Reference

Gateway configuration reference

The gateway configuration file controls how keep-llm-gateway proxies LLM API traffic, evaluates policy on decomposed message blocks, and logs audit events. Pass the file path with --config.

Top-level fields

FieldTypeRequiredDefaultDescription
listenstringYesAddress and port to listen on (e.g., ":8080", "127.0.0.1:8080").
rules_dirstringYesPath to the directory containing Keep rule files.
profiles_dirstringNo""Path to the directory containing profile YAML files.
packs_dirstringNo""Path to the directory containing starter pack files.
providerstringYesLLM provider name. Currently accepted: "anthropic".
upstreamstringYesBase URL of the LLM provider API (e.g., "https://api.anthropic.com").
scopestringYesScope name matching a scope declared in your rule files.
decomposeobjectNoSee belowControls which message block types the gateway decomposes for evaluation.
logobjectNoSee belowLog format and output configuration.
judgeobjectNonullLLM-as-judge provider configuration. Required for rules with action: judge.

decompose

The gateway decomposes LLM requests and responses into individual blocks (tool use, tool result, text, summaries) and evaluates each against Keep rules. The decompose section controls which block types are evaluated.

FieldTypeRequiredDefaultDescription
tool_useboolNotrueEvaluate tool-use blocks in LLM responses.
tool_resultboolNotrueEvaluate tool-result blocks in requests.
textboolNofalseEvaluate text blocks in messages.
request_summaryboolNotrueEvaluate a summary call for each inbound request.
response_summaryboolNotrueEvaluate a summary call for each outbound response.

See LLM decomposition for how the gateway maps message blocks to Keep calls.

log

FieldTypeRequiredDefaultDescription
formatstringNo"json"Log format.
outputstringNo"stdout"Output destination. A file path writes audit logs to that file.

judge

Configures the LLM provider used for rules with action: judge. If omitted, judge rules are skipped.

FieldTypeRequiredDefaultDescription
providerstringYesJudge provider: "anthropic" or "openai".
api_key_envstringYesName of the environment variable containing the provider API key.
base_urlstringNoProvider defaultOverride the provider API base URL.

Verdicts are cached in memory for the lifetime of the process. Identical content evaluated against the same prompt and model returns a cached result without calling the provider. The cache holds up to 10,000 entries with oldest-first eviction.

Complete example

listen: ":8080"
rules_dir: "./rules"
profiles_dir: "./profiles"
packs_dir: "./packs"
provider: anthropic
upstream: "https://api.anthropic.com"
scope: anthropic-gateway
judge:
  provider: anthropic
  api_key_env: "ANTHROPIC_API_KEY"

decompose:
  tool_use: true
  tool_result: true
  text: false
  request_summary: true
  response_summary: true

log:
  format: json
  output: stdout

This configuration proxies Anthropic API traffic on port 8080. Judge rules use the Anthropic API with a key from the ANTHROPIC_API_KEY environment variable. The gateway decomposes tool-use and tool-result blocks for policy evaluation but skips plain text blocks. Audit events are written to stdout in JSON format.