Configuration

Configuration Reference

Knull uses a YAML-based configuration file. It supports environment variable substitution using ${VAR_NAME} or $VAR_NAME syntax.

Top-Level Schema

database:   # Persistence settings
gateways:   # Listener settings
models:     # Backend LLM settings
apiKeys:    # Client authentication
policies:   # Budget and access rules
mcp:        # Model Context Protocol settings
redis:      # (Optional) HA state settings

Gateways

Defines the ports Knull listens on for AI traffic.

FieldTypeDescription
namestringUnique name for the gateway.
portintPort to listen on (default: 1975).

Models (AIServiceBackend)

Defines the backend LLM providers.

FieldTypeDescription
idstringUnique identifier used by clients in the model field.
providerstringOne of: azure, openai, anthropic, aws_bedrock, aws_anthropic, gcp_vertex, cohere, openai_compatible.
endpointstringThe base URL or hostname of the provider.
apiKeystring(Optional) API key for authentication.
backendNamestring(Optional) Custom backend name for routing.
awsRegionstringRequired for aws_* providers.
awsAccessKeystringAWS Access Key.
awsSecretKeystringAWS Secret Key.
gcpProjectstringRequired for gcp_* providers.
gcpLocationstringRequired for gcp_* providers.
gcpAccessTokenstringGCP Access Token.
aliasstring(Optional) Maps a client-side model name to this backend.
schemaobject(Optional) Custom API schema configuration.
authobject(Optional) Backend authentication policy.
headerMutationobject(Optional) Header mutation rules.
bodyMutationobject(Optional) Body mutation rules.

API Keys

Defines keys used by your applications to authenticate with Knull.

apiKeys:
  - id: team-alpha
    keyVal: sk-knull-alpha-xxxxxx
    name: "Alpha Team Key"
    owner: "alpha@example.com"

Policies

Maps API Keys to Models and sets budgets.

FieldTypeDescription
idstringUnique policy ID.
apiKeyIdstringReference to an apiKeys.id.
modelIdstringReference to a models.id.
allowbooleanSet to false to block access.
budgetLimitintMax tokens allowed for this key/model pair.

Full Example

database:
  type: sqlite
  path: "./knull.db"
 
gateways:
  - name: public-gw
    port: 1975
 
models:
  - id: gpt-4o
    provider: azure
    endpoint: ${AZURE_HOST}
    apiKey: ${AZURE_KEY}
  - id: claude-3-5
    provider: anthropic
    apiKey: ${ANTHROPIC_KEY}
 
apiKeys:
  - id: app-1
    keyVal: sk-knull-app1-secret
 
policies:
  - id: app1-gpt4
    apiKeyId: app-1
    modelId: gpt-4o
    budgetLimit: 50000