Skip to main content

gateway.yaml

What it does: Defines all LLM providers and named model groups. The gateway centralizes provider selection, routing strategy, and credentials, allowing agents to reference models by logical group names.

Filename convention: gateway.yaml (usually in project root)

Annotated Example

env:
- name: ANTHROPIC_API_KEY # env var name to read from process environment
secret: true # reserved for future log masking
description: "Anthropic API key"
- name: OPENAI_API_KEY
secret: true
default: "sk-unused" # optional — used when env var is not set

providers:
- name: anthropic # logical name — used as prefix in model references
type: anthropic # anthropic | openai
config:
api_key: "{{ env.ANTHROPIC_API_KEY }}" # required — resolved from env: section

- name: openai
type: openai
config:
base_url: "https://api.openai.com/v1"
api_key: "{{ env.OPENAI_API_KEY }}"

model_groups:
- name: economy # group name — referenced in agent and workflow model: fields
models:
- anthropic/claude-3-haiku-20240307 # provider-name/model-id
strategy: round_robin # optional — round_robin | cost_optimized; default: round_robin
default_temperature: 0.3 # optional — default temperature for this group
pricing: # optional — used for cost tracking circuit breakers
- model: claude-3-haiku-20240307
input_per_million: 0.25
output_per_million: 1.25

- name: standard
models:
- anthropic/claude-3-5-sonnet-20240620
strategy: round_robin

- name: frontier
models:
- anthropic/claude-3-opus-20240229
strategy: round_robin

Fields

Env

Declares environment variables available for substitution in provider config values. All {{ env.VAR }} references in the file must be declared here. The gateway fails fast at startup if a required var is not set.

FieldTypeRequiredDescription
namestringyesEnvironment variable name (read from process environment).
secretboolnoReserved for future log masking (no current effect).
defaultstringnoFallback value used when the env var is not set.
descriptionstringnoHuman-readable description.

Providers

FieldTypeRequiredDescription
namestringyesLogical name used as a prefix (e.g., anthropic/).
typestringyesanthropic or openai.
configmapyesProvider-specific config. Supports {{ env.VAR }} substitution.

Model Groups

FieldTypeRequiredDescription
namestringyesGroup identity (e.g., economy, frontier).
modelsstring[]yesArray of provider-name/model-id strings.
strategystringnoSelection strategy. Defaults to round_robin.
default_temperaturenumbernoDefault temperature override for the group.
pricingarraynoPer-model pricing definitions for cost monitoring.

Variable Substitution

Provider config values support {{ env.VAR_NAME }} substitution. All referenced variables must be declared in the root env: section.

env:
- name: MY_API_KEY
secret: true

providers:
- name: my-provider
type: openai
config:
api_key: "{{ env.MY_API_KEY }}"
base_url: "https://api.example.com/v1"

The gateway resolves all env vars at startup:

  1. Reads the value from the process environment (os.Getenv).
  2. Falls back to default if the env var is not set.
  3. Fails with a clear error if neither is available.

Notes

  • Provider Normalization: The Gateway normalizes provider-specific error codes and response formats into a unified Kimitsu contract.