Install
openclaw skills install openclaw-api-referenceOpenClaw API 参考 - 完整的 API 文档和示例。适合:开发者、集成场景。
openclaw skills install openclaw-api-reference完整的 API 文档和示例。
http://localhost:3000/api/v1
curl -H "Authorization: Bearer YOUR_API_KEY" \
http://localhost:3000/api/v1/chat
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
http://localhost:3000/api/v1/chat
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]
POST /api/v1/sessions
{
"name": "我的会话",
"model": "deepseek-chat"
}
GET /api/v1/sessions/:id
GET /api/v1/sessions
DELETE /api/v1/sessions/:id
GET /api/v1/sessions/:id/messages
# 参数
?limit=50
&offset=0
&order=desc
DELETE /api/v1/messages/:id
GET /api/v1/skills
POST /api/v1/skills/:name/run
{
"params": {
"key": "value"
}
}
POST /api/v1/skills
{
"name": "my-skill",
"description": "描述",
"script": "echo 'hello'"
}
GET /api/v1/config
PATCH /api/v1/config
{
"model": "gpt-4o",
"temperature": 0.7
}
POST /api/v1/users
{
"email": "user@example.com",
"password": "secure-password"
}
GET /api/v1/users/:id
PATCH /api/v1/users/:id
{
"name": "新名字"
}
POST /api/v1/webhooks
{
"url": "https://your-server.com/webhook",
"events": ["message.created", "session.created"]
}
POST /api/v1/webhooks/:id/test
{
"error": {
"code": "INVALID_API_KEY",
"message": "API key is invalid",
"details": {}
}
}
| 错误码 | 说明 |
|---|---|
| INVALID_API_KEY | API Key 无效 |
| RATE_LIMIT | 请求频率超限 |
| MODEL_NOT_FOUND | 模型不存在 |
| SESSION_NOT_FOUND | 会话不存在 |
| INTERNAL_ERROR | 服务器错误 |
npm install openclaw-sdk
import { OpenClaw } from 'openclaw-sdk';
const client = new OpenClaw({
apiKey: 'your-api-key'
});
const response = await client.chat({
message: '你好'
});
pip install openclaw
from openclaw import OpenClaw
client = OpenClaw(api_key='your-api-key')
response = client.chat(message='你好')
联系:微信 yang1002378395 或 Telegram @yangster151
创建:2026-03-14