OpenClaw从入门到应用:基础知识——非交互式 Onboarding 自动化指南

张开发
2026/5/9 16:50:44 15 分钟阅读

分享文章

OpenClaw从入门到应用:基础知识——非交互式 Onboarding 自动化指南
通过OpenClaw实现副业收入《OpenClaw赚钱实录从“养龙虾“到可持续变现的实践指南》本文档介绍了如何使用--non-interactive参数自动化执行openclaw onboard命令以便在脚本或自动化流程中完成初始配置。同时涵盖了认证信息的安全存储、多代理配置等高级用法。基础非交互示例以下命令展示了最基础的非交互式 onboard 流程openclaw onboard --non-interactive\--modelocal\--auth-choice apiKey\--anthropic-api-key$ANTHROPIC_API_KEY\--secret-input-mode plaintext\--gateway-port18789\--gateway-bind loopback\--install-daemon\--daemon-runtimenode\--skip-skills关键参数说明--non-interactive强制以非交互模式运行所有输入必须通过命令行参数提供。--mode local指定运行模式为本地常见场景。--auth-choice选择认证方式例如apiKey、gemini-api-key等。--secret-input-mode控制敏感信息的存储方式。plaintext会直接存储明文值ref则存储环境变量引用提高安全性。--gateway-port和--gateway-bind配置网关监听端口及绑定地址。--install-daemon将服务安装为守护进程。--daemon-runtime指定守护进程运行时如node。--skip-skills跳过技能安装适用于最小化配置。输出格式与安全存储机器可读输出添加--json参数可获取结构化的机器可读摘要便于脚本解析openclaw onboard --non-interactive...--json敏感信息存储模式使用--secret-input-mode ref可以在认证配置文件中存储环境变量引用而非明文值openclaw onboard --non-interactive\--modelocal\--auth-choice openai-api-key\--secret-input-mode ref\--accept-risk在交互式引导流程中用户可以选择使用环境变量引用或已配置的提供者引用file或exec。非交互式 ref 模式注意事项提供者所需的环境变量必须在当前进程环境中预先设置。如果传入了内联密钥标志如--openai-api-key但未设置对应的环境变量命令将立即失败fail fast。特定提供者示例根据不同的 AI 提供商需要指定相应的认证参数。以下为常见提供者的非交互式配置示例。Anthropic (Claude)openclaw onboard --non-interactive\--modelocal\--auth-choice apiKey\--anthropic-api-key$ANTHROPIC_API_KEY\--gateway-port18789\--gateway-bind loopbackGoogle Geminiopenclaw onboard --non-interactive\--modelocal\--auth-choice gemini-api-key\--gemini-api-key$GEMINI_API_KEY\--gateway-port18789\--gateway-bind loopbackZAIopenclaw onboard --non-interactive\--modelocal\--auth-choice zai-api-key\--zai-api-key$ZAI_API_KEY\--gateway-port18789\--gateway-bind loopbackAI Gatewayopenclaw onboard --non-interactive\--modelocal\--auth-choice ai-gateway-api-key\--ai-gateway-api-key$AI_GATEWAY_API_KEY\--gateway-port18789\--gateway-bind loopbackCloudflare AI Gatewayopenclaw onboard --non-interactive\--modelocal\--auth-choice cloudflare-ai-gateway-api-key\--cloudflare-ai-gateway-account-idyour-account-id\--cloudflare-ai-gateway-gateway-idyour-gateway-id\--cloudflare-ai-gateway-api-key$CLOUDFLARE_AI_GATEWAY_API_KEY\--gateway-port18789\--gateway-bind loopbackMoonshot月之暗面openclaw onboard --non-interactive\--modelocal\--auth-choice moonshot-api-key\--moonshot-api-key$MOONSHOT_API_KEY\--gateway-port18789\--gateway-bind loopbackMistral AIopenclaw onboard --non-interactive\--modelocal\--auth-choice mistral-api-key\--mistral-api-key$MISTRAL_API_KEY\--gateway-port18789\--gateway-bind loopbackSyntheticopenclaw onboard --non-interactive\--modelocal\--auth-choice synthetic-api-key\--synthetic-api-key$SYNTHETIC_API_KEY\--gateway-port18789\--gateway-bind loopbackOpenCodeZen 目录版本openclaw onboard --non-interactive\--modelocal\--auth-choice opencode-zen\--opencode-zen-api-key$OPENCODE_API_KEY\--gateway-port18789\--gateway-bind loopbackGo 目录版本openclaw onboard --non-interactive\--modelocal\--auth-choice opencode-go\--opencode-go-api-key$OPENCODE_API_KEY\--gateway-port18789\--gateway-bind loopbackOllama本地模型openclaw onboard --non-interactive\--modelocal\--auth-choice ollama\--custom-model-idqwen3.5:27b\--accept-risk\--gateway-port18789\--gateway-bind loopback自定义 API 端点对于兼容 OpenAI API 格式的自定义端点可以使用custom-api-key认证方式明文模式openclaw onboard --non-interactive\--modelocal\--auth-choice custom-api-key\--custom-base-urlhttps://llm.example.com/v1\--custom-model-idfoo-large\--custom-api-key$CUSTOM_API_KEY\--custom-provider-idmy-custom\--custom-compatibility anthropic\--gateway-port18789\--gateway-bind loopback--custom-api-key是可选参数。如果省略系统会检查CUSTOM_API_KEY环境变量。引用模式Ref-mode变体exportCUSTOM_API_KEYyour-keyopenclaw onboard --non-interactive\--modelocal\--auth-choice custom-api-key\--custom-base-urlhttps://llm.example.com/v1\--custom-model-idfoo-large\--secret-input-mode ref\--custom-provider-idmy-custom\--custom-compatibility anthropic\--gateway-port18789\--gateway-bind loopback在此模式下系统会将apiKey存储为{ source: env, provider: default, id: CUSTOM_API_KEY }的引用格式而非明文。添加额外的 Agent使用openclaw agents add命令可以创建一个独立的 Agent每个 Agent 拥有独立的工作空间workspace、会话sessions和认证配置文件auth profiles。openclaw agentsaddwork\--workspace~/.openclaw/workspace-work\--modelopenai/gpt-5.2\--bindwhatsapp:biz\--non-interactive\--json该命令会设置以下配置项agents.list[].nameAgent 名称例如work。agents.list[].workspace工作空间路径。agents.list[].agentDirAgent 目录。注意事项如果不指定--workspace默认工作区路径遵循~/.openclaw/workspace-name的命名规则。通过bindings可以配置入站消息的路由规则交互式向导支持此功能。非交互模式下可用的参数--model、--agent-dir、--bind、--non-interactive。相关文档Onboarding 中心Onboarding Wizard (CLI)完整参考CLI Onboarding Reference命令参考openclaw onboard本文档基于 Mintlify 构建。

更多文章