Skip to main content
Use this guide if you write Atomic extensions or embed Atomic through the TypeScript SDK and need dynamic model discovery, proxy overrides in code, custom OAuth sign-in, multi-account aliases, or a custom streaming protocol. Extensions register providers with atomic.registerProvider(), create multi-account aliases with atomic.registerProviderAlias(), and remove registrations with atomic.unregisterProvider(). If you only need to add chat or compactor models for an API Atomic already supports without writing TypeScript, configure ~/.atomic/agent/models.json instead (see Configure custom models). SDK hosts can register extension providers inline through extensionFactories (SDK extensions).

Before you begin

  • Install Atomic (see Installation).
  • Create an extension file under ~/.atomic/agent/extensions/<name>/ or .atomic/extensions/, or prepare an inline SDK extensionFactories function (see Author extensions).

Choose the right approach

The following table maps common goals to the right guide:

Guides and reference

Browse the focused guides and API reference to build each part of your custom provider:

Override a built-in provider

Change baseUrl or headers for a built-in provider while keeping its existing models and sign-in.

Register a custom provider

Register static or dynamically discovered models, choose a built-in API, add account aliases, or unregister a provider.

Add OAuth login

Integrate browser, device-code, or manual-code sign-in with /login, handle token refresh, and refresh catalogs.

Implement streaming

Build a custom streamSimple handler with stream events, tool calls, stop reasons, and usage cost calculation.

Custom provider API reference

Package imports and TypeScript interfaces for ProviderConfig, ProviderModelConfig, OAuth callbacks, and native Provider.

Quick reference

Register providers inside an async extension factory so Atomic waits for registration and model discovery before startup finishes:
Replace the following:
  • PROXY_HOST: the hostname of your Anthropic proxy, for example proxy.example.com.
  • API_HOST: the hostname of your custom provider API, for example api.example.com.
  • ACME_API_KEY: the environment variable name holding your provider API key (keep the leading $, or omit apiKey to sign in with /login acme-llm).

Registration and merge rules

Provider registration follows these runtime rules:
  • Await registration in the extension factory. Fetch and register dynamic models inside the async factory rather than session_start so the provider is available immediately at startup and in atomic --list-models.
  • Two registerProvider overloads. Pass (id, config) for config-object registration, or pass a native Provider instance from @bastani/atomic-ai (await atomic.registerProvider(provider)) for full control over authentication, model filtering, and persisted catalogs.
  • Repeated registrations merge defined fields. Calling registerProvider(id, config) again for the same id merges defined fields over the previous registration while leaving undefined fields untouched. Setting or replacing aliasOf resets the previous registration instead.
  • Interaction with models.json and credentials. Extension headers merge over models.json headers (extension values win on key collision), and models.json modelOverrides still apply on top of extension-registered chat and compactor models. See Credential resolution order.
  • Partial override versus full model replacement. Passing only baseUrl or headers for an existing provider preserves its built-in models. Supplying models replaces that provider’s models across chat, image, classifier, and compactor operations.

Required model fields

Every entry in models requires id, name, input, and cost. The following table lists the additional required and optional fields by model type:
When defining models, set baseUrl at the provider or model level unless overriding a built-in provider that already has one. Set api at the model level (or provider level for chat and compactor models) unless overriding a built-in provider that supplies defaults. When supplying a custom streamSimple, api is required at the provider level.

Mixed-operation providers

An omitted type defaults to "chat". Image and classifier entries require explicit type values and matching handlers in images or classifiers keyed by each model’s api. Compactor entries use type: "compactor" and follow the HTTP compactor request contract:
Replace the following:
  • MEDIA_HOST: the hostname of your media service, for example media.example.com.
  • MEDIA_TOOLS_API_KEY: the environment variable name holding your service API key (keep the leading $).
Model-level baseUrl overrides the provider endpoint. Equal model IDs across different operations (chat, image, classifier, compactor) stay distinct, including model-specific headers.

Verify your implementation

Test each provider and model pair against the scenarios in the following table before shipping:

Example extensions

Complete working examples are available in the Atomic repository: