解密OpenClaw系列10-OpenClaw API参考文档
本文档提供了OpenClaw应用的API参考指南,详细介绍了其核心组件和架构。主要内容包括: 深度链接协议openclaw://的实现与参数传递机制 AI模型API调用方法,基于Amazon Bedrock和models.generated.js 工具动作定义(tool-display.json)和设备识别系统(ios/mac-device-identifiers.json) 基于Sparkle框
·
API参考文档
**本文档引用的文件** - [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist) - [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js) - [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json) - [scaffold.html](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/scaffold.html) - [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json) - [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json) - [NOTICE.md](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/NOTICE.md) - [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)目录
简介
本文件为OpenClaw的完整API参考文档,覆盖以下方面:
- 深度链接协议openclaw://的URL模式、参数传递与回调机制
- AI模型API(基于Amazon Bedrock)的调用方法、请求格式、响应结构与错误码
- 权限管理API(系统权限声明与使用说明)
- 设备识别API(iOS与macOS设备型号映射)
- 更新系统API(基于Sparkle框架的自动更新机制)
本参考文档以仓库中现有资源为依据,提供可操作的规范说明与最佳实践建议。
项目结构
OpenClaw应用通过Info.plist声明深度链接协议,通过Resource目录下的JSON与JS文件提供模型、工具显示与设备识别等数据;通过Sparkle框架实现自动更新。
图表来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [scaffold.html](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/scaffold.html#L197-L221)
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L1-L26)
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L1-L82)
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L1-L26)
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
核心组件
- 深度链接协议:在Info.plist中声明openclaw://,用于从外部应用或浏览器唤起OpenClaw并传递参数。
- AI模型API:通过models.generated.js提供可用模型清单,支持Bedrock Converse Stream API。
- 工具与动作:tool-display.json定义了各类工具(如browser、nodes、cron等)的动作与参数键。
- 设备识别:ios-device-identifiers.json与mac-device-identifiers.json提供设备型号到人类可读名称的映射。
- 更新系统:Sparkle框架通过appcast.xml进行自动更新检查与安装。
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L27-L196)
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
架构总览
OpenClaw的API层由以下模块组成:
- 协议层:openclaw://深度链接协议
- 工具层:工具动作定义与参数键
- 数据层:模型清单、设备映射
- 更新层:Sparkle自动更新
图表来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L27-L196)
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
详细组件分析
深度链接协议 openclaw://
- 协议声明:在Info.plist中声明CFBundleURLTypes,scheme为openclaw。
- URL模式:openclaw://<动作>?<参数键>=<参数值>&<参数键>=<参数值>
- 参数传递:支持查询字符串形式的键值对,参数键集合由各工具定义。
- 回调机制:应用启动后解析URL,根据动作与参数执行相应流程。
图表来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L27-L196)
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L27-L196)
AI模型API(Amazon Bedrock Converse Stream)
- 提供方:amazon-bedrock
- API类型:bedrock-converse-stream
- 基础URL:https://bedrock-runtime.us-east-1.amazonaws.com
- 支持输入类型:text、image
- 模型清单:models.generated.js中包含多个具体模型条目,每个条目包含id、name、reasoning、input、cost、contextWindow、maxTokens等字段。
- 请求格式:基于Converse Stream API的流式请求,需携带模型ID、消息历史、推理开关等。
- 响应结构:流式响应,包含内容块与元数据;错误时返回标准HTTP错误码与错误信息。
- 错误码:HTTP 4xx/5xx表示请求失败;具体错误原因见响应体或日志。
图表来源
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
章节来源
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
权限管理API
- 系统权限声明:在Info.plist中声明了多项系统权限用途描述,包括自动化(Automation)、相机、麦克风、屏幕截图、语音识别、通知等。
- 使用说明:应用在需要时会请求对应权限;用户可在系统设置中管理权限。
图表来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L53-L70)
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L53-L70)
设备识别API
- iOS设备映射:ios-device-identifiers.json提供设备型号到人类可读名称的映射。
- macOS设备映射:mac-device-identifiers.json提供设备型号到一个或多个名称的映射。
- 使用场景:用于在工具动作中识别目标设备,例如nodes工具的camera_list、camera_clip等。
图表来源
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
- [NOTICE.md](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/NOTICE.md#L1-L10)
章节来源
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L177)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L215)
- [NOTICE.md](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/NOTICE.md#L1-L10)
更新系统API(Sparkle)
- 自动更新:应用内置Sparkle框架,通过SUFeedURL指向appcast.xml进行更新检查。
- 更新流程:应用启动时检查appcast.xml,下载新版本并提示安装。
- 版本兼容:更新源由appcast.xml定义,遵循Sparkle的版本比较协议。
图表来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L75-L81)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L75-L81)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
依赖关系分析
- 协议依赖:openclaw://依赖Info.plist中的URL Scheme声明。
- 工具依赖:工具动作依赖tool-display.json中的动作与参数键定义。
- 数据依赖:AI模型API依赖models.generated.js中的模型清单。
- 设备依赖:设备识别依赖ios-device-identifiers.json与mac-device-identifiers.json。
- 更新依赖:自动更新依赖Sparkle框架与appcast.xml。
图表来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L27-L196)
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L27-L196)
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
性能考虑
- 模型选择:根据上下文窗口与最大令牌数选择合适模型,平衡成本与性能。
- 输入优化:优先使用文本输入,必要时加入图像输入以提升理解能力。
- 流式响应:合理处理流式响应,避免阻塞主线程。
- 设备映射缓存:在频繁使用设备识别时缓存映射表,减少重复解析。
故障排除指南
- 深度链接无法打开:检查Info.plist中的URL Scheme是否正确;确认系统已注册openclaw://。
- 工具动作参数无效:核对tool-display.json中的动作与参数键,确保传入的键值存在且类型正确。
- AI模型调用失败:检查模型ID是否存在于models.generated.js;确认网络可达与认证配置。
- 设备识别异常:核对设备型号标识符是否在ios-device-identifiers.json或mac-device-identifiers.json中存在映射。
- 自动更新失败:检查SUFeedURL与appcast.xml的有效性;确认网络连接与签名完整性。
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L21-L31)
- [tool-display.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/OpenClawKit_OpenClawKit.bundle/tool-display.json#L27-L196)
- [models.generated.js](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/models.generated.js#L1-L20)
- [ios-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/ios-device-identifiers.json#L1-L20)
- [mac-device-identifiers.json](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/mac-device-identifiers.json#L1-L20)
- [appcast.xml](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/appcast.xml)
结论
本文档基于仓库中的现有资源,提供了OpenClaw的深度链接协议、AI模型API、权限管理、设备识别与更新系统的完整参考。建议在集成时严格遵循参数键与URL模式,并结合工具动作定义与模型清单进行开发与测试。
附录
- 版本兼容性:应用版本号与构建号在Info.plist中定义;更新源由SUFeedURL与appcast.xml决定。
- 许可与致谢:设备映射数据来源于第三方开源项目,详见DeviceModels目录下的NOTICE与LICENSE文件。
章节来源
- [Info.plist](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Info.plist#L19-L33)
- [NOTICE.md](file://OpenClaw-2026.1.30/OpenClaw.app/Contents/Resources/DeviceModels/NOTICE.md#L1-L10)
更多推荐

所有评论(0)