← 返回
未分类 Key

Openclaw Api Reference

OpenClaw API 参考 - 完整的 API 文档和示例。适合:开发者、集成场景。
OpenClaw API 参考 - 完整的 API 文档和示例。适用于开发者、集成场景。
yang1002378395-cmyk yang1002378395-cmyk 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 376
下载
💾 0
安装
1
版本
#latest

概述

OpenClaw API 参考

完整的 API 文档和示例。

基础 URL

http://localhost:3000/api/v1

认证

API Key

curl -H "Authorization: Bearer YOUR_API_KEY" \
  http://localhost:3000/api/v1/chat

JWT

curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  http://localhost:3000/api/v1/chat

聊天 API

发送消息

POST /api/v1/chat

{
  "message": "你好",
  "session_id": "optional-session-id",
  "model": "deepseek-chat"
}

响应

{
  "response": "你好!有什么可以帮你的?",
  "session_id": "abc123",
  "tokens": {
    "input": 5,
    "output": 10
  }
}

流式响应

POST /api/v1/chat/stream

{
  "message": "写一首诗"
}

响应(SSE):

data: {"text": "春"}
data: {"text": "眠"}
data: {"text": "不"}
data: {"text": "觉"}
data: {"text": "晓"}
data: [DONE]

会话 API

创建会话

POST /api/v1/sessions

{
  "name": "我的会话",
  "model": "deepseek-chat"
}

获取会话

GET /api/v1/sessions/:id

列出会话

GET /api/v1/sessions

删除会话

DELETE /api/v1/sessions/:id

消息 API

获取消息历史

GET /api/v1/sessions/:id/messages

# 参数
?limit=50
&offset=0
&order=desc

删除消息

DELETE /api/v1/messages/:id

Skills API

列出 Skills

GET /api/v1/skills

执行 Skill

POST /api/v1/skills/:name/run

{
  "params": {
    "key": "value"
  }
}

创建 Skill

POST /api/v1/skills

{
  "name": "my-skill",
  "description": "描述",
  "script": "echo 'hello'"
}

配置 API

获取配置

GET /api/v1/config

更新配置

PATCH /api/v1/config

{
  "model": "gpt-4o",
  "temperature": 0.7
}

用户 API

创建用户

POST /api/v1/users

{
  "email": "user@example.com",
  "password": "secure-password"
}

获取用户

GET /api/v1/users/:id

更新用户

PATCH /api/v1/users/:id

{
  "name": "新名字"
}

Webhook API

创建 Webhook

POST /api/v1/webhooks

{
  "url": "https://your-server.com/webhook",
  "events": ["message.created", "session.created"]
}

测试 Webhook

POST /api/v1/webhooks/:id/test

错误处理

错误格式

{
  "error": {
    "code": "INVALID_API_KEY",
    "message": "API key is invalid",
    "details": {}
  }
}

常见错误码

错误码说明
--------------
INVALID_API_KEYAPI Key 无效
RATE_LIMIT请求频率超限
MODEL_NOT_FOUND模型不存在
SESSION_NOT_FOUND会话不存在
INTERNAL_ERROR服务器错误

SDK

JavaScript/TypeScript

npm install openclaw-sdk
import { OpenClaw } from 'openclaw-sdk';

const client = new OpenClaw({
  apiKey: 'your-api-key'
});

const response = await client.chat({
  message: '你好'
});

Python

pip install openclaw
from openclaw import OpenClaw

client = OpenClaw(api_key='your-api-key')

response = client.chat(message='你好')

需要帮助?

  • API 集成:¥99
  • SDK 开发:¥299
  • 企业支持:¥999

联系:微信 yang1002378395 或 Telegram @yangster151


创建:2026-03-14

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 05:01 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 678 📥 327,589
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 72 📥 181,899
data-analysis

Data Analyst Cn

yang1002378395-cmyk
数据分析助手 - 数据清洗、统计分析、可视化建议。适合:数据分析师、产品经理、运营。
★ 8 📥 5,632