CLI 自动化
使用 --non-interactive 来自动化 openclaw onboard。
--json 并不意味着非交互模式。对于脚本,请使用 --non-interactive(以及 --workspace)。
基础非交互式示例
openclaw onboard --non-interactive \
--mode local \
--auth-choice apiKey \
--anthropic-api-key "$ANTHROPIC_API_KEY" \
--secret-input-mode plaintext \
--gateway-port 18789 \
--gateway-bind loopback \
--install-daemon \
--daemon-runtime node \
--skip-skills
添加 --json 以获得机器可读的摘要。
使用 --secret-input-mode ref 可将基于环境变量的引用存储到认证 profile 中,而不是存储明文值。
在新手引导流程中,支持在环境变量引用和已配置的提供商引用(file 或 exec)之间进行交互式选择。
在非交互式 ref 模式下,提供商环境变量必须在进程环境中设置。
传入内联密钥标志但未设置对应环境变量时,现在会快速失败。
示例:
openclaw onboard --non-interactive \
--mode local \
--auth-choice openai-api-key \
--secret-input-mode ref \
--accept-risk
提供商特定示例
openclaw onboard --non-interactive \
--mode local \
--auth-choice apiKey \
--anthropic-api-key "$ANTHROPIC_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice gemini-api-key \
--gemini-api-key "$GEMINI_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice zai-api-key \
--zai-api-key "$ZAI_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice ai-gateway-api-key \
--ai-gateway-api-key "$AI_GATEWAY_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice cloudflare-ai-gateway-api-key \
--cloudflare-ai-gateway-account-id "your-account-id" \
--cloudflare-ai-gateway-gateway-id "your-gateway-id" \
--cloudflare-ai-gateway-api-key "$CLOUDFLARE_AI_GATEWAY_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice moonshot-api-key \
--moonshot-api-key "$MOONSHOT_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice mistral-api-key \
--mistral-api-key "$MISTRAL_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice synthetic-api-key \
--synthetic-api-key "$SYNTHETIC_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice opencode-zen \
--opencode-zen-api-key "$OPENCODE_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
如果要使用 Go catalog,请改为 --auth-choice opencode-go --opencode-go-api-key "$OPENCODE_API_KEY"。
openclaw onboard --non-interactive \
--mode local \
--auth-choice ollama \
--custom-model-id "qwen3.5:27b" \
--accept-risk \
--gateway-port 18789 \
--gateway-bind loopback
Anthropic setup-token 仍然可作为受支持的新手引导令牌路径使用,但 OpenClaw 现在在可用时更优先使用 Claude CLI 复用。
在生产环境中,优先使用 Anthropic API 密钥。
添加另一个智能体
使用 openclaw agents add <name> 创建一个单独的智能体,它拥有自己的工作区、
会话和认证 profile。不带 --workspace 运行会启动向导。
openclaw agents add work \
--workspace ~/.openclaw/workspace-work \
--model openai/gpt-5.4 \
--bind whatsapp:biz \
--non-interactive \
--json
它会设置:
agents.list[].name
agents.list[].workspace
agents.list[].agentDir
说明:
- 默认工作区遵循
~/.openclaw/workspace-<agentId>。
- 添加
bindings 以路由入站消息(向导可以完成此操作)。
- 非交互式标志:
--model、--agent-dir、--bind、--non-interactive。
相关文档