Plugin SDK reference
Plugin runtime helpers
Reference for the live api.runtime object available during "full", "discovery", "tool-discovery", and "setup-runtime" registration. During "cli-metadata" and "setup-only" registration, runtime capabilities are intentionally unavailable: accessing one throws an error naming the plugin and mode. Defer runtime access out of register() or, for root CLI commands, declare cliCommands in the plugin manifest. Use runtime helpers instead of importing host internals directly.
Step-by-step guide that uses these helpers in context for channel plugins.
Step-by-step guide that uses these helpers in context for provider plugins.
register(api) { const runtime = api.runtime;}api.runtime.version is the current OpenClaw product version, sourced from the shared version resolver so plugins see the same value the CLI reports.
What each page covers
- Config and utilities — runtime config reads and writes, plus the shared process, error, and model-picker utilities.
- Agent and sessions — agent identity, directories, session store, transcripts, and sandbox authority.
- Model helpers — host-owned completions, model-selection policy, and provider auth resolution.
- Background work — hook agent turns, subagent runs, and Task Flow record binding.
- Gateway and nodes — in-process Gateway requests, paired node invocation, and Gateway service events.
- Media helpers — speech, media understanding, image/video/music generation, web search, and media utilities.
- State and system — config snapshot, SQLite-backed plugin state, system utilities, events, and logging.
- Channel helpers — channel-specific runtime helper groups for chunking, routing, pairing, media, and mentions.
Runtime namespaces
Every api.runtime namespace and the page that documents it.
| Namespace | Page |
|---|---|
api.runtime.agent |
Agent and sessions |
api.runtime.agent.defaults |
Agent and sessions |
api.runtime.llm |
Model helpers |
api.runtime.gateway |
Gateway and nodes |
api.runtime.hooks |
Background work |
api.runtime.subagent |
Background work |
api.runtime.sandbox |
Agent and sessions |
api.runtime.nodes |
Gateway and nodes |
api.runtime.tasks |
Background work |
api.runtime.tts |
Media helpers |
api.runtime.mediaUnderstanding |
Media helpers |
api.runtime.imageGeneration |
Media helpers |
api.runtime.videoGeneration |
Media helpers |
api.runtime.musicGeneration |
Media helpers |
api.runtime.webSearch |
Media helpers |
api.runtime.media |
Media helpers |
api.runtime.config |
State and system |
api.runtime.system |
State and system |
api.runtime.events |
State and system |
api.runtime.logging |
State and system |
api.runtime.modelConfig |
Model helpers |
api.runtime.modelAuth |
Model helpers |
api.runtime.state |
State and system |
api.runtime.channel |
Channel helpers |
Storing runtime references
Use createPluginRuntimeStore to store the runtime reference for use outside the register callback:
Create the store
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";import type { PluginRuntime } from "openclaw/plugin-sdk/runtime-store"; const store = createPluginRuntimeStore<PluginRuntime>({ pluginId: "my-plugin", errorMessage: "my-plugin runtime not initialized",});Wire into the entry point
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/channel-core"; // `myPlugin` is your own `ChannelPlugin` object and `store` is the store// created in the previous step; neither is an SDK export.export default defineChannelPluginEntry({ id: "my-plugin", name: "My Plugin", description: "Example", plugin: myPlugin, setRuntime: store.setRuntime,});Access from other files
export function getRuntime() { return store.getRuntime(); // throws if not initialized} export function tryGetRuntime() { return store.tryGetRuntime(); // returns null if not initialized}Other top-level api fields
Beyond api.runtime, the API object also provides:
api.idstringPlugin id.
api.namestringPlugin display name.
api.configOpenClawConfigCurrent config snapshot (active in-memory runtime snapshot when available).
api.pluginConfigRecord<string, unknown>Plugin-specific config from plugins.entries.<id>.config.
api.loggerPluginLoggerScoped logger (debug, info, warn, error).
api.registrationModePluginRegistrationModeCurrent load mode: "full" (live activation), "discovery" / "tool-discovery" (read-only capability discovery), "setup-only" (lightweight setup entry), "setup-runtime" (setup flow that also needs the runtime channel entry), or "cli-metadata" (CLI command metadata collection).
api.resolvePath(input)(string) => stringResolve a path relative to the plugin root.
Where each section moved
Every section heading and namespace anchor from the previous single-page version keeps its anchor here, so an existing link such as /plugins/sdk-runtime#api-runtime-subagent still resolves. Each entry points at the page that now holds the content.
- Config loading and writes
- Reusable runtime utilities
- Stage timing diagnostics
- Plugin command runtime helpers
- Gateway service events
api.runtime.agentapi.runtime.agent.defaultsapi.runtime.llmapi.runtime.gatewayapi.runtime.hooksapi.runtime.subagentapi.runtime.sandboxapi.runtime.nodesapi.runtime.tasksapi.runtime.ttsapi.runtime.mediaUnderstandingapi.runtime.imageGenerationapi.runtime.videoGenerationapi.runtime.musicGenerationapi.runtime.webSearchapi.runtime.mediaapi.runtime.configapi.runtime.systemapi.runtime.eventsapi.runtime.loggingapi.runtime.modelConfigapi.runtime.modelAuthapi.runtime.stateapi.runtime.channel
Related
- Plugin internals — capability model and registry
- SDK entry points —
definePluginEntryoptions - SDK overview — subpath reference