Skip to main content

Building Provider Plugins

This guide walks through building a provider plugin that adds a model provider (LLM) to OpenClaw. By the end you will have a provider with a model catalog, API key auth, and dynamic model resolution.
If you have not built any OpenClaw plugin before, read Getting Started first for the basic package structure and manifest setup.

Walkthrough

1

Package and manifest

The manifest declares providerAuthEnvVars so OpenClaw can detect credentials without loading your plugin runtime.
2

Register the provider

A minimal provider needs an id, label, auth, and catalog:
index.ts
That is a working provider. Users can now openclaw onboard --acme-ai-api-key <key> and select acme-ai/acme-large as their model.For bundled providers that only register one text provider with API-key auth plus a single catalog-backed runtime, prefer the narrower defineSingleProviderPluginEntry(...) helper:
If your auth flow also needs to patch models.providers.*, aliases, and the agent default model during onboarding, use the preset helpers from openclaw/plugin-sdk/provider-onboard. The narrowest helpers are createDefaultModelPresetAppliers(...), createDefaultModelsPresetAppliers(...), and createModelCatalogPresetAppliers(...).
3

Add dynamic model resolution

If your provider accepts arbitrary model IDs (like a proxy or router), add resolveDynamicModel:
If resolving requires a network call, use prepareDynamicModel for async warm-up — resolveDynamicModel runs again after it completes.
4

Add runtime hooks (as needed)

Most providers only need catalog + resolveDynamicModel. Add hooks incrementally as your provider requires them.
For providers that need a token exchange before each inference call:
OpenClaw calls hooks in this order. Most providers only use 2-3:For detailed descriptions and real-world examples, see Internals: Provider Runtime Hooks.
5

Add extra capabilities (optional)

A provider plugin can register speech, media understanding, image generation, and web search alongside text inference:
OpenClaw classifies this as a hybrid-capability plugin. This is the recommended pattern for company plugins (one plugin per vendor). See Internals: Capability Ownership.
6

Test

src/provider.test.ts

File structure

Catalog order reference

catalog.order controls when your catalog merges relative to built-in providers:

Next steps