Skip to main content
Use this guide if you want to add custom providers, local inference servers (such as Ollama, LM Studio, or vLLM), HTTP proxies, or remote compactors in ~/.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.json from the active agent directory. It doesn’t read project-scoped .atomic/models.json, fall back to ~/.pi/agent/models.json, or merge .pi and .atomic model files.
  • Syntax and schema. models.json supports // 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 /reload to reload without restarting. If models.json contains a JSON or schema error, Atomic ignores the file, keeps built-in providers working, and shows an error banner in /model.
For every schema field, see 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, only id 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:
Confirm that Atomic loaded your provider by opening /model (or running atomic --list-models) and selecting ollama/llama3.1:8b. Keep these validation rules in mind:
  • apiKey is optional in the schema: You can omit apiKey and 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-empty models or modelOverrides, apiKey, or authHeader. An empty {} object, or an entry containing only "models": [] or "modelOverrides": {}, fails validation.
  • Required fields for custom models: Any custom provider defining models requires baseUrl (unless overriding a built-in provider that already has one) and an api at either the provider or model level.

OpenAI-compatible server compatibility

Some OpenAI-compatible servers (such as Ollama, vLLM, or SGLang) reject the developer 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 an x-request-id. By default, Atomic sends a fresh universally unique identifier (UUID) for every Chat Completions or Responses attempt to api.openai.com, including retries. This doesn’t change the session ID or prompt-cache key. Tracing IDs, including Cloudflare’s cf-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 for openai-completions or openai-responses models whose endpoint explicitly documents support. Whether a duplicate is billed, and whether a retry can retrieve the original answer, depends on the endpoint.
For example, OP Inference supports idempotency keys for Chat Completions. Add the following provider to ~/.atomic/agent/models.json, export OP_API_KEY in the shell where you launch Atomic, and select /model op-inference/openai/gpt-oss-120b:
OP Inference returns 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, declare promptCache with positive lifetimes in seconds for short and long cache-retention tiers:
Replace the following:
  • GATEWAY_HOST: the hostname of your gateway, for example gateway.example.com.
  • GATEWAY_API_KEY: the environment variable name holding your gateway API key (keep the leading $).
Atomic’s cache warming runs only for retention tiers with a declared lifetime. If your endpoint doesn’t advertise a predictable prompt-cache time to live (TTL), omit that tier or omit 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:
Replace the following:
  • PROXY_HOST: the hostname of your HTTP proxy, for example proxy.example.com.

Add a Google AI Studio model

To add Google AI Studio models such as Gemma 4, configure google-generative-ai with a baseUrl and your Gemini API key:
Export 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 (enabledModels or --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.json or ~/.atomic. Sign-in and sign-out changes stay in effect even if an earlier background refresh finishes afterward.
  • Unsupported defaultProvider or defaultModel: 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 rejects prompt until you select a valid model.
For the full startup priority order and daily model switching, see Choose a model. For programmatic catalog persistence in SDK hosts, see Model catalog persistence and refresh.

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:
Replace the following:
  • COMPACTOR_HOST: the hostname of your compaction service, for example compact.example.com.
  • COMPACTOR_API_KEY: the environment variable name holding your compaction service API key (keep the leading $).
Every custom compactor requires "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-1 answers yes/no, choice, and score questions about text and images. It uses your saved /login google API key, GEMINI_API_KEY, or GOOGLE_API_KEY. See Gemini Decisions for supported inputs and limits.
  • OpenAI Decisions: openai-decisions/gpt-6-luna uses OpenAI’s Decisions API. It has no /login entry and reuses the first OpenAI API key found (openai-api, openai API key, then OPENAI_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 gateway 504 timeout that isn’t retried. (openai/gpt-6-luna always selects the chat model.)
  • TypeSafe Jev (direct): typesafe/jev-latest and typesafe/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), and github-copilot/gpt-6-luna-decisions (text and images), authenticated with Copilot OAuth or COPILOT_GITHUB_TOKEN.
  • Local llama.cpp: Native decision models and a next-token-probability fallback for chat models; see Local classification.
Open /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, and gpt-image-2.6-sunburst.
    • Authentication: No separate /login entry; reuses the first OpenAI API key found (openai-api, openai API key, then OPENAI_API_KEY), skipping ChatGPT sign-in. If you only signed in with ChatGPT, save a key with /login openai-api or set OPENAI_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 optional role: "markup" (on GPT Image 2.5 and later) or role: "mask" are mutually exclusive. Supported options include size, quality, n, background ("transparent" requires "png" or "webp"), outputFormat ("png", "jpeg", "webp", plus "svg" and "gif" on GPT Image 2.6), outputCompression (0–100 for JPEG and WebP), complexity ("low", "medium", or "high" on GPT Image 2.6), moderation, and safetyIdentifier (up to 128 characters).
    • SVG and animated GIF (GPT Image 2.6): outputFormat: "svg" requires n: 1 (or omitted); leave svg unset so Atomic retries automatically with gpt-6.1-sol if your account requires svg.model, or pass svg: { model, reasoning } to pin a specific authoring model. outputFormat: "gif" accepts frameCount (2–16, default 9) and frameDurationMs (20–2000, default 200, rounded to 10 ms).
  • OpenRouter (openrouter):
    • Reuses your OpenRouter credential (/login openrouter or OPENROUTER_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, and recraft/recraft-v4-pro-vector. OpenRouter image models ignore OpenAI-specific ImagesOptions.
    • 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 maxRetries greater than its default of 0 and the requested wait is within maxRetryDelayMs (60,000 ms by default).
The following codemode script generates an SVG icon with OpenAI Images:
To register a custom image provider or API, see Build custom providers.

Fallbacks and credentials

A model chain starts with a pinned model followed by fallbackModels 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). auto never selects an unauthenticated default model.
  • A provider that rejects credentials (HTTP 401 or an invalid, expired, revoked, or restricted key or token) is skipped for the rest of that chain. A model-scoped HTTP 403 skips 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.
For full fallback, model-scope, and subagent selection rules, see fallbackModels, enabledModels, CLI model options, and Automatic model selection.

Troubleshooting

Use these checks when a custom provider or model doesn’t behave as expected:
  • /model shows a models.json error banner: Fix the JSON syntax or schema error in ~/.atomic/agent/models.json (remember /* */ block comments and empty {} provider entries fail validation), then open /model or run /reload.
  • Custom local models don’t appear in /model: Confirm the provider has an apiKey (use a placeholder such as "ollama" for keyless local servers) or saved /login credential, and that you edited ~/.atomic/agent/models.json rather than a project-local .atomic/models.json.
  • A local OpenAI-compatible server returns HTTP 400: Set "supportsDeveloperRole": false and "supportsReasoningEffort": false under compat, then run /reload.
  • Image generation fails with ChatGPT sign-in: openai-images and openai-decisions skip ChatGPT sign-in and require an OpenAI API key. Save one with /login openai-api or export OPENAI_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.