Skip to main content

🎛️ Configuration

Global settings​

# Credential helper for persistent token storage.
# Resolved as agentkit-credential-<name> in PATH.
# Default: "keychain"
# Set to "file" for headless/CI (stores credentials in a JSON file at
# ~/.local/state/agentkit/credentials.json with 0600 perms).
credential_helper = "keychain"

credential_helper​

Name of the credential helper binary. Resolved as agentkit-credential-<name> in PATH.

  • Default: "keychain"
  • Set to "file" for headless/CI environments without a keychain daemon.

Per-provider model metadata overrides​

Model metadata is scoped to the provider serving the model, because the same model ID can mean different things at different providers. Overrides merge on top of the bundled models.dev snapshot for that provider only. Declaring an override also adds that model to the provider's served list; it does not need to be repeated in models. Pricing remains under [providers.pricing].

[[providers]]
identity = "openai_payg"
api_surface = "openai-chat-completions"
base_url = "https://api.openai.com/v1"
billing = "pay_as_you_go"
models = ["gpt-4o"]

[providers.model_overrides."gpt-4o"]
context_window = 128000
max_output = 16384

[providers.model_overrides."gpt-4o".capabilities]
tool_calling = true
reasoning = false
structured_output = true

providers.model_overrides.<id>.context_window​

Maximum context window size in tokens for this provider's model.

providers.model_overrides.<id>.max_output​

Maximum output tokens this provider's model can generate.

providers.model_overrides.<id>.capabilities​

  • tool_calling — whether the model supports function/tool calling.
  • reasoning — whether the model supports reasoning/thinking modes.
  • structured_output — whether the model supports structured JSON output.

Providers​

Providers are defined as an array of tables, keyed by identity:

[[providers]]
identity = "openai_codex_sub"
api_surface = "openai-responses"
base_url = "https://chatgpt.com/backend-api/codex"
billing = "subscription"
models = ["gpt-4o", "gpt-4o-mini"]

[providers.auth]
type = "bearer_token"

[providers.auth.oauth]
authorize_url = "https://provider.example.com/oauth/authorize"
token_url = "https://provider.example.com/oauth/token"
scopes = "openid email profile"
client_id = "my-client-id"

[providers.pricing]
input_per_mtok = 0
output_per_mtok = 0

identity​

Unique key for this provider. Used for credential resolution, session affinity lookups, and response headers. Must be unique across all providers.

api_surface​

The wire protocol format. One of:

  • "openai-chat-completions" — OpenAI Chat Completions.
  • "openai-responses" — OpenAI Responses.
  • "anthropic-messages" — Anthropic Messages.

A provider entry is pinned to a single surface; multi-surface gateways are configured as multiple entries sharing a base_url (see OpenCode).

base_url​

The upstream provider's base URL. Request paths are rewritten by stripping the API surface prefix and appending the upstream path.

billing​

  • "subscription" — flat-rate, time-limited quota. No per-token cost within quota.
  • "pay_as_you_go" — per-token cost, rate-limited.
  • "free" — local providers (e.g. Ollama). No auth, no limits.

models​

Explicit list of model IDs this provider can serve. When absent, models are inferred from the models.dev pricing snapshot.

auth.type​

  • "bearer_token" — sends credentials as Authorization: Bearer <value>, resolved from the credential helper via switchboard auth add or switchboard auth login.
  • "none" — no authentication header.

mutations​

Optional. Paths to mutation scripts applied to every outbound request for this provider, in declaration order. Relative paths resolve against the directory containing the configuration file.

mutations = ["scripts/zen.rhai", "scripts/add-tools.rhai"]

Every script must define a global fn mutate(request) that takes the request map and returns it:

fn mutate(request) {
request.headers["user-agent"] = "opencode/1.18.31";
request
}

The request map carries:

  • provider — the provider identity (read-only).
  • surface — the provider's api_surface (read-only).
  • model — the model id from the inbound request (read-only).
  • session_id — the inbound session id, or null (read-only).
  • headers — the outbound headers as a map of strings. Mutable.
  • body — the outbound body as a parsed JSON value, or null for a non-JSON body. Mutable.

What scripts can and cannot do:

  • Scripts run once per provider attempt, after the default headers are assembled and before the provider credential is injected, and the injected credential always wins over anything a script sets. Switchboard performs no inbound authentication, so an Authorization header from the client is assembled like every other header and is visible to scripts.
  • Scripts never see the outbound method or URL.
  • The returned map's headers and body replace the outbound values wholesale, so keep every header you want to send when you modify headers. A header name or value that is not a valid header fails the request; nothing is forwarded unmutated.
  • Scripts run inside a sandbox with bounded execution time, operations, call depth, and container sizes. eval and module imports are disabled.

Scripts are compiled once at startup. A missing file, a parse error, or a script without fn mutate aborts startup with the provider identity and the script path. Compilation is shared: two providers listing the same path compile it once.

See providers for worked examples.

auth.oauth​

OAuth 2.1 endpoint configuration. Present for providers that support automatic token refresh.

  • authorize_url — OAuth authorization endpoint URL.
  • token_url — OAuth token endpoint URL.
  • scopes — Space-separated OAuth scopes (default: "openid email").
  • client_id — OAuth client ID (optional, falls back to a known default per provider).

pricing​

Per-provider pricing for cost-aware routing.

  • input_per_mtok — cost per million input tokens.
  • output_per_mtok — cost per million output tokens.
  • cache_read_per_mtok — cost per million cached input tokens read.
  • cache_write_per_mtok — cost per million cached input tokens written.
  • reasoning_per_mtok — cost per million reasoning tokens.

Per-model pricing overrides:

[providers.pricing.models."gpt-4o-mini"]
input_per_mtok = 0.15
output_per_mtok = 0.60