~/.atomic/agent/models.json, or call built-in classifiers and image models. To store models.json in another directory, set ATOMIC_CODING_AGENT_DIR (or legacy PI_CODING_AGENT_DIR).
The following table directs you to the right page if you need a different task:
Before you begin
- Install Atomic (see Installation).
- Have your local server running (for example Ollama on
http://localhost:11434/v1) or your proxy URL and API key ready.
Keep three file rules in mind when editing
models.json:- Single file, no merging. Atomic reads only
models.jsonfrom the active agent directory. It doesn’t read project-scoped.atomic/models.json, fall back to~/.pi/agent/models.json, or merge.piand.atomicmodel files. - Syntax and schema.
models.jsonsupports//line comments, trailing commas, and leading UTF-8 byte order marks (BOMs);/* */block comments aren’t supported. Add"$schema": "https://raw.githubusercontent.com/bastani-inc/atomic/main/packages/coding-agent/schemas/models.schema.json"for editor validation and completion. - Reloading and validation errors. After you save
models.json, open/model, open/scoped-models, or run/reloadto reload without restarting. Ifmodels.jsoncontains a JSON or schema error, Atomic ignores the file, keeps built-in providers working, and shows an error banner in/model.
models.json field reference. For compatibility flags, value resolution, overrides, cost tiers, and derived fast variants, see Model runtime and overrides.
Add a local or OpenAI-compatible model
For local servers such as Ollama, LM Studio, or vLLM, onlyid is required per model. When needed, add explicit limits, modalities, pricing, and prompt cache lifetimes.
Add either the minimal or full configuration to ~/.atomic/agent/models.json:
- Minimal
- Full
/model (or running atomic --list-models) and selecting ollama/llama3.1:8b.
Keep these validation rules in mind:
apiKeyis optional in the schema: You can omitapiKeyand save a key later with/login <provider>. However, Atomic lists a provider’s models as available only when some credential is present, which is why local servers such as Ollama use a placeholder like"apiKey": "ollama".- Every provider entry must be non-empty: Include at least one of
baseUrl,headers,compat, non-emptymodelsormodelOverrides,apiKey, orauthHeader. An empty{}object, or an entry containing only"models": []or"modelOverrides": {}, fails validation. - Required fields for custom
models: Any custom provider definingmodelsrequiresbaseUrl(unless overriding a built-in provider that already has one) and anapiat either the provider or model level.
OpenAI-compatible server compatibility
Some OpenAI-compatible servers (such as Ollama, vLLM, or SGLang) reject thedeveloper role or reasoning_effort. Set compat flags at the provider level (applies to every model under that provider) or the model level (overrides provider defaults):
Request tracing and duplicate charges
Atomic sends tracing headers and optional idempotency keys with the following behavior:X-Client-Request-Id: Lets OpenAI look up a request even if the connection dropped before it returned anx-request-id. By default, Atomic sends a fresh universally unique identifier (UUID) for every Chat Completions or Responses attempt toapi.openai.com, including retries. This doesn’t change the session ID or prompt-cache key. Tracing IDs, including Cloudflare’scf-aig-event-id, don’t prevent duplicate execution or billing.- Z.ai and Zhipu Coding CN: Receive a fresh request ID on every attempt, including retries. The ID helps the provider look up a timed-out request; it doesn’t prevent duplicate work or charges.
Idempotency-Key: Signals a supporting endpoint not to run the same operation twice. Atomic keeps the same key across retries of one request and generates another key for the next request. This option is off by default. Enable it only foropenai-completionsoropenai-responsesmodels whose endpoint explicitly documents support. Whether a duplicate is billed, and whether a retry can retrieve the original answer, depends on the endpoint.
~/.atomic/agent/models.json, export OP_API_KEY in the shell where you launch Atomic, and select /model op-inference/openai/gpt-oss-120b:
409 idempotency_conflict for a duplicate chat completion instead of replaying the answer. Atomic stops retrying that request when it receives this error. If you configured a fallback model, Atomic can still try the fallback as a separate request, which might incur a separate charge. Don’t set a static Idempotency-Key in headers: a key must never be shared between unrelated requests.
Set prompt cache lifetimes
When configuring a custom model or overriding a built-in model, declarepromptCache with positive lifetimes in seconds for short and long cache-retention tiers:
GATEWAY_HOST: the hostname of your gateway, for examplegateway.example.com.GATEWAY_API_KEY: the environment variable name holding your gateway API key (keep the leading$).
promptCache altogether.
Proxy a built-in provider
To route a built-in provider through an HTTP proxy while keeping its built-in models, authentication, and derived-fast variants, set only baseUrl:
PROXY_HOST: the hostname of your HTTP proxy, for exampleproxy.example.com.
Add a Google AI Studio model
To add Google AI Studio models such as Gemma 4, configuregoogle-generative-ai with a baseUrl and your Gemini API key:
GEMINI_API_KEY, start Atomic from that shell, then open /model and select google-studio/gemma-4-31b-it to confirm that it appears.
Catalog refresh and startup defaults
/model and /scoped-models display cached authenticated catalogs immediately while refreshing network-backed catalogs in the background for up to 15 seconds. Closing either picker cancels the refresh. From the shell, use --model, --models, --list-models and atomic update --models to inspect or refresh catalogs.
Catalog refreshes and startup defaults follow these rules:
- Direct
/model <provider/model>: Without an active model scope (enabledModelsor--models),/model <provider/model>checks cached models first and waits for a network refresh only on a miss. With a scope active,/model <provider/model>searches only scoped models without triggering a refresh. - Failed or slow refreshes: If a refresh times out or fails, Atomic keeps showing cached models; you don’t need to reset
auth.jsonor~/.atomic. Sign-in and sign-out changes stay in effect even if an earlier background refresh finishes afterward. - Unsupported
defaultProviderordefaultModel: Saved defaults resolve after built-in,models.json, and extension providers finish loading. If the saved provider is still unsupported, interactive mode warns and leaves model selection open, print and JSON modes write the error to stderr and exit nonzero (keeping JSON stdout valid JSON Lines (JSONL)), and remote procedure call (RPC) mode rejectspromptuntil you select a valid model.
Add a remote compaction model
To add a custom remote compaction endpoint, set"type": "compactor" on a model entry (or override built-in morph/morph-compactor parameters under modelOverrides). Custom compactor models never appear in /model; they appear automatically under /settings → Compaction model:
COMPACTOR_HOST: the hostname of your compaction service, for examplecompact.example.com.COMPACTOR_API_KEY: the environment variable name holding your compaction service API key (keep the leading$).
"api" at the provider or model level (built-in Morph defines "api": "morph-compact"). Atomic sends { messages, query, model } plus any keys in compactionParams (omitting compactionParams lets the remote API apply its own defaults). Compactor output has no built-in size cap; to reject output longer than a target token count, set maxTokens on the compactor model, or pass the endpoint’s own compression parameter in compactionParams. See Configure Morph or add a custom compactor and Compaction reference.
Use classifier models
Classifier models answer typed questions (choice, bool, score) about structured JSON state instead of generating chat replies, and they don’t appear in /model. Choose a classifier for Atomic’s structured-decision tool (structured_output) and SDK or extension decisions (decide()) with decisionModel (unset by default; see Structured decisions), or call classifiers directly from codemode with models.getAvailableOfType("classifier") and models.classify().
Atomic includes the following built-in classifiers:
- Gemini Decisions:
google-decisions/gemini-decision-1answers yes/no, choice, and score questions about text and images. It uses your saved/login googleAPI key,GEMINI_API_KEY, orGOOGLE_API_KEY. See Gemini Decisions for supported inputs and limits. - OpenAI Decisions:
openai-decisions/gpt-6-lunauses OpenAI’s Decisions API. It has no/loginentry and reuses the first OpenAI API key found (openai-api,openaiAPI key, thenOPENAI_API_KEY), skipping ChatGPT sign-in. It accepts up to 128 images and up to 922K tokens; requests exceeding roughly 600K tokens might hit a gateway504timeout that isn’t retried. (openai/gpt-6-lunaalways selects the chat model.) - TypeSafe Jev (direct):
typesafe/jev-latestandtypesafe/jev-1.14.0(up to 262K tokens with PNG or JPEG images; see TypeSafe Jev). - Cloudflare Workers AI: Cloudflare Clef (
@cf/cloudflare/clef,@cf/cloudflare/clef-flash,@cf/cloudflare/clef-omni, up to four PNG, JPEG, or WebP images) and TypeSafe Jev (typesafe/jev,typesafe/jev-1.14.0, PNG or JPEG images). - OpenRouter: TypeSafe Jev (
~typesafe/jev-latest,typesafe/jev-1.13,typesafe/jev-1.14), Cloudflare Clef, and third-party classifiers such as Liquid D1 (~liquid/d1-latest), Perplexity Decider (~perplexity/pplx-decider-latest), Baseten (baseten/bison-1), Microsoft Decision (microsoft/microsoft-decision-1.1), Morph Reflex (morph/reflex), and Respan. - Vercel AI Gateway and OpenCode Zen: Text-only TypeSafe Jev plus additional Vercel AI Gateway classifiers (including Baseten Bison and Mammoth, Liquid D1.2, Microsoft Decision 1 and 1.1, Perplexity Decider, Google Gemini Decision 1, and OpenAI GPT-6 Luna Decisions).
- GitHub Copilot:
github-copilot/microsoft-decision-1,github-copilot/microsoft-decision-1.1(text only, 32,768-token context), andgithub-copilot/gpt-6-luna-decisions(text and images), authenticated with Copilot OAuth orCOPILOT_GITHUB_TOKEN. - Local llama.cpp: Native decision models and a next-token-probability fallback for chat models; see Local classification.
/settings → Decision model or run models.getAvailableOfType("classifier") in codemode to see every classifier available for your authenticated providers.
Built-in classifiers don’t retry when the provider reports that your account is out of quota. Temporary throttles can still retry if the provider’s requested wait fits within the retry limit. If you call models.classify() directly, failure results include retryAfterMs when the provider supplied a delay, even if it exceeded the limit. SDK callers can set the limit with maxRetryDelayMs (60,000 ms by default, 0 to disable it). If your quota is exhausted, wait for it to reset, replenish it, or choose a different provider.
TypeSafe’s System One classifier protocol (/v1/systemone)—also used by Cloudflare Workers AI, OpenRouter, GitHub Copilot, and Vercel AI Gateway classifiers—accepts different image request layouts depending on the host, controlled by compat.imageInput ("assets", "images", or "state-image-urls"). Built-in entries configure this automatically, so overriding baseUrl preserves it. For a custom proxy targeting another classifier service, set imageInput and sendImageOptInHeader in provider-level compat (for example, a proxy in front of OpenRouter needs "imageInput": "state-image-urls" and "sendImageOptInHeader": false so OpenRouter doesn’t silently drop images). See System One compatibility.
Use image models
Image models generate and edit images instead of chatting and never appear in/model. Call them from codemode with models.getAvailableOfType("image") and models.generateImages(), or from an extension with ctx.modelRegistry.generateImages().
Atomic includes two built-in image providers:
- OpenAI Images (
openai-images):- Models:
gpt-image-1,gpt-image-1-mini,gpt-image-1.5,gpt-image-2,gpt-image-2.5-flare,gpt-image-2.5-sunburst,gpt-image-2.6-flare, andgpt-image-2.6-sunburst. - Authentication: No separate
/loginentry; reuses the first OpenAI API key found (openai-api,openaiAPI key, thenOPENAI_API_KEY), skipping ChatGPT sign-in. If you only signed in with ChatGPT, save a key with/login openai-apior setOPENAI_API_KEY. - Editing and options: Pass text and image blocks in
input. The first untagged image is the base image, extra untagged images are references, and optionalrole: "markup"(on GPT Image 2.5 and later) orrole: "mask"are mutually exclusive. Supported options includesize,quality,n,background("transparent"requires"png"or"webp"),outputFormat("png","jpeg","webp", plus"svg"and"gif"on GPT Image 2.6),outputCompression(0–100for JPEG and WebP),complexity("low","medium", or"high"on GPT Image 2.6),moderation, andsafetyIdentifier(up to 128 characters). - SVG and animated GIF (GPT Image 2.6):
outputFormat: "svg"requiresn: 1(or omitted); leavesvgunset so Atomic retries automatically withgpt-6.1-solif your account requiressvg.model, or passsvg: { model, reasoning }to pin a specific authoring model.outputFormat: "gif"acceptsframeCount(2–16, default9) andframeDurationMs(20–2000, default200, rounded to 10 ms).
- Models:
- OpenRouter (
openrouter):- Reuses your OpenRouter credential (
/login openrouterorOPENROUTER_API_KEY). - Exposes multi-vendor image models through OpenRouter’s image generation API—such as
google/gemini-2.5-flash-image,google/gemini-3-pro-image,black-forest-labs/flux.2-pro,black-forest-labs/flux-3-image,openai/gpt-image-2.6-flare, andrecraft/recraft-v4-pro-vector. OpenRouter image models ignore OpenAI-specificImagesOptions. - If OpenRouter reports that the account is out of quota, Atomic returns the error without retrying. Wait for the quota to reset, replenish it, or use another provider. Temporary throttles can still retry if an SDK caller sets
maxRetriesgreater than its default of0and the requested wait is withinmaxRetryDelayMs(60,000 ms by default).
- Reuses your OpenRouter credential (
Fallbacks and credentials
A model chain starts with a pinned model followed byfallbackModels in a session or subagent; model: "auto" starts with your configured default model. Atomic evaluates candidates in the chain with these rules:
- Candidates whose providers lack credentials are skipped before any request (recorded in session history and subagent run details).
autonever selects an unauthenticated default model. - A provider that rejects credentials (
HTTP 401or an invalid, expired, revoked, or restricted key or token) is skipped for the rest of that chain. A model-scopedHTTP 403skips only that model. - A chain with no usable candidate fails immediately and names each skipped model and provider. A single pinned model with no fallbacks is never replaced.
fallbackModels, enabledModels, CLI model options, and Automatic model selection.
Troubleshooting
Use these checks when a custom provider or model doesn’t behave as expected:/modelshows amodels.jsonerror banner: Fix the JSON syntax or schema error in~/.atomic/agent/models.json(remember/* */block comments and empty{}provider entries fail validation), then open/modelor run/reload.- Custom local models don’t appear in
/model: Confirm the provider has anapiKey(use a placeholder such as"ollama"for keyless local servers) or saved/logincredential, and that you edited~/.atomic/agent/models.jsonrather than a project-local.atomic/models.json. - A local OpenAI-compatible server returns
HTTP 400: Set"supportsDeveloperRole": falseand"supportsReasoningEffort": falseundercompat, then run/reload. - Image generation fails with ChatGPT sign-in:
openai-imagesandopenai-decisionsskip ChatGPT sign-in and require an OpenAI API key. Save one with/login openai-apior exportOPENAI_API_KEY.
Next steps
Model runtime and overrides
Supported APIs, secret and header resolution, overrides, cost tiers, fast variants, and API compatibility rules.
models.json field reference
Complete schema table for every provider, model, override, and compatibility field.