Providers & auth
Three wires, every provider
Section titled “Three wires, every provider”ka does not integrate providers one by one: it speaks three wire protocols, which between them cover essentially every endpoint:
| Wire | Covers |
|---|---|
anthropic_messages |
Anthropic |
openai_chat |
OpenAI and every OpenAI-compatible endpoint: Ollama, vLLM, LM Studio, gateways, DeepSeek, Groq, Mistral, Together, … |
openai_responses |
OpenAI’s Responses API for reasoning models: item-based history, flat tool definitions, reasoning.effort, streamed reasoning summaries |
All three are vendored (reqwest + rustls + hand-rolled SSE): no provider SDKs, no extra weight. Per-model quirks live in a dialect profile (a data table, not code): context window, supported efforts, cache mode, char-per-token ratio, flags like replay_reasoning for byte-exact <think> re-emission on Ollama.
The catalog
Section titled “The catalog”- A curated registry of vendors works selector-only:
openai,anthropic,google,zai,zai-plan,deepseek,mistral,groq,cerebras,qwen,moonshot,xai,nvidia,openrouter,opencode-go,together,fireworks,perplexity,nebius,sambanova,upstage,ollama,lmstudio,llamacpp,vllm. The community providers (perplexity,nebius,sambanova,upstage) are keyless until their key env var is set. - On top, a generated overlay seeded from models.dev adds 600+ models across 32 vendors, with context windows and published pricing, including subscription coding plans (
zai-coding-plan/glm-5.3and friends) as unpricedplanrows.ka models --updaterefreshes this catalog overlay at runtime from models.dev. - opencode-go is the OpenCode Go subscription gateway:
openai_chatwire,OPENCODE_API_KEY, models addressed asopencode-go/<model>. ka modelslists everything;--no-discoveryskips probing local endpoints.
User overlays extend the same table: --dialects <PATH> (repeatable) leaf-merges overlay TOMLs onto the embedded catalog, so a row that sets only context keeps the embedded wire and base URL, an unknown selector creates a new row, and later files win per leaf. The top level must be exactly a [dialects] table and row keys must be known; strict TOML applies, and errors name the offending key. The server_search flag below shows the shape.
ka-passport (Claude Pro/Max)
Section titled “ka-passport (Claude Pro/Max)”The opt-in ka-passport crate (enable the passport cargo feature) puts a Claude Pro or Max subscription behind ka: OAuth with PKCE and a loopback callback, tokens stored under the OS keyring service ka-passport, and proactive refresh so logins survive long sessions. The subscription surfaces as a claude-plan vendor (anthropic wire plus the oauth beta header), e.g. claude-plan/claude-sonnet-5. Like other coding plans, its models are unpriced plan rows: you pay the subscription, not per token.
Priority routing
Section titled “Priority routing”A top-level service_tier config key passes through on all three wires, for providers that support priority tiers.
Cache warming
Section titled “Cache warming”With [context] cache_warming = "idle", ka warms the prompt cache while the session is idle instead of inline, saving cost on turns that would otherwise pay a cold cache (turns of $0.05 or more benefit).
Local discovery
Section titled “Local discovery”On startup (unless disabled), ka probes the well-known local endpoints for Ollama (port 11434) and LM Studio (port 1234) and converts what it finds into ephemeral catalog rows. vLLM and llama.cpp are not probed: they ship as keyless providers (vllm/…, llamacpp/…), selector-only. Explicit config always wins over discovery.
Session routing
Section titled “Session routing”Every request carries the active strand id. Vendors that route by conversation receive it in their own header: opencode-go gets x-opencode-session and rejects calls without a stable id (MissingSessionID); vendors without a mapping never see it. Nested voices (delegate, pathfinder) inherit the engine’s session id, so gateway-routed traffic stays on one conversation.
Provider-native web search
Section titled “Provider-native web search”Some providers run web search on their own servers. With the server_search dialect flag set on a model through an overlay:
[dialects."anthropic/claude-sonnet-5".flags]server_search = truethe wire injects the provider’s own search tool (Anthropic and OpenAI Responses support it) and drops ka’s client-side web_search hand for that model, so no [[search]] API key is needed. The streamed query and sources surface as visible text; failed searches surface as errors, never as silence. Injection honors the web feature toggle: disable web and native search goes with it, fail-closed like every toggle. openai_chat refuses the flag with an instructive error.
The auth ladder
Section titled “The auth ladder”Keys are never written into config files. ka resolves each provider’s key through, in order:
- the environment (
ANTHROPIC_API_KEY, …) ./.envin the project~/.config/ka/.env(created0600)- the OS keyring (via
/key) !cmdindirection: the key is the stdout of a shell command (for vault setups)
# in .envANTHROPIC_API_KEY=sk-ant-…
# or in ka.toml contexts that take a command:# api_key = "!pass show anthropic"ka providers shows every vendor with its key env var and whether it is set.
Fallback chains
Section titled “Fallback chains”When a turn fails on the active model with a provider/auth error after retries are exhausted, ka re-dispatches the same messages on the next entry of your fallback chain (at most 2 hops per turn):
[fallback]models = [ "anthropic/claude-sonnet-5", "openai/gpt-5.1", "ollama/qwen3.5:9b",]