Skip to content
Crystal CodeDocs
ENEnglish

Configuration

Host settings live in ~/.crystal/config.json. Provider and model definitions live in ~/.crystal/providers.json and in the files under ~/.crystal/providers/. The built-in DeepSeek, OpenAI, Gemini, and Ollama catalog is available even when none of them exist. Your definitions overlay it. Edit the file you changed, then restart. Editing provider definitions in the TUI is not available. <workspace>/.crystal/config.json is not read.

Provider files What is read
Any present The operator catalog. The legacy config.json.providers field is ignored
None The legacy field, including apiKey and apiKeyEnvironment

Saving preferences never rewrites a provider file. If no provider file exists and config.json still has a providers object, the save copies it to providers.json and keeps the original field. Later edits belong in the provider files.

Providers can be spread across several files. The host reads these, in order:

  1. ~/.crystal/providers.json
  2. ~/.crystal/providers/*.json
  3. ~/.crystal/providers/<category>/*.json

Every file has the same shape as providers.json: an object keyed by provider name, with an array under one name for several protocols. Comments and trailing commas are allowed. For example, ~/.crystal/providers/work/gateway.json:

{
"gateway": {
"protocol": "openai",
"baseUri": "https://gateway.example.test/v1/",
"models": { "model-id": { "contextWindow": 128000 } }
}
}

The <category> directory only groups files. It is not the provider name, does not appear in /model or the status bar, and does not change how providers merge. Use 1 to 64 characters: start with a letter, then letters, digits, ., _, or -. Any other name stops startup with an error that names the directory. Directories below a category and files that do not end in .json are not read.

A provider name may appear in only one file. If two files define the same name, startup stops and names both files. To offer several protocols under one name, put them in an array inside a single file. A malformed file also stops startup with its path in the error. Provider files are read from ~/.crystal only; a <workspace>/.crystal/providers directory is not read.

Top-level fields:

Field Meaning
provider Active provider name
model Active model id (must exist under that provider)
approval default, edit, review, audit, or full
approvalModel Optional reviewer. enabled, provider, model, and optional thinkingEffort, serviceTier, speed, and contextWindow. Omitted means off. enabled: false keeps a stored provider, model, and gear unused. A tier or speed applies to the reviewer only and must be listed by that model
pursueModel Checker for /pursue. Optional provider and model, thinkingEffort, serviceTier, speed, and contextWindow, with the same rules as topicModel. Without a model the session model checks. compaction (same shape as compactionModel) summarizes older entries for the checker; unset falls back to compactionModel, then to the checker’s model
pursueLimits Per-run bounds for /pursue: maximumContinuations (1000), maximumStalls (10, never unlimited), maximumModelCalls (10000), maximumToolCalls (100000), maximumDurationSeconds (7 days), and maximumWaitSeconds (3 hours). null is unlimited; "unlimited" unlimits all but stalls
topicModel Session topic naming. enabled (default off), and optional provider and model; without them the session model names the topic. thinkingEffort is the gear either way. With its own model, optional serviceTier, speed, and contextWindow apply to that model only. nameOnResume (default true) names a resumed session that has no topic after its next completed turn
extendedApproval Optional extended approval model for Review and Audit. enabled, provider, model, and optional thinkingEffort, serviceTier, speed, trigger (low, medium, or high; default low, which checks every review allow), and includePrimaryReview (default true). Omitted means off. It never falls back to the session or approval model
compactionModel Optional summarizer. enabled, provider, model, and optional thinkingEffort (default, off, or a gear that model lists). Omitted means off, and summaries use the session model. enabled: false keeps a stored provider, model, and gear unused. The model does not need imageInput. Opening it requires a catalog model; a missing credential or unknown model is refused and the saved value stays
imageModel, audioModel, videoModel, documentModel Resource description models. Each is enabled, provider, model, and optional thinkingEffort, serviceTier, speed, and contextWindow, like approvalModel. A model is on only with enabled: true. An enabled model must declare imageInput, audioInput, videoInput, or fileInput respectively in providers.json. Tools: describe_image, describe_audio, describe_video, and describe_document, respectively.
sessionStorage Select the save backend (sqlite by default, or json). sessionStorage
searchAllSessionStorages Read both backends when finding sessions (false by default)
thinkingEffort Host thinking gear: default, off (none is the same), or an effort token the model lists. max and maximum are different tokens. Tokens are stored in lowercase and sent unchanged
contextSelections Saved local context budgets as a nested map, for example {"openai": {"my-model": 272000}}. /context writes this map; the older flat {"openai/my-model": 272000} form is still read and is rewritten nested on the next save. An absent or unsupported choice uses that model’s lowest declared budget
tierSelections Saved service-tier tokens as a nested map, for example {"openai": {"my-model": "flex"}}. /tier writes this map. An absent choice, or a token the model no longer lists, omits the field
speedSelections Saved speed tokens in the same shape as tierSelections. /speed writes this map
skills Enable the skill tool and available-skill guidance (default true)
ruleFiles OpenCode-compatible rule files. global and project each default to true and are omitted until off. Does not affect instructions.md or .crystal.md
externalTools Enable operator tool set discovery (default true)
plugins Enable operator plugin discovery (default true)
mcp Connect configured MCP servers (default true; omitted when on)
mcpToolApproval Per-source trust for an MCP server’s read-only declarations: home and project, each author or host (both default host)
agents Child Agents. Omitted means off, concurrency 4, and the built-in Agents inherit the parent model. enabled, maxConcurrent (1–8), limits (maximumModelCalls, maximumToolCalls, maximumDurationSeconds; each child run is unlimited when omitted), and general, explore, and work model choices (provider, model, thinking, context, tier, speed). /agents writes built-in choices here. Custom Agents are stored in their own agent.json, not in this object
workspaceTrust Ask before the first interactive session in a directory (default true; omitted when on). Does not apply to crystal run
externalToolApproval Per-source trust for tool-set author declarations: home and project, each author or host (defaults Home author, Project host)
todoBar Show the pinned Todos bar above the status bar (default true; omitted when on)
todoBarRows Items the pinned Todos bar shows before +N more, from 3 to 10 (default 4; omitted when 4). Other values refuse startup
estimatedTokens Show a live four-characters-per-token estimate on the progress row during Thinking and Writing (default false)
verboseResults Parent switch for success result panels (default true; omitted when on). Off hides every success result already on screen, including read, search, skill, edit, write, bash, and background bash. Does not hide Tool cards; those follow verboseCalls. Failures stay. verboseTools and verboseCommands do not draw results while this is off. crystal run does not read it
verboseCalls Show Tool cards (default true; omitted when on). Off hides every Tool card already on screen: read, search, edit, write, bash, background bash, and external tools such as Apply Patch. Success and failure results stay. Independent of verboseResults, verboseTools, and verboseCommands. crystal run does not read it
verboseTools While verboseResults is on, show read, search, and skill result panels (default true; omitted when on). Edit and write results stay. No visible effect while verboseResults is off
verboseCommands While verboseResults is on, show full output from bash, bash_start, bash_status, bash_logs, and bash_stop (default true; omitted when on). Off keeps a hidden-line hint and the last line. No visible effect while verboseResults is off
verboseApprovals Show policy and grant auto-pass cards (default true; omitted when on). Off hides those cards already on screen. Review allow cards follow verboseReview. The ask overlay stays
verboseReview Show review allow cards (default true; omitted when on). Off hides those cards already on screen, including Outcome and rationale. Independent of verboseApprovals. The ask overlay, reviewer Deny text, and crystal run stay
verboseThinking Show Thinking panels in the interactive transcript (default true; omitted when on). Off hides live and restored cards. The gear, progress row, and export stay. crystal run --show-thinking is separate
exportDirectory Export root: omitted or home for {home}/exports, workspace for <workspace>/.crystal/exports, or any absolute/~ path
customStatusLine Enable the ordered custom status line (default false; the existing adaptive status line remains the default)
statusLine Ordered custom fields used only when customStatusLine is enabled. Built-in names are checked on load. An extra name is kept when it matches a plugin field name, even if that plugin is not loaded yet. An entry is a field name, or an object {"field": "model", "keep": true, "hideBelow": 100} (see Custom status line on narrow terminals)
statusLineDrop Optional list of statusLine fields to hide first when the custom line does not fit, in this order
statusLineTitleCase Show the prompt set name and a custom mode name in title case on the status line (default true; written only while false). Edit config.json; there is no slash command
compactionThreshold Fraction of the selected context budget that triggers compaction (greater than 0, at most 1; default 0.8)
reservedOutputTokens Optional positive tokens held back for the reply. Omitted derives the reservation from the window and the model maxTokens: the smallest of 20000, maxTokens, and a quarter of the window. The ceiling is the lesser of the threshold fraction and the budget minus this reservation. Raising it changes the ceiling and the reply cap only when the reservation is already the tighter of those two
showCompactionSummary Print the summary after a manual /compact (default true; omitted when on). /compact summary toggles it; on or off sets it
showAutomaticCompactionSummary Print the same summary after automatic compaction (default false; omitted when off). /compact auto toggles it (automatic is the same); on or off sets it. Does not change /compact
microCompaction Optional removal of old successful tool results before each model call. Omitted means off. Object with enabled (default false), protectTurns (at least 1, default 2), protectTokens (non-negative, default 40000), and minimumTokens (non-negative, default 20000). Invalid values stop startup. /compact micro toggles it; on or off sets it. Does not summarize
bashTimeoutSeconds Built-in bash per-command timeout. Omitted keeps 600 seconds. A positive integer up to 4,294,967 replaces it. null or "unlimited" disables that timer; cancelling the turn still stops the command
backgroundBashTimeoutSeconds bash_start background task timeout. Omitted keeps 10800 seconds (3 hours). A positive integer up to 4,294,967 replaces it. null or "unlimited" disables that timer; bash_stop and session shutdown still stop the task
retry Work-turn and compaction retry policy. Object with enabled (default true; false disables retries), maximumRetries (0-100, default 5), initialDelaySeconds (0-3600, default 2), backoffFactor (1-100, default 2), jitterFactor (0-1, default 0.25), and maximumDelaySeconds (0-86400, default 30; the backoff cap when Retry-After is absent). Invalid values stop startup. Work retries publish RetryScheduled
approvalRetry The same object shape for the Review and Audit approval reviewer. Independent of retry. Reviewer retries are silent; exhausted retries fall back to your approval prompt
server Defaults for crystal server. auth (token, the default, or none), apiBase (default /; path prefix for every route, such as /api), allowOrigins (origins such as https://app.example.test, no path, or * for any origin), allowHosts (extra Host values), exposeHeaders (extra Access-Control-Expose-Headers names), and allowPrivateNetwork (default false). The matching command-line options add to these, except --api-base, which replaces apiBase. crystal web uses the same lists but fixes the API prefix to /api. Invalid entries stop startup. See Server
theme Color theme name: built-in default (same as dark), dark, light, or a file ~/.crystal/themes/<name>.json (omitted when default). Set with /theme. It can also be an object, {"name": "night", "approvalColors": false}, where approvalColors (default true) colors the approval mode in the status bar with the theme’s approval colors
resourceTrim Limits how many resources, today images, each model request carries. Object with enabled (default true), keepRecent (default 16), slack (default 8), maxBytes (default 134217728, 0 for no budget), and includeUserResources (default false). /trim on or /trim off sets enabled. A provider entry in providers.json may set its own values
httpHeaders Headers sent to every model provider. Names are case-insensitive. An endpoint httpHeaders in providers.json replaces the whole global value for that endpoint, and null omits a header there. Do not put a provider-specific secret in global headers. Reserved names, invalid names or values, and non-string globals stop startup. Changes take effect after restart
bridge Which session options crystal bridge shows an editor as config options. customConfigOptions (default false) turns the list on. configOptions accepts the option ids in the Bridge catalog or ["all"]. workspaceTrust (default false) asks about editor-opened directories; the top-level workspaceTrust does not apply to Bridge. An unknown id or an empty list stops startup. See Bridge
web Defaults for crystal web beyond server. auth (none, the default, or token; a token source without --auth implies token) and spaFallback (default true; serves index.html for missing paths without extensions). `–spa-fallback on
operatorNotify Optional command run when the session waits for you. Omitted means off. command (executable and arguments, no shell), enabled (default true when command is set), events (approval, question, turn; default ["approval", "question"]), delaySeconds (0-3600, default 0), and timeoutSeconds (1-600, default 10). Invalid values stop startup. See Operator notification

Add named endpoints and model tables in providers.json, not in new config.json configurations.

operatorNotify runs a command you choose when the session needs you. There is no built-in command. For example, on macOS:

"operatorNotify": {
"command": ["osascript", "-e", "display notification (system attribute \"CRYSTAL_NOTIFY_TEXT\") with title \"CrystalCode\""],
"events": ["approval", "question", "turn"],
"delaySeconds": 5
}

On Linux, ["sh", "-c", "notify-send \"$CRYSTAL_NOTIFY_TITLE\" \"$CRYSTAL_NOTIFY_TEXT\""] does the same. Set "enabled": false to keep the command and stop notifications, or use /notify off.

Event When
approval A tool call waits for your approval, after any Review or Audit model judged it. Auto-pass and grants do not notify. Child approvals notify when their card opens
question The question tool or an MCP server asks you something
turn A turn ended and nothing queued started. An interrupted turn does not notify

With delaySeconds, the command runs only if you have not answered by then; for turn, the next submission cancels it. The command does not block the prompt. It runs in the workspace, inherits the CrystalCode environment, and gets these variables, plus the same values as one JSON object on stdin:

Variable Value
CRYSTAL_NOTIFY_EVENT approval, question, turn, or test
CRYSTAL_NOTIFY_TITLE CrystalCode
CRYSTAL_NOTIFY_TEXT One plain line, such as Approval needed: Run bash: git push
CRYSTAL_NOTIFY_TOOL, CRYSTAL_NOTIFY_SUMMARY, CRYSTAL_NOTIFY_RISK, CRYSTAL_NOTIFY_AUTHORITY Approval only
CRYSTAL_NOTIFY_HEADER, CRYSTAL_NOTIFY_QUESTION, CRYSTAL_NOTIFY_COUNT Question only: the first question and how many there are
CRYSTAL_NOTIFY_STOP Turn only: the stop reason, such as completed
CRYSTAL_WORKSPACE, CRYSTAL_SESSION Workspace root and session id

Each value is one line of at most 500 characters. An approval summary can quote the command or path being approved, so it reaches whatever your command sends it to, such as the system notification center or a webhook. Output is discarded. A command that cannot start, exits non-zero, or exceeds timeoutSeconds is stopped, and the first such failure in a session prints one note. crystal run never runs the command. Under crystal server it runs on the server host.

There is no global context window. Models that are not listed cannot be selected.

When the custom line is wider than the terminal, fields are hidden in this order until it fits:

  1. Fields with hideBelow set, when the terminal is narrower than that many columns.
  2. Fields listed in statusLineDrop, first entry first.
  3. All other fields, last field first.

A field with "keep": true is never hidden. If the keep fields alone are still too wide, the line is cut at the edge. These settings live in config.json only. /statusline shows them but does not change them. Setting a new field list with /statusline keeps the rules and hide order of fields that stay on the list.

{
"customStatusLine": true,
"statusLine": [
"approval",
{ "field": "context-used", "keep": true },
{ "field": "model", "hideBelow": 100 },
"workspace",
"elapsed"
],
"statusLineDrop": ["elapsed", "workspace"]
}

Here the model is hidden below 100 columns. On a narrower line elapsed goes first, then workspace, and context-used stays. keep and hideBelow cannot be used on the same field, and a keep field cannot be in statusLineDrop. A name in statusLineDrop or a rule must also be in statusLine. An invalid entry stops startup with an error. The adaptive line is unchanged.

Set httpHeaders in ~/.crystal/config.json for headers sent to every model provider. Set httpHeaders inside a provider endpoint in providers.json or a split provider file for that endpoint. Header names are case-insensitive. Each endpoint value replaces the entire global value; an endpoint value of null omits that header, while an empty string remains an empty value. Global values must be strings. With multiple protocol endpoints under one provider name, each endpoint uses its own headers. A user endpoint overlaid on a built-in endpoint merges its headers by name.

In config.json:

{ "httpHeaders": { "X-Client": "CrystalCode", "X-Region": "global" } }

Inside a provider endpoint:

"httpHeaders": { "X-Region": "local", "X-Client": null }

Do not put a provider-specific secret in global headers: they are sent to every selected model provider. Header values are not included in configuration error messages. Header names must be valid HTTP request header names, values must not contain control characters other than tab, and duplicate names differing only in case are invalid. Content headers and the transport headers Proxy-Authorization, Transfer-Encoding, and Connection are reserved. Built-in adapters also reserve Authorization, Accept, and the headers owned by their protocol. For example, Gemini reserves x-goog-api-key, Anthropic reserves x-api-key and anthropic-version, and OpenAI Chat Completions reserves OpenAI-Organization and OpenAI-Project. Conflicts are reported when a client for that protocol is created. Configure API keys using the existing credential settings.

You can override User-Agent and Host. An endpoint value wins over a global value, and an endpoint null restores the client default. The request URI still determines where to connect. With the built-in .NET HTTP transport, a custom Host also affects TLS server name indication (SNI) and certificate validation. An empty Host uses the URI host.

Changes take effect after restart. Disk plugins receive effective headers and are responsible for applying them and validating their protocol rules. MCP connections use their own header configuration.

Starter catalog (merged with providers.json):

Provider Protocol Default base URI Starter models
deepseek deepseek https://api.deepseek.com/ deepseek-flash, deepseek-v4-flash (compatibility alias), deepseek-v4-pro
openai openai https://api.openai.com/v1/ gpt-6.1-sol, gpt-6.1-terra, gpt-6-astra, gpt-6-sol, gpt-6-luna
gemini gemini https://generativelanguage.googleapis.com/v1beta/ gemini-4-carbon, gemini-4-argon, gemini-4-hydrogen
ollama ollama http://localhost:11434/ qwen3:8b (pull this model before selecting it)

Built-in DeepSeek V4 models enable thinking with efforts low, high, and max. Each has a 1,000,000-token context window. Starter OpenAI models use a 400,000-token window and do not enable thinking unless you add it. The Ollama starter assumes a 4,096-token local context. If the local model uses a different context size, set that size in providers.json and configure the Ollama model to match it. Other local or cloud model IDs may be added there. Automatically fetching model-list information from a provider is not available in this build.

Anthropic Messages is also a built-in protocol, but the starter catalog ships no entry for it, so Claude models come from providers.json. See Example: add an Anthropic (Claude) provider.

Field Meaning
protocol deepseek, openai, responses, anthropic, gemini, or ollama
baseUri Absolute API base URI; the adapter appends the protocol’s chat path
organization Optional OpenAI organization for the openai protocol
project Optional OpenAI project for the openai protocol
replayReasoningContent Replay provider reasoning content (DeepSeek always replays it); reasoning that cannot be replayed keeps its readable text (assistant text, or the protocol’s readable reasoning field)
requireAssistantContent openai protocol only. Send "content": "" for an assistant message that has only tool calls or reasoning, instead of null. Set it for gateways that reject a null content, such as Aliyun DashScope (“The content field is a required field”)
tokenLimit Chat Completions output field: max_tokens or max_completion_tokens (ignored by responses and anthropic)
apiKeyEnvironment Environment variable name checked first for this provider
apiKey Literal, {env:NAME}, or {file:path}
requiresApiKey Whether a missing key is an error (default true, except ollama; set false for an unauthenticated endpoint)
options Optional endpoint-wide protocol settings. Values are JSON strings, numbers, or booleans. Unknown names, and names that do not apply to protocol, fail loading
models Table of selectable model ids

Provider names are letters, digits, hyphen, or underscore.

All protocol adapters send the constant User-Agent: Crystal Code, with no version. responses authenticates with Authorization: Bearer; anthropic uses x-api-key and anthropic-version: 2023-06-01. Both adapters use direct HTTP and JSON/SSE handling; no provider SDK is required. Gemini uses x-goog-api-key and native generateContent SSE. Ollama uses native /api/chat JSON lines and omits authorization when no key is configured. For a provider with requiresApiKey: false, an explicit provider key or its specific environment variable is still used; CRYSTAL_API_KEY is skipped.

Amazon Bedrock models that support its OpenAI-compatible Chat Completions API can be configured with protocol: "openai", a regional https://bedrock-runtime.REGION.amazonaws.com/openai/v1/ base URI, and a Bedrock API key. This path uses bearer authentication. IAM SigV4 credentials are not supported by the current adapter.

Field Meaning
contextWindow Required positive maximum model context size in tokens. Upper bound for selectable local budgets; used as the sole budget when contextWindows is omitted or empty
contextWindows Optional distinct positive token budgets no greater than contextWindow, for example [272000, 1000000]. /context cycles these values; the lowest is the initial budget. Compaction and the status bar use the selected budget
options Optional JSON object interpreted by the selected adapter. Built-in adapters accept temperature (0 to 1 for Anthropic, 0 to 2 for the other built-in protocols) and topP (0 to 1) here. Omitted or null values use server defaults. Custom adapters define their own keys and values
maxTokens Optional positive output-token cap. The host lowers the cap a request asks for so the prompt and the reply fit the selected context budget. It never raises it. Anthropic Messages requires a cap on every request, so an anthropic model without maxTokens is sent 8192 and long replies stop at max_tokens. Declare maxTokens for every Claude model
thinking Whether the model accepts reasoning hints
thinkingEfforts Effort tokens this endpoint accepts. A token starts with a letter and then uses only letters, digits, underscores, and hyphens. max and maximum are different tokens. The host stores each token in lowercase and sends it unchanged
thinkingCanDisable Whether /thinking off is accepted (default true). Built-in Gemini 3 models set this to false
serviceTiers Service-tier tokens this model accepts. A token starts with a letter and then uses only letters, digits, underscores, and hyphens. The host stores each token in lowercase and does not interpret it. default is sent when it is listed; it does not mean unset. An empty or omitted list means this model has no service tier
speeds Speed tokens this model accepts, using the same token rules. fast and ultrafast belong here when the endpoint accepts them. An empty or omitted list means this model has no speed
imageInput Whether this model may receive images (default false; supported by all built-in protocols)
audioInput Declared audio input (default false). Stored and visible to plugins. The host does not accept or send audio
videoInput Declared video input (default false). Stored and visible to plugins. The host does not accept or send video
fileInput Declared file input (default false). Stored and visible to plugins
textTools Offer apply_patch to this model as a free-form tool, so it writes the patch as plain text instead of JSON (default false). Only the responses protocol supports it, and any other protocol refuses the declaration when the file loads. Turn it on only for a model that accepts custom tools

audioInput and videoInput only record the claim. Crystal Code stores them and shows them to plugins. It does not attach, paste, persist, or send audio or video, and those flags do not register multimodal tools. imageInput is still the only flag that allows image input. Service tier and speed are sent only when the active model lists the selected token. The host does not choose the JSON field and does not compare the response with the request. Chat Completions and OpenAI Responses write one set slot to service_tier and reject both when the client is created, before the choice is saved. Anthropic Messages writes service_tier and speed separately. DeepSeek, Gemini, and Ollama reject either slot when the client is created. A saved combination the protocol cannot send fails at startup. The endpoint address is not used to decide.

Gemini and Ollama native adapters accept inline images in user messages. Tool images are sent on Gemini functionResponse parts and on the Ollama tool message images array. Gemini tool images require a model that accepts multimodal function responses.

thinkingEffort is a host setting, not a model field. Changing models never fails: if the model does not support thinking, requests omit reasoning hints; if the stored gear is not in that model’s list, the request uses the provider default and the stored choice is unchanged. The host stores a listed token in lowercase and forwards that text. Adapters send the token unchanged. max and maximum are different tokens. openai and responses are also used for third-party gateways such as OpenRouter, so a catalog value is not renamed to xhigh. List xhigh, max, or maximum only when that endpoint accepts that spelling. Gemini 3 uppercases the token as thinkingLevel. Gemini 2.5 maps minimal, low, medium, and high to thinking budgets and rejects any other token. Anthropic requests summarized thinking text when thinking is on, unless that endpoint sets options.thinkingDisplay to omitted. An empty thinkingEfforts list is on/off only. When thinkingCanDisable is false, Off is left out of the gear. A stored Off choice uses the provider default and the status bar shows Think Default.

Example: add an OpenAI-compatible provider

Section titled “Example: add an OpenAI-compatible provider”

Add this entry to ~/.crystal/providers.json. Keep the secret out of this file. Write it in ~/.crystal/credentials.json under openrouter.

{
"openrouter": {
"protocol": "openai",
"baseUri": "https://openrouter.ai/api/v1/",
"replayReasoningContent": true,
"tokenLimit": "max_tokens",
"models": {
"anthropic/claude-sonnet-4": {
"contextWindow": 200000,
"options": { "temperature": 0.2 },
"maxTokens": 8192,
"thinking": true,
"thinkingEfforts": ["low", "medium", "high"]
}
}
}
}

OPENROUTER_API_KEY overrides that file when the process environment sets it. Restart after editing providers.json. Select the model with /model openrouter anthropic/claude-sonnet-4, or set provider and model in config.json. CLI --provider and --model override that selection for one run; /approval (including /approval model and /approval thinking), /thinking, /context, /tier, /speed, and /model write their values to config.json. /context stores each model’s selected budget in contextSelections. /tier and /speed store each model’s token in tierSelections and speedSelections.

Example: add an Anthropic (Claude) provider

Section titled “Example: add an Anthropic (Claude) provider”

Anthropic Messages is a built-in protocol, but the starter catalog ships no Anthropic entry, so Claude models are reached by adding one to ~/.crystal/providers.json. Write the key in ~/.crystal/credentials.json under anthropic.

{
"anthropic": {
"protocol": "anthropic",
"baseUri": "https://api.anthropic.com/v1/",
"models": {
"claude-sonnet-4": {
"contextWindow": 200000,
"maxTokens": 64000,
"thinking": true,
"thinkingEfforts": ["low", "medium", "high"],
"imageInput": true
}
}
}
}

ANTHROPIC_API_KEY overrides that file for one process. Restart after editing providers.json, then select the model with /model anthropic claude-sonnet-4, or set provider and model in config.json. The same entry reaches any Anthropic Messages gateway: change baseUri and the model id to match it. List the endpoint token in thinkingEfforts, such as max or xhigh. The adapter sends that token unchanged, and it asks for summarized thinking text whenever thinking is on. Set options.thinkingDisplay to omitted on this endpoint to leave the Anthropic display field off. summarized is the default and is not written back. The name is valid only for the anthropic protocol. Omit options.temperature and options.topP for models that reject sampling parameters. Thinking tokens count toward maxTokens.

Token usage for this protocol is the sum of input_tokens, cache_creation_input_tokens, and cache_read_input_tokens, because the adapter marks prompt-cache breakpoints and a cache hit leaves only a few uncached input tokens. Session totals, CTX percent, and usage-based compaction read that sum. When the endpoint reports no usage, the request counts as unknown, not zero, and the host falls back to its estimate. The adapter reports usage as soon as the request starts, so a request that is interrupted or fails mid-stream still counts its input tokens. Its output count is only what the endpoint had reported by then. A stream that ends without a stop_reason fails the request, and a retry follows the usual retry rules.

max_tokens and model_context_window_exceeded both end the turn as truncated output, and refusal ends it as filtered. pause_turn means the provider paused a server-side tool loop such as web search, so the turn sends the paused content back and continues on its own. Five pauses in a row fail the turn. Any other stop reason fails the turn and names the reason.

Crystal Code does not ask Anthropic to run server tools. If a gateway runs them anyway, their calls and results are kept in the transcript and sent back unchanged on later requests, but they are not shown in the terminal.

Example: add OpenCode Zen protocol endpoints

Section titled “Example: add OpenCode Zen protocol endpoints”

One gateway can group models that use different wire protocols under one provider name. Put this example in providers.json. The key for both endpoints belongs in credentials.json under opencode-zen. OPENCODE_ZEN_API_KEY overrides that file for one process.

{
"opencode-zen": [
{
"protocol": "responses",
"baseUri": "https://opencode.ai/zen/v1/",
"models": {
"gpt-5.6-sol": {
"contextWindow": 1050000,
"maxTokens": 128000,
"thinking": true,
"thinkingEfforts": ["low", "medium", "high", "maximum"],
"imageInput": true
}
}
},
{
"protocol": "anthropic",
"baseUri": "https://opencode.ai/zen/v1/",
"models": {
"claude-sonnet-5": {
"contextWindow": 1000000,
"maxTokens": 128000,
"thinking": true,
"thinkingEfforts": ["low", "medium", "high", "maximum"],
"imageInput": true
}
}
}
]
}

Add a protocol: "openai" object to the same array for Chat Completions models. Each model id must be unique within a provider. Listed efforts are sent as written. maximum is not rewritten to xhigh or max.