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 SDKextensionFactoriesfunction (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 anasync extension factory so Atomic waits for registration and model discovery before startup finishes:
PROXY_HOST: the hostname of your Anthropic proxy, for exampleproxy.example.com.API_HOST: the hostname of your custom provider API, for exampleapi.example.com.ACME_API_KEY: the environment variable name holding your provider API key (keep the leading$, or omitapiKeyto 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
asyncfactory rather thansession_startso the provider is available immediately at startup and inatomic --list-models. - Two
registerProvideroverloads. Pass(id, config)for config-object registration, or pass a nativeProviderinstance 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 sameidmerges defined fields over the previous registration while leavingundefinedfields untouched. Setting or replacingaliasOfresets the previous registration instead. - Interaction with
models.jsonand credentials. Extensionheadersmerge overmodels.jsonheaders(extension values win on key collision), andmodels.jsonmodelOverridesstill apply on top of extension-registered chat and compactor models. See Credential resolution order. - Partial override versus full model replacement. Passing only
baseUrlorheadersfor an existing provider preserves its built-in models. Supplyingmodelsreplaces that provider’s models across chat, image, classifier, and compactor operations.
Required model fields
Every entry inmodels 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 omittedtype 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:
MEDIA_HOST: the hostname of your media service, for examplemedia.example.com.MEDIA_TOOLS_API_KEY: the environment variable name holding your service API key (keep the leading$).
baseUrl overrides the provider endpoint. Equal model IDs across different operations (chat, image, classifier, compactor) stay distinct, including model-specific headers.