On this page
On this page
CLI commands
Inference CLI
openclaw infer is the main headless command for provider-backed inference. It exposes capability families (model, image, audio, tts, video, web, embedding), not raw gateway RPC names or agent tool ids. openclaw capability ... is an alias for the same command tree.
Reasons to prefer it over a one-off provider wrapper:
- Reuses providers and models already configured in OpenClaw.
- Stable
--jsonenvelope for scripts and agent-driven automation (see JSON output). - Runs the normal local path without the gateway for most subcommands.
- For end-to-end provider checks, it exercises the shipped CLI, config loading, default-agent resolution, bundled plugin activation, and the shared capability runtime before the provider request goes out.
Command tree
infer list / infer inspect --name <capability> show this tree as data (capability id, transports, description).
Parent and subcommand help expose the full inference command tree without loading provider execution runtimes. These command definitions also supply inference shell-completion metadata.
Common tasks
| Task | Command | Notes |
|---|---|---|
| Run a text/model prompt | openclaw infer model run --prompt "..." --json |
Local by default |
| Run a model prompt on images | openclaw infer model run --prompt "Describe this" --file ./image.png --model provider/model |
Repeat --file for multiple images |
| Generate an image | openclaw infer image generate --prompt "..." --json |
Use image edit when starting from an existing file |
| Describe an image file or URL | openclaw infer image describe --file ./image.png --prompt "..." --json |
--model must be an image-capable <provider/model> |
| Transcribe audio | openclaw infer audio transcribe --file ./memo.m4a --json |
--model must be <provider/model> |
| Synthesize speech | openclaw infer tts convert --text "..." --output ./speech.mp3 --json |
tts status only runs through the gateway |
| Generate a video | openclaw infer video generate --prompt "..." --json |
Supports provider hints such as --resolution |
| Describe a video file | openclaw infer video describe --file ./clip.mp4 --json |
--model must be <provider/model> |
| Search the web | openclaw infer web search --query "..." --json |
|
| Fetch a web page | openclaw infer web fetch --url https://example.com --json |
|
| Create embeddings | openclaw infer embedding create --text "..." --json |
Behavior
- Use
--jsonwhen the output feeds another command or script; text output otherwise. - Use
--provideror--model provider/modelto pin a specific backend. - Explicitly empty or whitespace-only values for
--limit,--count,--duration, and--timeout-msare errors. Omit the flag to retain its default behavior. image editandimage describe-manyrequire at least one--file;embedding createrequires at least one--text. Repeat the flag for multiple inputs. Omitting it is a usage error, not an empty successful result, and no inference request is sent.- Use
model run --thinking <level>for a one-shot thinking/reasoning override:off,minimal,low,medium,high,adaptive,xhigh, ormax. - For
image describe,audio transcribe, andvideo describe,--modelmust use the form<provider/model>. - For
image describe,--fileaccepts local paths and HTTP(S) URLs; remote URLs go through the normal media-fetch SSRF policy. - Stateless execution commands (
model run,image *,audio *,video *,web *,embedding *) default to local. Gateway-managed state commands (tts status) default to gateway. - The local path never requires the gateway to be running.
- Provider inventory commands whose
configuredstate can come from saved agent auth accept--agent <id>. Without it, they useagents.defaults.systemAgent.agentIdor the sole configured agent; explicit multi-agent fleets with no system owner must pass--agent. The provider catalog remains aggregate;--agentscopes saved-auth and per-agent selection facts. Gateway-owned TTS provider state remains Gateway-global, sotts providers --gatewaydoes not accept--agent. - Commands that resolve agent-owned model or auth state (
model run,image generate,image edit,image describe,image describe-many,audio transcribe,video generate,video describe,embedding create, andmodel auth login/logout/status) also accept--agent <id>. They resolve an explicit id first, thenagents.defaults.systemAgent.agentId, then the sole configured agent. - Generated image and video
--outputfiles are staged beside the destination and replace it only after the complete buffer is written; a failed write leaves an existing destination unchanged. An interrupt cancels image generation or editing and discards late provider results before output writes begin. It also stops an in-progress provider-URL video download instead of letting it finish and publish a late result. - Ctrl-C or SIGTERM cancels image description downloads and provider requests, and prevents later model fallback attempts.
- Local
model runis a lean one-shot provider completion: it resolves the configured agent model and auth but does not start a chat-agent turn, load tools, or open bundled MCP servers. - Model runs load the catalog for case correction only when an explicit model override contains uppercase characters. Runs using the configured default or a lowercase model ref skip that catalog lookup.
model run --fileattaches image files (auto-detected MIME type) to the prompt; repeat--filefor multiple images. Non-image files are rejected — useinfer audio transcribeorinfer video describeinstead.- Local
model run --filerequires an image-capable model and fails before the provider call when the model's catalog input is text-only.model run --gateway --fileinstead offloads images for text-only models and describes them through the Gateway's media understanding. model run --gatewayexercises Gateway routing, saved auth, provider selection, and the embedded runtime, but stays a raw model check: no prior session transcript, bootstrap/AGENTS context, tools, or bundled MCP servers.model run --gateway --model <provider/model>requires a trusted-operator gateway credential, because it asks the Gateway to run a one-off provider/model override.
Model
Text inference and model/provider inspection.
model list, model inspect, and model providers read the selected agent's model catalog. They preserve configured model details and exclude models outside that catalog. Use infer model --agent <id> list --json or infer model --agent <id> inspect --model <provider/model> --json to select an agent. Provider counts use the same inventory.
Use full <provider/model> refs with --local to smoke-test one provider without starting the Gateway or loading the agent tool surface:
Notes:
- Local
model runis the narrowest CLI smoke for provider/model/auth health: for non-ChatGPT-Codex providers it sends only the supplied prompt. - Local
model run --model <provider/model>can resolve exact bundled static-catalog rows (the same rowsopenclaw models list --allshows) before that provider is written to config. Provider auth is still required; missing credentials fail as auth errors, notUnknown model. - For Mistral Medium 3.5 reasoning checks, leave temperature unset/default. Mistral rejects
reasoning_effort="high"withtemperature: 0; use default temperature or a non-zero value such as0.7. - OpenAI ChatGPT/Codex OAuth (
openai-chatgpt-responsesAPI) local checks add a minimal system instruction so the transport can populate its requiredinstructionsfield — no full agent context, tools, memory, or session transcript. model run --fileattaches image content directly to the single user message. Common formats (PNG, JPEG, WebP) work when MIME type is detected asimage/*; unsupported or unrecognized files fail before the provider is called. Useinfer image describeinstead when you want OpenClaw's image-model routing and fallbacks rather than a direct multimodal-model check.- The selected model must support image input; text-only models may reject the request at the provider layer.
- Use exactly one of
model run --prompt <text>,--prompt-file <path>, or--prompt-stdin. The file path must be relative to the current directory and remain inside it; symlinks and hardlinks are rejected. File and stdin input are read at invocation time as UTF-8 with a 1 MiB limit. Malformed UTF-8 files are rejected rather than silently replacing invalid bytes. Stdin is read only with--prompt-stdin; invalid UTF-8, read errors, and overflow fail before inference. Empty or whitespace-only prompts are rejected before any provider or Gateway call. File and stdin input keep prompt text out of process arguments and do not add it to command output or a chat transcript; the selected provider still receives the prompt. - Local
model runexits non-zero for empty output or a failed/aborted response, even when partial text was received. These runs do not emit a successful JSON envelope. model run --gatewayalso exits non-zero when the Gateway reports a failed, timed-out, or cancelled run, preserving its error detail instead of wrapping the reply in a successful JSON envelope.- When a completed response contains only reasoning and no final text, local
model runreports that it returned reasoning but no text output, and notes when it stopped at the output token limit. Failed or aborted responses keep the generic no-text error with any provider error detail. Reasoning content is not printed as the answer. - Use
model run --gatewayto test Gateway routing or agent-runtime setup while keeping the model input raw. Useopenclaw agentor a chat surface for full agent context, tools, memory, and session transcript. --thinking adaptivemaps to the completion-runtime levelmedium;--thinking maxmaps tomaxfor OpenAI models that support the native max effort, otherwisexhigh.model auth login,model auth logout, andmodel auth statusmanage saved provider auth state.- An interrupt accepted during generation cancels the in-flight local request or Gateway call and stops waiting for it instead of letting the run finish, and publishes no output for the interrupted run.
- For
model run --gateway, interruption cancels the caller's RPC and does not change the lifetime of Gateway-owned generation.
Image
Generation, edit, and description.
Notes:
-
Use
image editwhen starting from existing input files;--size,--aspect-ratio, or--resolutionadd geometry hints on providers/models that support them. -
image edit --fileaccepts regular files and symlinks to regular files. Special files such as FIFOs are refused before any provider request. -
image generateandimage editaccept positive numericW:Haspect ratios, including7:5and1.5:1. Malformed values such as16x9,16/9, or0:5fail before a provider request or output file is created. -
--output-format png --background transparentwith--model openai/gpt-image-1.5gives transparent-background OpenAI PNG output;--openai-backgroundis an OpenAI-specific alias for the same hint. Providers that do not declare background support report it as an ignored override (seeignoredOverridesin the JSON envelope). -
--quality low|medium|high|autoworks for providers that support image-quality hints, including OpenAI. OpenAI also accepts--openai-moderation low|auto. -
image providers --jsonlists which bundled image providers are discoverable, configured, selected, and which generation/edit capabilities each exposes. -
image generate --model <provider/model> --jsonis the narrowest live smoke for image-generation changes:bash The response reports
ok,provider,model,attempts, and written output paths. When--outputis set, the final extension may follow the provider's returned MIME type. -
For
image describeandimage describe-many, use--promptfor a task-specific instruction (OCR, comparison, UI inspection, concise captioning). -
Use
--timeout-msfor slow local vision models or cold Ollama starts. -
For
image describe, an explicit--model(must be an image-capable<provider/model>) runs first, then tries configuredagents.defaults.imageModel.fallbacksif that call fails. Input-preparation errors (missing file, unsupported URL) fail before any fallback attempt, and the model must be image-capable in the model catalog or provider config. -
For local Ollama vision models, pull the model first and set
OLLAMA_API_KEYto any placeholder value, for exampleollama-local. See Ollama. -
For llmman vision models such as
llmman/gemma4:e4b, configure thellmmanprovider withinput: ["text", "image"]on the model entry and setLLMMAN_API_KEYto a placeholder such asllmman-local. See llmman.
Audio
File transcription (not realtime session management).
--model must be <provider/model>.
An accepted interrupt cancels the pending transcription request and suppresses late transcript output.
The same cancellation behavior applies to infer video describe: interruption
stops the pending provider request and suppresses late description output.
For audio transcription and video description on POSIX systems, --file follows
directory symlinks before resolving .., matching filesystem path resolution.
Final-file symlinks remain subject to the existing media-directory checks.
For CLI-backed transcription, the result's provider identifies the tool family
and model reports the executed command. Auto-detected tools report their resolved
executable path; explicit CLI entries retain their authored command value. This
field does not identify the speech model loaded internally by the tool.
TTS
Speech synthesis and TTS provider/persona state.
Notes:
tts statusonly supports--gateway(it reflects gateway-managed TTS state).- Local and loopback-Gateway
tts convert --outputcopies stage beside the destination and replace it only after success; a failed copy leaves an existing file unchanged. - If interruption is accepted before the output copy begins,
tts convertleaves the requested destination unchanged. Completed synthesis audio remains in the media store for its normal lifetime. - Interrupting
tts convert --gatewaycancels the caller's pending RPC and exits with status 130 without printing a late result. Gateway-owned speech synthesis keeps its existing lifetime. - Remote-Gateway
tts convert --outputis rejected before requesting speech synthesis. - Use
tts convert --provider <id>when selecting a provider without overriding its model. --channel <id>is an output-format hint, not a delivery request. Local conversion uses bundled voice capabilities even without a loaded channel account; Telegram requests voice-note audio (Opus with OpenAI) instead of the default MP3 audio file.- Use
tts providers,tts voices,tts personas,tts set-provider, andtts set-personato inspect and configure TTS behavior.
Video
Generation and description.
Notes:
video generateaccepts--size,--aspect-ratio,--resolution,--duration,--audio,--watermark, and--timeout-ms, forwarded to the video-generation runtime.--durationis a number of seconds that must round to 1–9007199254740991 seconds. Zero, negative, nonnumeric, and smaller values that round to zero fail before provider dispatch. Valid fractions such as2.5retain normal provider-supported rounding; omitting the flag keeps the provider default.- Provider-hosted video downloads reject empty, text, and JSON responses instead of reporting an unusable file as successful output.
- With
--output, URL-backed video streams to a sibling temporary file and replaces the destination only after the complete non-empty download succeeds; a failed stream leaves an existing destination unchanged. --modelmust be<provider/model>forvideo describe.
Web
Search and fetch.
web providers lists available, configured, and selected providers for search and fetch.
Interrupting web search or fetch forwards cancellation to the request and suppresses late provider results and failures.
Embedding
Vector creation and embedding-provider inspection.
--model takes <provider/model>. When you also pass --provider, it must match
that prefix; model ids that contain a slash keep the provider prefix, for example
--model deepinfra/Qwen/Qwen3-Embedding-8B.
Without --json, embedding create shows the provider and model, followed by
each input, its dimension count, and a preview of the first eight vector values.
Longer vectors end with ...; use --json to retrieve complete vectors.
An accepted interrupt forwards cancellation to the embedding provider and suppresses output from the interrupted batch.
JSON output
Infer commands normalize JSON output under a shared envelope:
Stable top-level fields:
okcapabilitytransportprovidermodelusage(observed model-run usage, when available)lastCallUsage(observed usage from the last model API call, when available)attemptsinputs(image attachments sent with the request, when applicable)outputsignoredOverrides(hint keys a provider does not support, when applicable)error
For model.run, both transports expose normalized token counts such as input, output, cacheRead, cacheWrite, reasoningTokens, and total, plus usage availability and recorded cost metadata when supplied. Missing observations are omitted; adapter-default zeros are not treated as measurements. Explicitly measured zero counts are preserved, and explicitly unavailable usage is represented by usageReport.state: "unavailable" without invented token counts or cost.
With --local, a run is one completion, so usage and lastCallUsage contain the same snapshot. With --gateway, usage keeps the runtime's aggregate billing usage (which can span multiple calls or candidates), while lastCallUsage describes only the last physical API call. Cost values and their provenance come from the existing runtime accounting; the CLI does not estimate them.
For generated media commands, outputs contains files written by OpenClaw. Use the path, mimeType, size, and any media-specific dimensions in that array for automation instead of parsing human-readable stdout.
Common pitfalls
Turn infer into a skill
Copy and paste this to an agent:
A good infer-based skill maps common user intents to the right subcommand, includes a few standard examples per workflow, prefers openclaw infer ... over lower-level alternatives, and does not re-document the entire infer surface in the skill body.