CLI 自动化
CLI 自动化
Section titled “CLI 自动化”使用 --non-interactive 自动化 openclaw onboard。
基准非交互式示例
Section titled “基准非交互式示例”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 将环境变量支持的引用存储在身份验证配置文件中,而不是明文值。
在环境变量引用和配置的提供商引用(file 或 exec)之间的交互式选择在新手引导流程中可用。
在非交互式 ref 模式下,必须在进程环境中设置提供商环境变量。
如果没有匹配的环境变量,现在传递内联密钥标志将快速失败。
示例:
openclaw onboard --non-interactive \ --mode local \ --auth-choice openai-api-key \ --secret-input-mode ref \ --accept-risk特定于提供商的示例
Section titled “特定于提供商的示例”Anthropic API key example
openclaw onboard --non-interactive \ --mode local \ --auth-choice apiKey \ --anthropic-api-key "$ANTHROPIC_API_KEY" \ --gateway-port 18789 \ --gateway-bind loopbackGemini example
openclaw onboard --non-interactive \ --mode local \ --auth-choice gemini-api-key \ --gemini-api-key "$GEMINI_API_KEY" \ --gateway-port 18789 \ --gateway-bind loopbackZ.AI example
openclaw onboard --non-interactive \ --mode local \ --auth-choice zai-api-key \ --zai-api-key "$ZAI_API_KEY" \ --gateway-port 18789 \ --gateway-bind loopbackVercel AI Gateway example
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 loopbackCloudflare AI Gateway example
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 loopbackMoonshot example
openclaw onboard --non-interactive \ --mode local \ --auth-choice moonshot-api-key \ --moonshot-api-key "$MOONSHOT_API_KEY" \ --gateway-port 18789 \ --gateway-bind loopbackMistral example
openclaw onboard --non-interactive \ --mode local \ --auth-choice mistral-api-key \ --mistral-api-key "$MISTRAL_API_KEY" \ --gateway-port 18789 \ --gateway-bind loopbackSynthetic example
openclaw onboard --non-interactive \ --mode local \ --auth-choice synthetic-api-key \ --synthetic-api-key "$SYNTHETIC_API_KEY" \ --gateway-port 18789 \ --gateway-bind loopbackOpenCode 示例
openclaw onboard --non-interactive \ --mode local \ --auth-choice opencode-zen \ --opencode-zen-api-key "$OPENCODE_API_KEY" \ --gateway-port 18789 \ --gateway-bind loopback切换到 --auth-choice opencode-go --opencode-go-api-key "$OPENCODE_API_KEY" 以获取 Go 目录。
Ollama 示例
openclaw onboard --non-interactive \ --mode local \ --auth-choice ollama \ --custom-model-id "qwen3.5:27b" \ --accept-risk \ --gateway-port 18789 \ --gateway-bind loopback自定义提供商示例
openclaw onboard --non-interactive \ --mode local \ --auth-choice custom-api-key \ --custom-base-url "https://llm.example.com/v1" \ --custom-model-id "foo-large" \ --custom-api-key "$CUSTOM_API_KEY" \ --custom-provider-id "my-custom" \ --custom-compatibility anthropic \ --gateway-port 18789 \ --gateway-bind loopback--custom-api-key 是可选的。如果省略,新手引导会检查 CUSTOM_API_KEY。
引用模式变体:
export CUSTOM_API_KEY="your-key"openclaw onboard --non-interactive \ --mode local \ --auth-choice custom-api-key \ --custom-base-url "https://llm.example.com/v1" \ --custom-model-id "foo-large" \ --secret-input-mode ref \ --custom-provider-id "my-custom" \ --custom-compatibility anthropic \ --gateway-port 18789 \ --gateway-bind loopback在此模式下,新手引导将 apiKey 存储为 { source: "env", provider: "default", id: "CUSTOM_API_KEY" }。
Anthropic setup-token 再次作为旧版/手动新手引导路径可用。 使用它的前提是,Anthropic 告知 OpenClaw 用户 OpenClaw Claude 登录路径需要 Extra Usage。对于生产环境,首选 Anthropic API 密钥。
添加另一个代理
Section titled “添加另一个代理”使用 openclaw agents add <name> 创建具有自己的工作区、
会话和身份验证配置文件的独立代理。不带 --workspace 运行将启动向导。
openclaw agents add work \ --workspace ~/.openclaw/workspace-work \ --model openai/gpt-5.4 \ --bind whatsapp:biz \ --non-interactive \ --json设置内容:
agents.list[].nameagents.list[].workspaceagents.list[].agentDir
备注:
- 默认工作区遵循
~/.openclaw/workspace-<agentId>。 - 添加
bindings以路由传入消息(向导可以执行此操作)。 - 非交互式标志:
--model、--agent-dir、--bind、--non-interactive。
- 新手引导中心:新手引导 (CLI)
- 完整参考:CLI 设置参考
- 命令参考:
openclaw onboard