OpenClaw API Control
Overview
Use the hosted OpenClaw API instead of the browser UI when an agent should operate an existing OpenClaw instance directly.
Required environment variables:
Optional environment variables:
Defaults:
- - If
OPENCLAW_API_BASE_URL is missing, use INLINECODE4 - If
OPENCLAW_INSTANCE_ID is missing, discover a ready instance automatically
When To Use
- - “Send this folder to my OpenClaw”
- “Upload these files into the OpenClaw workspace”
- “Ask my OpenClaw to continue this task”
- “Run this command on my hosted OpenClaw”
- “Read
/workspace/... from OpenClaw” - “Create an OpenClaw instance through the API”
Workflow
- 1. Verify
OPENCLAW_API_KEY is present. - Use
scripts/openclaw_api_client.mjs root or instances list to confirm connectivity. - Resolve the target instance:
- Prefer
OPENCLAW_INSTANCE_ID
- Otherwise pick the first
ready instance from
instances list
- 4. Choose the right action:
- Chat:
chat send
- Recent history:
chat tail
- Files or folders:
files read,
files write,
files upload-tree
- Commands:
terminal exec
- 5. Report the exact API action and result back to the user.
Commands
Discover API root
CODEBLOCK0
List instances
CODEBLOCK1
Create an instance
CODEBLOCK2
Send a chat message
CODEBLOCK3
Stream a chat message
CODEBLOCK4
Upload a folder into /workspace
CODEBLOCK5
Read a file
CODEBLOCK6
Run a command
CODEBLOCK7
Notes
- -
files upload-tree only uploads text-like files and skips likely binary files. - INLINECODE21 automatically reuses the latest chat session when no session id is supplied.
- The helper prints JSON for machine-friendly reuse.
Resources
- -
scripts/openclaw_api_client.mjs - Minimal Node client for OpenClaw API operations
技能名称: openclaw-api-control
详细描述:
OpenClaw API 控制
概述
当代理需要直接操作现有的 OpenClaw 实例时,使用托管的 OpenClaw API 而非浏览器界面。
必需的环境变量:
- - OPENCLAWAPIKEY
- OPENCLAWAPIBASE_URL
可选的环境变量:
默认值:
- - 如果缺少 OPENCLAWAPIBASEURL,则使用 https://openclaw-as-a-service.com/api
- 如果缺少 OPENCLAWINSTANCE_ID,则自动发现一个就绪的实例
使用场景
- - 将此文件夹发送到我的 OpenClaw
- 将这些文件上传到 OpenClaw 工作区
- 让我的 OpenClaw 继续此任务
- 在我的托管 OpenClaw 上运行此命令
- 从 OpenClaw 读取 /workspace/...
- 通过 API 创建一个 OpenClaw 实例
工作流程
- 1. 确认 OPENCLAWAPIKEY 已存在。
- 使用 scripts/openclawapiclient.mjs root 或 instances list 确认连接状态。
- 解析目标实例:
- 优先使用 OPENCLAW
INSTANCEID
- 否则从 instances list 中选择第一个 ready 状态的实例
- 4. 选择正确的操作:
- 聊天:chat send
- 最近历史:chat tail
- 文件或文件夹:files read、files write、files upload-tree
- 命令:terminal exec
- 5. 向用户报告确切的 API 操作和结果。
命令
发现 API 根路径
bash
node scripts/openclawapiclient.mjs root
列出实例
bash
node scripts/openclawapiclient.mjs instances list
创建实例
bash
node scripts/openclawapiclient.mjs instances create --invite-code YOUR_CODE
发送聊天消息
bash
node scripts/openclawapiclient.mjs chat send --message 继续 /workspace 中的任务
流式发送聊天消息
bash
node scripts/openclawapiclient.mjs chat send --stream --message 在工作时叙述每一步
上传文件夹到 /workspace
bash
node scripts/openclawapiclient.mjs files upload-tree --src ./my-project --dest /workspace/my-project
读取文件
bash
node scripts/openclawapiclient.mjs files read --path /workspace/README.md
运行命令
bash
node scripts/openclawapiclient.mjs terminal exec --command pwd && ls -la /workspace
注意事项
- - files upload-tree 仅上传文本类文件,跳过可能的二进制文件。
- 当未提供会话 ID 时,chat tail 会自动重用最新的聊天会话。
- 该辅助工具输出 JSON 格式,便于机器友好地复用。
资源
- - scripts/openclawapiclient.mjs - 用于 OpenClaw API 操作的最小化 Node 客户端