grithdocs

[llm]

Provider and model for grith run and the REPL, and the three places an API key can come from.

This section only affects grith's own agent - grith run and the REPL. Supervising an external tool with grith exec does not use it: Claude Code, Codex and the rest bring their own model connections.

KeyDefault
default_provider"ollama"
ollama.base_url"http://localhost:11434"
ollama.model"llama3.1:8b"
openai.model"gpt-4o-mini"
anthropic.model"claude-sonnet-4-5-20250514"
openrouter.model"anthropic/claude-sonnet-4-5-20250514"

default_provider must be one of ollama, openai, anthropic or openrouter. Anything else is a fatal validation error.

toml
[llm]
default_provider = "anthropic"

[llm.anthropic]
model = "claude-sonnet-4-5-20250514"

grith config set accepts llm.default_provider, both Ollama keys, llm.openai.model and llm.anthropic.model. The OpenRouter model is edited in the file. GRITH_LLM_PROVIDER switches provider for one invocation without touching config.

⚠️Three model defaults move under an overlay

The OpenAI, Anthropic and OpenRouter model defaults are among the five keys that change value the moment any config file exists. See the sparse-file trap.

Where the API key comes from

Three sources, first hit wins:

  1. api_key in the config file. Explicit and highest priority.
  2. The environment variable named by api_key_env - OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY by default. Change the name if your environment uses a different one.
  3. A synced provider key at ~/.config/grith/provider-keys/<provider>.json, written by grith pro sync. Encrypted at rest and decrypted with your account key.

An empty value at any level falls through to the next.

Point at a differently-named variable

toml
[llm.anthropic]
api_key_env = "WORK_ANTHROPIC_KEY"

Ollama needs no key. If you only supervise external agents, this whole section can stay at its defaults.

See also

Last updated: 2026-08-24Edit this page on GitHub →