Import map, registration API reference, and SDK architecture
You need to know which SDK subpath to import from
You want a reference for all registration methods on OpenClawPluginApi
You are looking up a specific SDK export
Plugin SDK Overview
The plugin SDK is the typed contract between plugins and core. This page is the
reference for what to import and what you can register.
**Looking for a how-to guide?**
- First plugin? Start with [Getting Started](/plugins/building-plugins)
- Channel plugin? See [Channel Plugins](/plugins/sdk-channel-plugins)
- Provider plugin? See [Provider Plugins](/plugins/sdk-provider-plugins)
The register(api) callback receives an OpenClawPluginApi object with these
methods:
Capability registration
Method
What it registers
api.registerProvider(...)
Text inference (LLM)
api.registerCliBackend(...)
Local CLI inference backend
api.registerChannel(...)
Messaging channel
api.registerSpeechProvider(...)
Text-to-speech / STT synthesis
api.registerMediaUnderstandingProvider(...)
Image/audio/video analysis
api.registerImageGenerationProvider(...)
Image generation
api.registerWebSearchProvider(...)
Web search
Tools and commands
Method
What it registers
api.registerTool(tool, opts?)
Agent tool (required or { optional: true })
api.registerCommand(def)
Custom command (bypasses the LLM)
Infrastructure
Method
What it registers
api.registerHook(events, handler, opts?)
Event hook
api.registerHttpRoute(params)
Gateway HTTP endpoint
api.registerGatewayMethod(name, handler)
Gateway RPC method
api.registerCli(registrar, opts?)
CLI subcommand
api.registerService(service)
Background service
api.registerInteractiveHandler(registration)
Interactive handler
CLI backend registration
api.registerCliBackend(...) lets a plugin own the default config for a local
AI CLI backend such as claude-cli or codex-cli.
The backend id becomes the provider prefix in model refs like claude-cli/opus.
The backend config uses the same shape as agents.defaults.cliBackends.<id>.
User config still wins. OpenClaw merges agents.defaults.cliBackends.<id> over the
plugin default before running the CLI.
Use normalizeConfig when a backend needs compatibility rewrites after merge
(for example normalizing old flag shapes).
Exclusive slots
Method
What it registers
api.registerContextEngine(id, factory)
Context engine (one active at a time)
api.registerMemoryPromptSection(builder)
Memory prompt section builder
api.registerMemoryFlushPlan(resolver)
Memory flush plan resolver
api.registerMemoryRuntime(runtime)
Memory runtime adapter
Memory embedding adapters
Method
What it registers
api.registerMemoryEmbeddingProvider(adapter)
Memory embedding adapter for the active plugin
registerMemoryPromptSection, registerMemoryFlushPlan, and
registerMemoryRuntime are exclusive to memory plugins.
registerMemoryEmbeddingProvider lets the active memory plugin register one
or more embedding adapter ids (for example openai, gemini, or a custom
plugin-defined id).
User config such as agents.defaults.memorySearch.provider and
agents.defaults.memorySearch.fallback resolves against those registered
adapter ids.
Events and lifecycle
Method
What it does
api.on(hookName, handler, opts?)
Typed lifecycle hook
api.onConversationBindingResolved(handler)
Conversation binding callback
Hook decision semantics
before_tool_call: returning { block: true } is terminal. Once any handler sets it, lower-priority handlers are skipped.
before_tool_call: returning { block: false } is treated as no decision (same as omitting block), not as an override.
message_sending: returning { cancel: true } is terminal. Once any handler sets it, lower-priority handlers are skipped.
message_sending: returning { cancel: false } is treated as no decision (same as omitting cancel), not as an override.
API object fields
Field
Type
Description
api.id
string
Plugin id
api.name
string
Display name
api.version
string?
Plugin version (optional)
api.description
string?
Plugin description (optional)
api.source
string
Plugin source path
api.rootDir
string?
Plugin root directory (optional)
api.config
OpenClawConfig
Current config snapshot
api.pluginConfig
Record<string, unknown>
Plugin-specific config from plugins.entries.<id>.config
Within your plugin, use local barrel files for internal imports:
my-plugin/
api.ts # Public exports for external consumers
runtime-api.ts # Internal-only runtime exports
index.ts # Plugin entry point
setup-entry.ts # Lightweight setup-only entry (optional)
Never import your own plugin through `openclaw/plugin-sdk/`
from production code. Route internal imports through `./api.ts` or
`./runtime-api.ts`. The SDK path is the external contract only.
Related
Entry Points — definePluginEntry and defineChannelPluginEntry options