Configuration
Configure LLM providers, memory backends, and security rules for your KRAIT agent.
The krait.exs Config File
All agent configuration lives in config/krait.exs. This file is evaluated at startup and defines how KRAIT connects to LLM providers, where it stores memory, and which security rules govern self-evolution.
# config/krait.exs
import Config
config :krait,
llm: [
provider: :openrouter,
models: ["anthropic/claude-sonnet-4.5", "openai/gpt-4o"],
api_key: System.get_env("OPENROUTER_API_KEY"),
max_tokens: 8192
],
memory: [
backend: :postgres,
pool_size: 5,
embedding_model: :local
],
sandbox: [
runtime: :docker,
timeout_ms: 30_000,
memory_limit_mb: 512
]
LLM Providers
KRAIT uses OpenRouter as its cloud LLM backend, providing access to dozens of providers through a single OpenAI-compatible API:
| Provider | Key | Models |
|---------------|-----------------|---------------------------------|
| OpenRouter | :openrouter | Claude, GPT-4o, Gemini, and more via openrouter.ai |
| Local (Ollama)| :ollama | Any GGUF model via Ollama |
The LLM Router (Krait.LLM.Router) automatically escalates from local Ollama to OpenRouter cloud when quality scores fall below threshold. OpenRouter supports multi-model fallback:
config :krait, :llm,
provider: :openrouter,
models: ["anthropic/claude-sonnet-4.5", "openai/gpt-4o"],
api_key: System.get_env("OPENROUTER_API_KEY")
Memory Backends
The memory backend controls how the agent persists learned context across evolution cycles. Supported backends are :postgres, :sqlite, and :ets (in-memory, development only).
config :krait, :memory,
backend: :sqlite,
path: "priv/memory.db"
Security Rules
KRAIT ships with seven built-in security rules (KRAIT-001 through KRAIT-007) that constrain what the agent can modify during self-evolution. You can extend or override these in config/rules.exs:
# config/rules.exs
[
%Krait.Rule{
id: "CUSTOM-001",
severity: :critical,
description: "Prohibit network calls in skill modules",
match: {:module_attribute, :skill, true},
deny: [:httpc, :hackney, Req]
}
]
Rules are enforced by Narsil during the validation phase of every evolution. See Your First Evolution for details on how validation integrates into the merge flow.
Environment Variables
Sensitive values like API keys should always be set via environment variables rather than hardcoded in krait.exs. KRAIT reads from .env files automatically in development mode:
# .env
OPENROUTER_API_KEY=sk-or-...
DATABASE_URL=postgres://localhost/krait_dev
For production deployments, consult Getting Started for the recommended secrets management approach.