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.
assumeRoleArnstring(Optional) IAM Role ARN to assume for Bedrock access.
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.

Versioned API Schema

Customize how Knull communicates with the backend.

models:
  - id: gemini-openai
    provider: openai_compatible
    endpoint: ai.google.dev
    schema:
      name: OpenAI
      prefix: /v1beta/openai
FieldTypeDescription
namestringSchema name (e.g., OpenAI, Anthropic).
prefixstring(Optional) URL prefix for the API (e.g., /v1beta/openai).
versionstring(Optional) API version identifier.

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