Plugin Runtime
Native OpenClaw plugins receive a trusted runtime throughapi.runtime.
Use it for host-owned operations that should stay inside OpenClaw’s runtime:
- reading and writing config
- agent/session helpers
- system commands with OpenClaw timeouts
- media, speech, image-generation, and web-search runtime calls
- channel-owned helpers for bundled channel plugins
When to use runtime vs focused SDK helpers
- Use focused SDK helpers when a public subpath already models the job.
- Use
api.runtime.*when the host owns the operation or state. - Prefer hooks for loose integrations that do not need tight in-process access.
Runtime namespaces
| Namespace | What it covers |
|---|---|
api.runtime.config | Load and persist OpenClaw config |
api.runtime.agent | Agent workspace, identity, timeouts, session store |
api.runtime.system | System events, heartbeats, command execution |
api.runtime.media | File/media loading and transforms |
api.runtime.tts | Speech synthesis and voice listing |
api.runtime.mediaUnderstanding | Image/audio/video understanding |
api.runtime.imageGeneration | Image generation providers |
api.runtime.webSearch | Runtime web-search execution |
api.runtime.modelAuth | Resolve model/provider credentials |
api.runtime.subagent | Spawn, wait, inspect, and delete subagent sessions |
api.runtime.channel | Channel-heavy helpers for native channel plugins |
Example: read and persist config
Example: use a runtime service owned by OpenClaw
createPluginRuntimeStore(...)
Plugin modules often need a small mutable slot for runtime-backed helpers. Use
plugin-sdk/runtime-store instead of an unguarded let runtime.
createPluginRuntimeStore(...) gives you:
setRuntime(next)clearRuntime()tryGetRuntime()getRuntime()
getRuntime() throws with your custom message if the runtime was never set.
Channel runtime note
api.runtime.channel.* is the heaviest namespace. It exists for native channel
plugins that need tight coupling with the OpenClaw messaging stack.
Prefer narrower subpaths such as:
plugin-sdk/channel-pairingplugin-sdk/channel-actionsplugin-sdk/channel-feedbackplugin-sdk/channel-lifecycle
api.runtime.channel.* when the operation is clearly host-owned and there
is no smaller public seam.
Runtime safety guidelines
- Do not cache config snapshots longer than needed.
- Prefer
createPluginRuntimeStore(...)for shared module state. - Keep runtime-backed code behind small local helpers.
- Avoid reaching into runtime namespaces you do not need.