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 在 auth profiles 中儲存以環境變數為後端的參考,而非明文值。
互動式 onboarding 精靈流程中也可以在 env ref 和已設定的提供者 ref(file 或 exec)之間選擇。
非互動 ref 模式下,提供者環境變數必須在行程環境中已設定。
傳入行內 key 旗標但沒有對應環境變數會立即失敗。
範例:
openclaw onboard --non-interactive \
--mode local \
--auth-choice openai-api-key \
--secret-input-mode ref \
--accept-risk
提供者特定範例
Gemini 範例
```bash
openclaw onboard --non-interactive \
--mode local \
--auth-choice gemini-api-key \
--gemini-api-key "$GEMINI_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
```
Z.AI 範例
```bash
openclaw onboard --non-interactive \
--mode local \
--auth-choice zai-api-key \
--zai-api-key "$ZAI_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
```
Vercel AI Gateway 範例
```bash
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
```
Cloudflare AI Gateway 範例
```bash
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
```
Moonshot 範例
```bash
openclaw onboard --non-interactive \
--mode local \
--auth-choice moonshot-api-key \
--moonshot-api-key "$MOONSHOT_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
```
Mistral 範例
```bash
openclaw onboard --non-interactive \
--mode local \
--auth-choice mistral-api-key \
--mistral-api-key "$MISTRAL_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
```
Synthetic 範例
```bash
openclaw onboard --non-interactive \
--mode local \
--auth-choice synthetic-api-key \
--synthetic-api-key "$SYNTHETIC_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
```
OpenCode 範例
```bash
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 範例
```bash
openclaw onboard --non-interactive \
--mode local \
--auth-choice ollama \
--custom-model-id "qwen3.5:27b" \
--accept-risk \
--gateway-port 18789 \
--gateway-bind loopback
```
自訂提供者範例
```bash
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` 是選用的。省略時,onboarding 會檢查 `CUSTOM_API_KEY`。
Ref 模式變體:
```bash
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
```
這個模式下,onboarding 將 `apiKey` 儲存為 `{ source: "env", provider: "default", id: "CUSTOM_API_KEY" }`。
新增另一個 agent
使用 openclaw agents add <name> 來建立有獨立工作區、sessions 和 auth profiles 的 agent。不帶 --workspace 執行時會啟動精靈。
openclaw agents add work \
--workspace ~/.openclaw/workspace-work \
--model openai/gpt-5.2 \
--bind whatsapp:biz \
--non-interactive \
--json
設定的項目:
agents.list[].nameagents.list[].workspaceagents.list[].agentDir
注意事項:
- 預設工作區路徑為
~/.openclaw/workspace-<agentId>。 - 加入
bindings來路由傳入訊息(精靈可以幫你做)。 - 非互動旗標:
--model、--agent-dir、--bind、--non-interactive。
相關文件
- Onboarding 中心:Onboarding 精靈(CLI)
- 完整參考:CLI Onboarding 參考
- 指令參考:
openclaw onboard