Configuration

Paladin is configured via a YAML file (config.yml by default) and environment variables. Environment variables take precedence over file values and use the APP_ prefix format shown throughout this guide.

Loading Configuration

// Load from the default config.yml in the current directory
let settings = paladin_ai_core::config::ApplicationSettings::load()?;

// Or specify a path
let settings = paladin_ai_core::config::ApplicationSettings::from_file("config.yml")?;

LLM Provider

Ten providers are supported: openai, anthropic, deepseek, kimi, qwen, grok, ollama, gemini, zai, and a generic operator-configured openai-compatible provider for any other OpenAI-compatible endpoint. Nine of them have an llm.<provider> block; zai is configured through its ZAI_* environment variables only (see Z.ai below). Only the providers compiled in via the matching llm-<provider> Cargo feature are usable at runtime; the compiled default remains openai + anthropic + deepseek (see Feature Flags).

llm:
  default_provider: "openai"   # openai | anthropic | deepseek | kimi | qwen | grok | ollama | gemini | zai | openai-compatible

  openai:
    base_url: "https://api.openai.com/v1"
    default_model: "gpt-4o-mini"
    default_temperature: 0.7
    timeout_seconds: 300
    max_retries: 3

  deepseek:
    base_url: "https://api.deepseek.com/v1"
    default_model: "deepseek-chat"
    default_temperature: 0.7
    timeout_seconds: 300
    max_retries: 3

  anthropic:
    base_url: "https://api.anthropic.com/v1"
    default_model: "claude-3-5-sonnet-20241022"
    default_temperature: 0.7
    timeout_seconds: 300
    max_retries: 3

  # Six providers added alongside the original three. Each carries its own dated
  # verification status below rather than one blanket disclaimer — see "Live
  # verification status" further down for what was confirmed and when.
  #
  # Kimi (Moonshot AI). Live-verified 2026-08-22 (plan 17-19, closing G-17-4b): GET
  # /models and a generate() round trip both succeeded against api.moonshot.ai.
  kimi:
    base_url: "https://api.moonshot.ai/v1"
    default_model: "kimi-k3"
    timeout_seconds: 60

  # Qwen (Alibaba DashScope). Live-verified 2026-08-23 (plan 17-21 gap closure): GET
  # /models returned a 162-model catalog at the endpoint below, including the default
  # model, and a generate() round trip succeeded.
  #
  # DashScope API keys are scoped to the Model Studio region that issued them and are
  # REJECTED by every other region's endpoint. `base_url` below is Singapore, the
  # shipped default. If your workspace is in the US or on the mainland, you MUST
  # set `DASHSCOPE_BASE_URL` to your own region's endpoint:
  #   - Singapore      (shipped default): https://dashscope-intl.aliyuncs.com/compatible-mode/v1
  #   - US (Virginia):                    https://dashscope-us.aliyuncs.com/compatible-mode/v1
  #   - China (mainland):                 https://dashscope.aliyuncs.com/compatible-mode/v1
  qwen:
    base_url: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
    default_model: "qwen-plus"
    timeout_seconds: 60

  # Grok (xAI). Live-verified 2026-08-22 (plan 17-18, closing G-17-4a): GET /models and
  # a generate() round trip both succeeded against api.x.ai.
  grok:
    base_url: "https://api.x.ai/v1"
    default_model: "grok-4.6"
    timeout_seconds: 60

  # Ollama (self-hosted) requires no api_key at all (D-12) — omit the field entirely.
  # Not applicable to live-vendor verification: self-hosted, no vendor endpoint to
  # verify. Its live exercise is the Docker Tier 2 suite (UAT test 3), passed on a
  # GitHub Actions runner 2026-08-19.
  ollama:
    base_url: "http://localhost:11434/v1"
    default_model: "llama3"
    timeout_seconds: 60

  # Gemini uses a bespoke `generateContent` protocol, not OpenAI-compatible.
  # Live-verified: GET /models and a generate() round trip both succeeded against
  # generativelanguage.googleapis.com. default_model was refreshed from
  # gemini-2.5-flash (retired for new users) to gemini-3.6-flash per the live catalog.
  gemini:
    base_url: "https://generativelanguage.googleapis.com/v1beta"
    default_model: "gemini-3.6-flash"
    timeout_seconds: 60

  # Generic adapter for ANY OpenAI-compatible endpoint not named above (self-hosted
  # vLLM/LiteLLM, Groq, Together, Mistral, Fireworks, Bedrock's OpenAI-compat mode, ...).
  # base_url and default_model are REQUIRED here — there is no vendor default.
  openai-compatible:
    base_url: "https://your-endpoint.example.com/v1"
    default_model: "your-model-name"
    timeout_seconds: 60

API keys are read exclusively from environment variables:

VariableProvider
OPENAI_API_KEYOpenAI
DEEPSEEK_API_KEYDeepSeek
ANTHROPIC_API_KEYAnthropic
MOONSHOT_API_KEYKimi
DASHSCOPE_API_KEYQwen
XAI_API_KEYGrok
— (none required)Ollama — self-hosted, no vendor credential (D-12)
GEMINI_API_KEYGemini
ZAI_API_KEYZ.ai (Zhipu AI, GLM) — environment only, see Z.ai
OPENAI_COMPATIBLE_API_KEYGeneric OpenAI-compatible provider — not the same variable as OPENAI_API_KEY, a different credential for a different provider; the two names are one word apart, read both character-by-character before exporting either
APP_LLM_DEFAULT_PROVIDEROverride default provider at runtime

Security: Never put API keys in config.yml. Use environment variables or a secrets manager (AWS Secrets Manager, HashiCorp Vault, Kubernetes Secrets).

Z.ai (environment only)

Z.ai (Zhipu AI, GLM models; provider name zai, Cargo feature llm-zai) has no llm.zai block in this release. LlmConfig ignores keys it does not know, so a zai: section under llm: loads without error and is silently not read. It is configured through these environment variables:

VariableRequiredDefault
ZAI_API_KEYyes—
ZAI_BASE_URLnohttps://api.z.ai/api/paas/v4
ZAI_MODELnoglm-5.3
ZAI_TIMEOUT_SECONDSno300 (the vendor documents thinking as enabled by default)

With those set, default_provider: "zai" (or APP_LLM_DEFAULT_PROVIDER=zai) selects it, and an agent or a model_fallback hop can name zai. ZAI_BASE_URL must start with http:// or https://. Z.ai documents a second endpoint for its GLM Coding Plan (https://api.z.ai/api/coding/paas/v4) and says Standard and Coding Plan keys are managed separately, with the key type deciding how calls are billed; point ZAI_BASE_URL there only with a Coding Plan key. An llm.zai block is planned for a later release.

Live verification status

Per-vendor, not one blanket disclaimer — each provider's base_url and default_model above carry their own dated status:

ProviderStatus
GeminiLive-verified: a model-list fetch and a generate() round trip both succeeded.
Grok (xAI)Live-verified 2026-08-22 (plan 17-18): model list + a generate() round trip against api.x.ai.
Kimi (Moonshot)Live-verified 2026-08-22 (plan 17-19): model list + a generate() round trip against api.moonshot.ai, including its measured fixed-temperature constraint.
Qwen (DashScope)Live-verified 2026-08-23 (plan 17-21 gap closure): a model-list fetch (162 models at the shipped Singapore endpoint) and a generate() round trip both succeeded. See the region-scoping note above qwen: for the mandatory override outside the Singapore region.
Z.ai (GLM)Not live-verified. The base URL, default model, model list and temperature range were read on docs.z.ai on 2026-11-17; no live call, seed probe or effort probe has been run, so every model is unprofiled and an explicit reasoning effort is refused.
OllamaNot applicable — self-hosted, no vendor endpoint to verify. Its live exercise is the Docker Tier 2 suite (UAT test 3), passed on a GitHub Actions runner 2026-08-19.

Running against a local Ollama server (RT-FR-22)

Ollama is the only provider in the table above that requires no vendor API key (D-12) — it is also the only one you can run entirely on your own machine. Two commands get a model serving locally:

ollama serve                 # starts the local server (default: http://localhost:11434)
ollama pull llama3           # pulls the model named in the Ollama config block above

Point Paladin at it with the Ollama configuration block already shown above under LLM Provider — base_url and default_model there are exactly what ollama serve/ollama pull produce by default. To override the base URL without editing config.yml (a different port, a remote host, a container), set OLLAMA_BASE_URL; it follows the same environment-variable-overrides-file precedence as every other provider on this page.

A minimal reasoning_agent preset call against a local Ollama server, once it is running (the exact signature per 26-CONTEXT.md D-35 — paladin::presets and ReasoningAgent do not exist in the tree yet as of this plan; the runnable, doc-tested version of this snippet arrives with the agent-runtime user guide, plan 26-21):

use paladin::presets::{reasoning_agent, ReasoningAgentOptions};

// `llm` is any Arc<dyn LlmPort> -- for example the adapter built from the Ollama
// configuration block above (base_url "http://localhost:11434/v1", model "llama3").
let agent = reasoning_agent(llm, arsenal, ReasoningAgentOptions::default())?;
let result = agent.run("What is the capital of France?").await?;

Verifying the adapter against a real Ollama server is an existing suite, not a new one (D-32). tests/integration/ollama_docker_test.rs already is the "ignored-by-default integration test gated on an env var" RT-FR-22 asks for: it is required-features-gated on integration-tests + llm-ollama, every test in it independently probes OLLAMA_TEST_URL before doing anything else, and it prints a named SKIP: reason and returns early — never panics or hangs — when the service is unreachable. Run it with:

cargo test --test ollama_docker --features integration-tests,llm-ollama

Locally this will almost always print SKIP: ... and pass without exercising anything, because OLLAMA_TEST_URL is unset by default — that is the intended, documented behavior for a plain cargo test, not a failure. The suite is exercised for real only in CI's ollama-integration job (.github/workflows/ci.yml, the ollama-integration job near line 748), which brings up a Docker Compose ollama-test service, waits for it to report healthy, pulls qwen2.5:0.5b, runs this exact suite against it, and separately fails the job if any test took the SKIP: path — so a green run there is proof the live server was actually exercised, not proof-by-absence. Do not add a second Ollama integration test file — this is the one, and none should be added.

A rejected credential now announces itself

Every provider above except Ollama shares one underlying protocol engine (CompatEngine), so this applies uniformly to all of them — an operator debugging a self-hosted OpenAI-compatible endpoint gets the same signal as one debugging DashScope, Moonshot or xAI (2026-08-22, plan 17-22, closing G-17-4d).

Before this change, a rejected credential and an offline vendor looked identical: the model-list fetch silently fell back to a curated list with nothing above a debug log line, in either case. This is what let a genuine credential/region mismatch go undiagnosed for five days during this phase's own live verification (.planning/WINDOWS.md gap history). Now, when the configured endpoint rejects the request (an authentication failure), a warn-level line is emitted naming the endpoint and stating that the returned list is the curated fallback, not the vendor's own catalog — for example:

[WARN] configured endpoint https://dashscope-intl.aliyuncs.com/compatible-mode/v1 rejected
the request while listing models (Authentication failed: ...); the returned model list is
the curated fallback, not this vendor's own catalog — a credential scoped to a different
account or region is the usual cause

An endpoint that is simply unreachable — a self-hosted Ollama that has not started yet, a network blip, a slow response — stays at debug, exactly as before: being offline is a supported state (D-13/D-14), not a misconfiguration, and this diagnostic does not fire for it. Seeing the warning at all means the fix is the same one described throughout this page: check the configured base_url/*_BASE_URL override against the credential you are using.

Environment variables

The full LLM environment-variable surface — every credential, base-URL, model, timeout and (for the generic openai-compatible provider) capability/temperature override the adapters read — is documented as a first-class configuration path, alongside the YAML above, in .env.example at the repository root. Copy it to .env and fill in the credentials you need; unset variables fall back to the defaults shown in this guide.

In the devcontainer, these credentials arrive from ~/.config/paladin/ (one file per secret, filename = the lowercased variable name — e.g. ~/.config/paladin/xai_api_key → XAI_API_KEY) via .devcontainer/paladin-env.sh, sourced automatically into interactive shells by ~/.bashrc. A genuinely-exported non-empty value always wins over the file. A non-interactive shell (a script, a CI step, an agent's Bash tool) does not run ~/.bashrc and therefore does not source paladin-env.sh automatically — it must be sourced explicitly: set -a; . .devcontainer/paladin-env.sh; set +a.

Garrison (Short-term Memory)

The Garrison stores conversation context between Paladin turns.

garrison:
  garrison_type: "in_memory"       # in_memory | sqlite
  # path: "./garrison.db"          # Required when garrison_type = "sqlite"
  max_entries: 100                  # Max conversation turns to retain
  max_tokens: 4000                  # Context-window token budget
  tokenizer: "gpt-4o-mini"               # Model name for token counting
  eviction_strategy: "importance_based"  # importance_based | fifo | sliding_window
  preserve_recent_count: 10        # Always keep at least N recent entries
KeyTypeDefaultDescription
garrison_typestringin_memoryStorage backend
pathstring-SQLite file path (sqlite only)
max_entriesint100Maximum entries before eviction
max_tokensint4000Token budget for context window
eviction_strategystringimportance_basedEviction algorithm
preserve_recent_countint10Minimum recent entries to keep

Env vars: APP_GARRISON_TYPE, APP_GARRISON_PATH, APP_GARRISON_MAX_ENTRIES, APP_GARRISON_MAX_TOKENS, APP_GARRISON_EVICTION_STRATEGY, APP_GARRISON_PRESERVE_RECENT_COUNT

Sanctum (Long-term Vector Memory)

Sanctum stores semantic memories in a vector database for RAG.

sanctum:
  enabled: false
  adapter_type: "in_memory"        # in_memory | qdrant

  qdrant:                          # Required when adapter_type = "qdrant"
    url: "http://localhost:6334"
    collection_name: "paladin_memories"
    vector_dimension: 1536         # Must match your embedding model

rag:
  top_k: 5                         # Results to retrieve
  min_similarity: 0.7              # Score threshold (0.0-1.0)
  max_tokens: 2000                 # Max tokens to inject from RAG -- enforced by the
                                    # Commissary (Phase 33): shed memories are recorded
                                    # and a marker naming the omitted count and the
                                    # budget is appended to the injected context.
  timeout_seconds: 5

memory_extraction:
  enabled: true
  strategy: "on_completion"        # every_turn | on_completion | manual

Env vars: APP_SANCTUM_ENABLED, APP_SANCTUM_ADAPTER_TYPE, APP_SANCTUM_QDRANT_URL, APP_SANCTUM_QDRANT_COLLECTION_NAME, APP_SANCTUM_QDRANT_VECTOR_DIMENSION

See Sanctum Vector Memory for detail.

Arsenal (Tool System / MCP)

The Arsenal connects Paladins to external tools via the Model Context Protocol.

arsenal:
  default_timeout_seconds: 30
  max_concurrent_tools: 5
  mcp_servers:
    # STDIO server (command-line process)
    - name: "web_search"
      server_type: "stdio"
      command: "uvx"
      args: ["mcp-web-search"]

    # Streamable-HTTP server (remote, optionally authenticated)
    - name: "code_analyzer"
      server_type: "streamable_http"
      endpoint: "http://localhost:8080/mcp"
      # NAMES the env var holding the bearer token -- never a literal
      # secret in this file. Omit entirely for an unauthenticated server.
      auth_token_env: "CODE_ANALYZER_TOKEN"
KeyTypeDefaultDescription
default_timeout_secondsint30Per-tool execution timeout
max_concurrent_toolsint5Parallel tool invocations
mcp_servers[].namestring-Unique server identifier
mcp_servers[].server_typestring-stdio or streamable_http (sse is retired -- fails loud with a migration message)
mcp_servers[].commandstring-Executable (stdio only)
mcp_servers[].endpointstring-URL (streamable_http only)
mcp_servers[].auth_token_envstring-Env var NAME holding the bearer token (streamable_http only, optional)

Env vars: APP_ARSENAL_DEFAULT_TIMEOUT_SECONDS, APP_ARSENAL_MAX_CONCURRENT_TOOLS

See Arsenal & Tools for full integration guide.

Citadel (State Persistence)

Citadel saves Paladin state to disk for crash recovery and resumption.

citadel:
  enabled: false
  state_dir: "./paladin-states"
  autosave_enabled: false          # Save state after each execution
  cleanup_enabled: false           # Delete old state files automatically
  max_state_age_days: 30

Env vars: APP_CITADEL_ENABLED, APP_CITADEL_STATE_DIR, APP_CITADEL_AUTOSAVE_ENABLED, APP_CITADEL_CLEANUP_ENABLED, APP_CITADEL_MAX_STATE_AGE_DAYS

Battalion (Multi-agent Orchestration)

Battalion fault handling (retry, per-attempt timeout and error handler) is configured in code through BattalionConfig.aegis, set with BattalionConfig::with_aegis; see the Configuration Reference in the orchestration guide. config.yml has no battalion: section. The Maneuver flow DSL is configured through ManeuverConfig; see the Maneuver Flow DSL guide.

See Battalion Patterns for Formation, Phalanx, Campaign, and Chain of Command details.

Herald (Output Formatting)

herald:
  default_formatter: "json"        # json | markdown | table

  json:
    pretty: true
    include_metadata: true

  markdown:
    include_colors: true
    heading_level: 2

  table:
    max_column_width: 60
    border_style: "rounded"        # ascii | rounded | modern | sharp | none

Env vars: APP_HERALD_DEFAULT_FORMATTER, APP_HERALD_JSON_PRETTY, APP_HERALD_MARKDOWN_INCLUDE_COLORS, APP_HERALD_TABLE_BORDER_STYLE

Treasurer

The treasurer: subtree configures two of the token economy's three officers: the Treasurer's price table and allowances, and Cadence's rate pacing. The third, the Commissary, rations one call's input window and has no key here (see Token Budget Terminology). It has four parts -- currency, pricing, allowance and cadence -- and every struct under it rejects an unknown key at load, so a misspelled key (allowence:, perid:, cache_reads:) is a boot error, never a setting that silently does nothing. Omit treasurer: entirely and the server boots as it did without it: nothing is priced, nothing is enforced, and Cadence pacing is on. The concept page is Treasurer.

Treasurer key reference

One table covers every key. The Validation column is the rule paladin-server applies at load or boot, and a rejected value is an error naming the key's full path and the offending value, never rounded or clamped. An environment variable that cannot be parsed (for example APP_TREASURER_CADENCE_BASE_BACKOFF_MS=fast) is ignored and the file value stays.

KeyTypeDefaultValidationEnv override
treasurer.currencystring"USD"exactly three ASCII uppercase letters, never case-folded; an override is applied verbatim and a lowercase one is rejected like a file valueAPP_TREASURER_CURRENCY
treasurer.pricing.<model>map of price rowsempty map (nothing priced)key non-empty; matched exactly and case-sensitively against the model string the provider's response reportsnone (config file only)
row prompt (required)decimal string, currency units per 1M tokensnonedigits with an optional fraction of at most nine places; non-negative; at most 9223372036.854775807none
row completion (required)decimal string, currency units per 1M tokensnonesame as promptnone
row cache_readdecimal string, currency units per 1M tokensomitted: bills at promptsame as promptnone
row cache_writedecimal string, currency units per 1M tokensomitted: bills at promptsame as promptnone
row reasoningdecimal string, currency units per 1M tokensomitted: bills at completionsame as promptnone
treasurer.allowance.warn_atinteger percent800 to 100; 0 disables warnings; above 100 is rejected, never clampedAPP_TREASURER_ALLOWANCE_WARN_AT
treasurer.allowance.webhook.urlnon-empty http(s) URLnonenon-empty; passes the run-webhook address guard at boot (a private address needs webhooks.allow_private: true)none
treasurer.allowance.webhook.secretstring, redacted from Debug, never serialisednonenever echoed in an error; a ${VAR} placeholder in YAML is not expandedAPP_TREASURER_ALLOWANCE_WEBHOOK_SECRET (applied only when a webhook exists)
treasurer.allowance.tenants.<id>entrynonekey is a valid id; names a tenant that http.auth maps to; needs a run storenone (config file only)
treasurer.allowance.api_keys.<name>entrynonekey is a valid name; names a key in http.auth.api_keys; needs a run storenone (config file only)
entry period (required)<integer><m|h|d>none1m to 366d (60 to 31,622,400 seconds); 0m and 367d are rejected, as is any other unitnone
entry amount (required)decimal string, whole currency unitsnonepositive; at most nine places; at most 9223372036.854775807none
entry lifetimedecimal string, whole currency unitsnonepositive; at most nine places; at most 9223372036.854775807none
entry warn_atinteger percentthe global warn_at0 to 100; above 100 is rejectednone
treasurer.cadence.enabledbooltruenone beyond the typeAPP_TREASURER_CADENCE_ENABLED
treasurer.cadence.backendin_process or { redis: { url_env: NAME } }in_processone of the two forms; a misspelled key inside redis: is a load errornone (config file only)
treasurer.cadence.backend.redis.url_envname of an environment variablenonenon-empty; names a variable that is set at boot; the redis backend needs a binary built with --features redis-cadencenone
treasurer.cadence.base_backoff_msinteger500greater than zero; not above max_backoff_msAPP_TREASURER_CADENCE_BASE_BACKOFF_MS
treasurer.cadence.max_backoff_msinteger30000greater than zero; at least base_backoff_msAPP_TREASURER_CADENCE_MAX_BACKOFF_MS
treasurer.cadence.max_wait_secsinteger300greater than zeroAPP_TREASURER_CADENCE_MAX_WAIT_SECS
treasurer.cadence.degraded_multipliernumber2.0finite; at least 1.0APP_TREASURER_CADENCE_DEGRADED_MULTIPLIER
treasurer.cadence.fallback_pace_budget_secsinteger60greater than zeroAPP_TREASURER_CADENCE_FALLBACK_PACE_BUDGET_SECS
treasurer.cadence.lock_ttl_secsinteger120greater than zeroAPP_TREASURER_CADENCE_LOCK_TTL_SECS

Treasurer pricing

treasurer.pricing is the price table that turns a call's token usage into a cost. Without a row for a model, nothing about that model can be metered, so a model an allowance should bound needs one. Prices are copied from the provider's published price sheet.

treasurer:
  currency: "USD"
  pricing:
    gpt-4:
      prompt: "2.50"
      completion: "10.00"
      cache_read: "0.25"
    claude-3-5-sonnet-20241022:
      prompt: "3.00"
      completion: "15.00"

The numeric contract. A price is a decimal string in currency units per one million tokens: digits with an optional fractional part of at most nine places. A tenth fractional digit is a load error, never rounded; a sign, exponent, separator or whitespace is a load error; the value is non-negative and at most 9223372036.854775807. A value that does not fit names its full path (treasurer.pricing.<model>.<axis>) and is never clamped. Every row needs prompt and completion; an omitted cache_read or cache_write bills at prompt and an omitted reasoning at completion, because a call's prompt tokens already include its cache tokens and its completion tokens already include its reasoning tokens. A model key matches the model string the provider's response reports, exactly and case-sensitively: there is no normalisation and no provider/model key. When a fallback chain serves a call, the model that actually served it is the one priced. Allowance amounts follow the same nine-place rule, in whole currency units rather than per million tokens.

The cost rule. A call's cost is the sum of five axis products (base prompt, cache read, cache write, base completion, reasoning), each token count multiplied by its axis price, and that sum is rounded exactly once, half-up, to the nearest nano-unit -- not once per axis. Sums saturate rather than overflow. For example, 1,000 prompt and 2,000 completion tokens at "2.50" and "10.00" cost 0.0225 currency units (22,500,000 nano-units). Token counts that a malformed response reports above their parent count are billed at the parent's count.

A missing row. A model with no row keeps cost: None and logs one warning per model name; no price is ever invented. What that means depends on the path:

  • A principal with an allowance ceiling calling an agent whose model has no row is refused 422 model_unpriced at admission, naming the model and carrying no Retry-After, because spend that cannot be metered cannot be bounded. A principal with no ceiling is unaffected.
  • A call made by a WarGraph node on an unpriced model settles nothing, so an allowance cannot bound it: the spend is not metered and does not reach the ledger. This is a known, open gap (.planning/WINDOWS.md row 67), not a guarantee; give every model a graph can reach a row.
  • At boot, when an allowance is configured, the server logs one warning under paladin::pricing for every code-registered agent model and every stored agent-kind assistant model that has no row, and boot continues. Every stored version of each agent-kind assistant present at boot is checked, including pinned older ones. The warning does not check workflow graph-node models, agents provisioned at runtime, or agent-kind assistants or versions created after boot, and it does not refuse workflow assistants; see the Treasurer guide.

Treasurer allowances

treasurer.allowance caps how much an API key or a tenant may spend, enforced when a run is submitted: a request whose scope has already reached a ceiling is refused with 429 allowance_exhausted before anything is persisted. Amounts are operator-currency figures (treasurer.currency), never token counts. Omit the section and nothing is enforced.

treasurer:
  currency: "USD"
  allowance:
    warn_at: 80
    webhook:
      url: "https://ops.example.com/paladin-allowance"
    tenants:
      acme:
        period: "24h"
        amount: "25.00"
        lifetime: "500.00"
    api_keys:
      ci-runner:
        period: "1h"
        amount: "2.50"
        warn_at: 90

Decimal strings are exact: up to nine digits after the point, no sign, exponent, separator or whitespace, positive, and at most 9223372036.854775807. "25.00" is twenty-five units; "0.000000001" is one nano-unit. A value that does not fit is a boot error naming its full path, never rounded or clamped. A ${VAR} placeholder in the YAML file is not expanded -- the webhook.secret is supplied with APP_TREASURER_ALLOWANCE_WEBHOOK_SECRET. A lifetime-only entry is not expressible: every entry carries a window period and amount.

An entry's period is <integer><m|h|d> and is accepted from 1m to 366d (60 to 31,622,400 seconds). One step outside either end -- 0m below, 367d above -- is a boot error, never clamped to the nearest accepted value, and so is any other unit (s, w). A scope's spend is checked again at every boundary of a running run, not only at submission; the Treasurer page describes both checks and their bounded overshoot.

Window and limit model

Windows are tumbling and aligned to the UTC epoch, computed from the ledger's own clock, so a scope's spend resets on the boundary and can reach twice an allowance across one boundary. A caller can hold up to four ceilings, evaluated in a fixed order: API-key window, API-key lifetime, tenant window, tenant lifetime. A balance at or above a ceiling is exhausted (>=), and the first exhausted ceiling decides the refusal. Admin keys are bound like any other key.

Warn threshold

warn_at is a whole percent of a ceiling, applied to each ceiling the entry holds. A ceiling warns when balance x 100 >= ceiling x warn_at, in integer arithmetic and inclusive. With warn_at: 80 on a ceiling of 25.00, a balance of 19.75 (79 %) does not warn, 20.00 (80 %) does, and 20.25 (81 %) does. A notice is claimed once per window and never gates the request.

  • 0 disables warnings for the entry: it never warns.
  • 100 never warns, because a balance at or above the ceiling is exhausted and refused (>=) rather than warned about.
  • A value above 100 is rejected at load, never clamped.

Boot coherence

paladin-server refuses to start, naming the offending path, when:

  • treasurer.allowance has any entry while run_store.backend is disabled -- allowances are enforced against the spend ledger, which needs a run store;
  • an api_keys.<name> entry names no key in http.auth.api_keys;
  • a tenants.<id> entry names a tenant that no http.auth.api_keys entry or http.auth.bearer_token.tenant maps to;
  • any key under treasurer: is misspelled (allowence:, api_key:, perid:).

With http.auth.enabled: false the open-access principal is the key anonymous in the tenant open-access, so api_keys.anonymous and tenants.open-access are accepted.

Because those names stand for the open-access and unattributed principals, they are reserved: paladin-server also refuses to load a configuration that uses open-access, unattributed or anonymous as an http.auth.api_keys entry name, or open-access or unattributed as an http.auth.api_keys entry tenant, or as http.auth.bearer_token.tenant while the bearer token is enabled. The match is exact and case-sensitive.

The derived token budget on agent routes

On POST /v1/agents/{id}/execute, execute/stream and jobs, a principal with an allowance ceiling gets a per-run token budget derived at admission: the tightest remaining headroom across its ceilings, divided by the agent model's price. Every token is billed at the model's dearest treasurer.pricing axis (prompt, completion, cache read, cache write or reasoning), so a prompt-heavy agent stops earlier than its true spend would require. The agent loop ends after the model response that crosses the figure -- the overshoot is at most one response -- and the call answers stop_reason: "allowance_halted" with a halt_reason object and the partial output.

One TokenBudget enforces both figures. The effective limit is the tightest of agent_runtime.token_budget.max_tokens (when enabled) and the derived figure, and a tie goes to the allowance. When the operator figure is the tighter one the stop is the familiar stop_reason: "token_budget". The middleware is inert without either, so a deployment with the operator budget disabled and no allowance is unchanged. Note that the operator's agent_runtime.token_budget now takes effect on the HTTP agent routes: it was not applied to agents served over HTTP before, so enabling it now caps each of their runs.

Worker-dispatched agent-kind runs honour only the derived figure. A run of an agent-kind assistant submitted through POST /v1/runs is executed by the run engine's shared service, which also executes every engine node. That service installs the budget in a Treasurer-only mode: the operator's agent_runtime.token_budget is forced off there, so it applies to the HTTP agent routes above and never to a worker-dispatched run. The worker re-derives the allowance figure at dispatch and only a run carrying one is ever cut; an engine node never is (an operator budget on the shared service would cap a node mid-flight and hand a successful partial result to a Battlefield).

Two limits to know about:

  • Every model a metered principal can reach needs a treasurer.pricing row. A principal with a ceiling calling an agent whose model has none is refused 422 model_unpriced (naming the model, with no Retry-After) before the agent runs, because spend that cannot be metered cannot be bounded. A principal with no ceiling is unaffected.
  • A single streamed execute/stream call is one provider call and is not cut mid-flight. It is admitted or refused up front like any other call. Its terminal done event stays { "done": true, "usage": ... } unless the final chunk's usage exceeded the derived figure, in which case it also carries an informational halt_reason reporting the crossing. An agent with no streaming backend is buffered, and its done carries stop_reason and halt_reason as execute does.

A derived figure of zero tokens is refused 429 allowance_exhausted, like an exhausted ceiling.

Caveats

Changing treasurer.currency while allowances are in force makes every allowanced principal's admission fail closed until the ledger is migrated: its history is in the old currency. The operator webhook target must pass the same address guard as run webhooks, so a private address needs webhooks.allow_private: true; paladin-server checks it at boot and refuses to start, naming treasurer.allowance.webhook.url, when it is rejected. Each warn-threshold notice is then delivered once to that URL as a signed allowance_warning webhook through the same durable queue the run webhooks use (payload, headers and signature: Operator allowance notices). Enable webhook only after every replica runs the release that understands allowance_warning (see the HTTP service host rollout note).

Treasurer rate pacing (Cadence)

treasurer.cadence paces every LLM call paladin-server makes after a provider answers 429 Too Many Requests. It is reactive: nothing is gated until a provider says slow down. After a 429, later calls to the same provider and model wait out a gate -- the provider's own Retry-After when it sent one, otherwise exponential back-off with full jitter -- and the 429 itself is surfaced to the caller unchanged, never retried inside the pacing layer. Pacing is on by default: omit the section and every agent port (config-loaded agents, runtime-provisioned agents and the run engine's port) is paced over one in-process gate state shared by the whole server process. enabled: false installs nothing and restores the previous behaviour.

# Defaults, in process (what you get when the section is omitted):
treasurer:
  cadence:
    backend: in_process
    base_backoff_ms: 500
    max_backoff_ms: 30000
    max_wait_secs: 300

To share pacing state across a worker fleet, name the environment variable that holds the Redis URL (never the URL itself -- it may carry a password):

treasurer:
  cadence:
    backend:
      redis:
        url_env: CADENCE_REDIS_URL   # export CADENCE_REDIS_URL=redis://:password@redis.internal:6379/2
    degraded_multiplier: 2.0

The redis backend needs a binary built with --features redis-cadence; on a binary built without it paladin-server refuses to start, naming the feature, rather than quietly pacing in-process. See Fleet-wide pacing with Redis for the rollout and outage behaviour.

  • base_backoff_ms / max_backoff_ms: a 429 with no usable retry delay gates the key for a random time up to base_backoff_ms, doubling per consecutive 429 on that key up to max_backoff_ms; the first success resets it.
  • max_wait_secs: the longest a single call waits on a gate. A provider delay beyond it is not slept on: the call surfaces the rate-limit error immediately, carrying the full delay, so a worker lease is never held for an hour in silence.
  • degraded_multiplier: while a shared Redis is unreachable, each worker paces itself in-process with every delay multiplied by this factor, because it can no longer see the fleet's 429s. It has no effect with backend: in_process.
  • fallback_pace_budget_secs: a provider fallback chain (ModelFallbackMiddleware) stays on the same provider and waits out its gate for up to this long before a 429 moves the chain to the next provider. Other failures (5xx, timeouts, network errors) hop immediately, as before.
  • lock_ttl_secs: the lifetime of the cache stampede lock a library-built WarEngine takes around a cached node (WarEngine::with_cadence, shipped in the same release). Choose a value above the p99 duration of a cached node including its retries: the lock is not renewed, and a waiter that outlasts it runs the node itself. paladin-server attaches no node cache (Node cache on the shipped server), so the key has no effect on the shipped server today.

backend has no environment override: the Redis URL travels only through the variable url_env names, so it never appears in a config file, a serialised config or a log line. A misspelled key anywhere under treasurer.cadence -- including inside redis: -- is a load error, and an empty url_env, or one naming an unset variable, stops the server at boot naming treasurer.cadence.backend.redis.url_env. An unparseable environment value (for example APP_TREASURER_CADENCE_BASE_BACKOFF_MS=fast) is ignored and the file value stays.

Key namespace. The Redis backend keeps its state under the fixed key prefix paladin:cadence. Two independent fleets pointed at one Redis server therefore share pacing state for the same provider and model: a 429 seen by one slows the other. Give each fleet its own Redis server or logical database (redis://host:6379/2 selects database 2).

Token Budget Terminology

Paladin uses max_tokens in four independent, non-overlapping senses:

MeaningConfig key / typeOwner
Garrison store capgarrison.max_tokenssrc/config/ (Garrison config)
RAG injection caprag.max_tokenssrc/config/ (RAG config) — enforced by the Commissary (Phase 33): shed memories are recorded and a marker naming the omitted count and the budget is appended to the injected context
Per-request completion capLlmRequest metadata "max_tokens" (OpenAI/DeepSeek fallback-override); ANTHROPIC_MAX_TOKENS env var, read by AnthropicConfig::from_env() (Anthropic, required, env-only — no YAML key)provider adapters (crates/paladin-llm/src/openai/adapter.rs, crates/paladin-llm/src/anthropic/adapter.rs)
Run-level budget capagent_runtime.token_budget.max_tokenssrc/application/services/paladin/middleware/limits.rs

The spend-governance cap is a distinct key, treasurer.allowance (operator-currency amounts, never a token count), described in Treasurer allowances. On the HTTP agent routes the run-level budget and the allowance meet: the run is capped at the tightest of agent_runtime.token_budget.max_tokens and the token figure derived from the caller's remaining allowance (see The derived token budget on agent routes).

Autonomous Features

All autonomous features are opt-in (disabled by default). Uncomment sections in config.yml to enable:

autonomous:
  planning:
    enabled: false          # Decompose complex tasks into subtasks
    max_subtasks: 10

  prompt_generation:
    enabled: false          # Auto-generate system prompts from description
    description: null       # e.g. "Expert data analyst"

  dynamic_temperature:
    enabled: false          # Adjust temperature per task type
    min: 0.1
    max: 0.9

  handoffs:
    enabled: false          # Delegate to specialist Paladins
    strategy: "automatic"   # automatic | explicit | {threshold: 0.8}
    max_depth: 5

Env vars: APP_AUTONOMOUS_PLANNING_ENABLED, APP_AUTONOMOUS_PLANNING_MAX_SUBTASKS, APP_AUTONOMOUS_PROMPT_GENERATION_ENABLED, APP_AUTONOMOUS_DYNAMIC_TEMPERATURE_ENABLED, APP_AUTONOMOUS_HANDOFFS_ENABLED, APP_AUTONOMOUS_HANDOFFS_STRATEGY

Multi-Environment Pattern

Keep a config.yml for defaults and override per environment:

# Development
export APP_LLM_DEFAULT_PROVIDER=openai
export APP_GARRISON_TYPE=in_memory

# Staging
export APP_GARRISON_TYPE=sqlite
export APP_GARRISON_PATH=/data/garrison.db
export APP_SANCTUM_ENABLED=true

# Production
export APP_GARRISON_TYPE=sqlite
export APP_SANCTUM_ENABLED=true
export APP_SANCTUM_ADAPTER_TYPE=qdrant
export APP_CITADEL_ENABLED=true
export APP_CITADEL_AUTOSAVE_ENABLED=true

Complete Example (config.yml)

llm:
  default_provider: "openai"
  openai:
    default_model: "gpt-4o-mini"
    default_temperature: 0.7

garrison:
  garrison_type: "sqlite"
  path: "./garrison.db"
  max_entries: 200
  max_tokens: 8000

arsenal:
  default_timeout_seconds: 30
  max_concurrent_tools: 5
  mcp_servers:
    - name: "web_search"
      server_type: "stdio"
      command: "uvx"
      args: ["mcp-web-search"]

herald:
  default_formatter: "markdown"

See Also