Skip to content

AI and model configuration

Knetik gives modules three AI capabilities through ctx.ai, and one model for agents. A deployment decides which providers back them. A module never hard-codes a model.

What Used by Setting
Agent model Agent stages KNETIK_DEFAULT_MODEL
Chat ctx.ai.chat in code stages (for example a fact check) KNETIK_AI_CHAT_MODEL, defaulting to KNETIK_DEFAULT_MODEL
Search ctx.ai.search and the agent web_search tool KNETIK_AI_SEARCH
Images ctx.ai.image KNETIK_AI_IMAGE

A capability that is not set up fails with a message saying which setting to add, for example ai.search is not configured on this deployment.

Models are written provider/model-id. With OpenRouter that is openrouter/<OpenRouter model id>:

Terminal window
KNETIK_DEFAULT_MODEL=openrouter/anthropic/claude-sonnet-5.5
KNETIK_AI_CHAT_MODEL=openrouter/anthropic/claude-haiku-5.5

A moving alias works too: openrouter/~anthropic/claude-sonnet-latest (note the ~). For other providers, use the model library’s provider name with the matching provider API key; the hosting guide’s example is anthropic/claude-haiku-4-5 with ANTHROPIC_API_KEY.

Use a cheaper model for KNETIK_AI_CHAT_MODEL when code stages only need short, structured answers. npm run check:env verifies model ids against the model library’s catalog.

KNETIK_AI_SEARCH is openrouter or brave.

Provider Needs Notes
openrouter OPENROUTER_API_KEY Uses OpenRouter’s web search plugin. No extra account. Web results are billed on top of the model call. The model that runs the search defaults to the chat model; set KNETIK_AI_SEARCH_MODEL (an OpenRouter id such as anthropic/claude-haiku-5.5) to use a cheaper one.
brave BRAVE_API_KEY Brave Search API

Without search, a module that starts from a topic will say so. A link or pasted text still works.

KNETIK_AI_IMAGE=openrouter:<model>, for example openrouter:bytedance-seed/seedream-4.5. It needs OPENROUTER_API_KEY. Leave it unset to run modules without images.

KNETIK_AI_MODULES is JSON keyed by module id. It overrides chat and image for one module:

Terminal window
KNETIK_AI_MODULES='{"content-creator":{"chat":"openrouter/anthropic/claude-haiku-5.5","image":"openrouter:bytedance-seed/seedream-4.5"}}'
Setting Default Meaning
KNETIK_AI_MAX_IMAGES_PER_RUN 8 Images per run. A cap while you experiment.
KNETIK_AI_TIMEOUT_MS 120000 Time limit for an AI call

Prompts are also size limited (200,000 characters).

Timeline events ai.chat, ai.search, ai.image and page.fetch record the model or provider, duration and sizes. Never prompts, queries or page text. Token usage is not recorded, so there is no per-run cost accounting yet.

KNETIK_STUB_MODEL=1 makes model, search, page and image calls come from one script file (KNETIK_MODEL_SCRIPT, which knetik dev points at the module’s fixtures/dev-model.ts). It is for trials, tests and knetik dev. check:env warns when it is set, because a real run needs it off.