Automate LLM Tasks in OpenClaw: Structured JSON Workflows
Getting an LLM to follow instructions is one thing, but getting it to return a clean, predictable JSON object is another challenge entirely. You often end up fighting with weird formatting or extra text that breaks your code.
If you are building workflows and want to add LLM steps without writing a bunch of custom logic every time, the llm-task plugin is exactly what you need. It is an optional tool that runs JSON-only tasks and gives you structured output that you can validate.
Enable the plugin
Section titled “Enable the plugin”You need to turn the plugin on first. Since it is an optional tool, it won’t be active by default.
{ "plugins": { "entries": { "llm-task": { "enabled": true } } }}Next, you need to allowlist the tool for your agents.
{ "agents": { "list": [ { "id": "main", "tools": { "allow": ["llm-task"] } } ] }}Config (optional)
Section titled “Config (optional)”You can set up default settings to make your requests shorter and more consistent.
{ "plugins": { "entries": { "llm-task": { "enabled": true, "config": { "defaultProvider": "openai-codex", "defaultModel": "gpt-5.4", "defaultAuthProfileId": "main", "allowedModels": ["openai-codex/gpt-5.4"], "maxTokens": 800, "timeoutMs": 30000 } } } }}The allowedModels setting acts as a security filter. If you define this list, the plugin will reject any request that tries to use a model not included here.
Tool parameters
Section titled “Tool parameters”When you call the tool, you can use these parameters:
prompt(string, required)input(any, optional)schema(object, optional JSON Schema)provider(string, optional)model(string, optional)thinking(string, optional)authProfileId(string, optional)temperature(number, optional)maxTokens(number, optional)timeoutMs(number, optional)
For the thinking parameter, you can use standard reasoning presets like low or medium.
Output
Section titled “Output”The tool returns a file called details.json. This file contains the parsed JSON data. If you provided a schema, the tool automatically validates the output against it to ensure everything is correct.
Example: Lobster workflow step
Section titled “Example: Lobster workflow step”Here is how you can use llm-task inside a Lobster workflow step to process an email.
openclaw.invoke --tool llm-task --action json --args-json '{ "prompt": "Given the input email, return intent and draft.", "thinking": "low", "input": { "subject": "Hello", "body": "Can you help?" }, "schema": { "type": "object", "properties": { "intent": { "type": "string" }, "draft": { "type": "string" } }, "required": ["intent", "draft"], "additionalProperties": false }}'Safety notes
Section titled “Safety notes”To keep your workflows reliable and secure, keep these points in mind:
- The tool is strictly JSON-only. It tells the model to avoid adding code fences or extra commentary.
- The model cannot access any other tools during this specific run.
- You should treat the output as untrusted data unless you use a
schemato validate it. - Always place approval steps before any action that has side effects, such as
send,post,exec, or similar commands.
Next steps
Section titled “Next steps”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.