Skip to content

Config

asksh reads its configuration from ~/.config/asksh/config.toml (or $ASKSH_CONFIG_DIR/config.toml, $XDG_CONFIG_HOME/asksh/config.toml, or --config <path>). Running asksh setup generates this file with 0600 permissions.

Top-level settings

Key Type Default Description
base_url string "" Provider endpoint base URL (required via config, ASKSH_BASE_URL, or --base-url)
provider string "openai" Wire protocol: "openai" ("openai-compatible"), "anthropic" ("claude"), or "gemini" ("google")
api_key string or table unset Literal string, { env = "VAR" }, or { cmd = { run = "...", args = [...] } }
model string "" Default model ID or alias from [[models]] (required unless [routing] supplies fast_model or strong_model)
tier string "" Optional metadata tier ("fast" or "strong")
session_continue string "1h" Window to resume a session in the same repo/directory ("1h", bare number as minutes such as "60", or "0" to disable)
yolo bool false Auto-approve tool calls and allow high-danger -x execution
history_file string "" Override shell history file path (~ and $VAR expanded)

If history_file is unset, asksh checks $HISTFILE, then ~/.zsh_history, ~/.bash_history, and $XDG_DATA_HOME/fish/fish_history (or ~/.local/share/fish/fish_history) ordered by your detected shell.

API keys (api_key)

api_key accepts three forms:

# 1. Environment variable (trimmed of leading/trailing whitespace)
api_key = { env = "OPENROUTER_API_KEY" }

# 2. Subprocess command (10s timeout; trailing CR/LF stripped)
api_key = { cmd = { run = "op", args = ["read", "op://Private/OpenRouter/credential"] } }

# 3. Literal string
api_key = "sk-or-v1-..."

Custom headers and body ([headers] and [body])

Use [headers] to attach HTTP headers to requests. Any {{api_key}} placeholder in a header value is replaced with the resolved API key:

[headers]
HTTP-Referer = "https://greendale.edu"
X-Title = "asksh"

Use [body] to merge extra JSON fields into the request body (core fields such as model, messages or contents, stream, and tools take precedence):

[body]
temperature = 0.2

When omitted from [body], Anthropic requests default max_tokens to 4096 and OpenAI requests default stream_options to { include_usage = true }.

Providers

Set provider to select the wire protocol:

  • "openai" (or "openai-compatible"): OpenAI Chat Completions (POST <base_url>/chat/completions)
  • "anthropic" (or "claude"): Anthropic Messages API (POST <base_url>/messages)
  • "gemini" (or "google"): Gemini streamGenerateContent SSE API (POST <base_url>/models/<model>:streamGenerateContent?alt=sse)

Setting provider explicitly for Anthropic and Gemini

When provider is empty or omitted, asksh uses "openai". It does not auto-detect "anthropic" or "gemini" from base_url or model. Set provider = "anthropic" or provider = "gemini" explicitly when targeting those native APIs.

base_url = "https://openrouter.ai/api/v1"
api_key = { env = "OPENROUTER_API_KEY" }
model = "anthropic/claude-sonnet-4"
provider = "anthropic"
base_url = "https://api.anthropic.com"
api_key = { env = "ANTHROPIC_API_KEY" }
model = "claude-sonnet-4-20250514"
provider = "gemini"
base_url = "https://generativelanguage.googleapis.com"
api_key = { env = "GEMINI_API_KEY" }
model = "gemini-2.5-pro"
base_url = "https://api.deepseek.com/v1"
api_key = { env = "DEEPSEEK_API_KEY" }
model = "deepseek-chat"
base_url = "http://localhost:11434/v1"
model = "qwen2.5-coder:7b"

[capabilities]

Controls which built-in client tools are offered to the model:

Key Default Controlled tools
enable_history_search true shell_history
enable_file_tools true read_file, edit_file, write_file, grep_files, glob_files
enable_command_execution true execute_shell_command

command_help is always enabled. load_skill is offered whenever invocable skills exist, and external MCP tools are offered whenever configured under [[mcp_servers]].

[opening]

Controls what context is included in the initial system prompt:

Key Default Description
send_cwd true Include current working directory in the system prompt
send_last_command false Include the last command from your native shell history file

[[models]]

Define named model profiles for /model switching or model = "<alias>":

[[models]]
alias = "sonnet"
name = "Claude Sonnet via OpenRouter"
description = "Balanced reasoning and speed"
model = "anthropic/claude-sonnet-4"

[[models]]
alias = "local"
name = "Local Ollama"
description = "Qwen 2.5 Coder on localhost"
provider = "openai"
tier = "fast"
model = "qwen2.5-coder:7b"
base_url = "http://localhost:11434/v1"
api_key = ""

Supported keys per entry: alias, name, description, model, provider, tier, base_url, api_key, headers, and body. Resolution checks alias first and then model. Non-empty fields override top-level settings, and headers and body merge over top-level tables.

[routing]

Opt-in routing between a fast model and a strong model per turn:

[routing]
enabled = true
fast_model = "local"
strong_model = "sonnet"

When enabled = true (and you did not override the model with --model or /model), asksh selects strong_model if any of these hold:

  • Tool calls already ran earlier in the current turn.
  • The prompt contains a newline or has at least 160 characters (runes).
  • The prompt contains multi-step or diagnostic phrases (multi-step, step by step, step-by-step, stack trace, exit code) or keywords (fix, debug, diagnose, troubleshoot, investigate, refactor, migrate, analyze, analyse, review, optimize, plan, error, failed, failing, failure, broken, crash, panic, traceback).

Otherwise it selects fast_model, including for mid-buffer assists. If the chosen tier is empty, it falls back to top-level model.

[[mcp_servers]]

Configures external MCP servers over stdio or http. See MCP servers.

Environment overrides

These environment variables override values loaded from config.toml:

Variable Overrides
ASKSH_BASE_URL base_url
ASKSH_API_KEY api_key (treated as a literal string)
ASKSH_MODEL model
ASKSH_YOLO yolo (1/true/0/false)
ASKSH_SESSION_CONTINUE session_continue
ASKSH_HISTORY_FILE history_file
ASKSH_ENABLE_HISTORY_SEARCH capabilities.enable_history_search
ASKSH_ENABLE_FILE_TOOLS capabilities.enable_file_tools
ASKSH_ENABLE_COMMAND_EXECUTION capabilities.enable_command_execution
ASKSH_SEND_CWD opening.send_cwd
ASKSH_SEND_LAST_COMMAND opening.send_last_command

There is no ASKSH_PROVIDER environment variable; set provider in config.toml. See Paths and environment variables for all environment variables read by asksh.