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 將環境變數參照儲存在 auth profiles 中,而非純文字值。
在入門流程中,可以在環境變數參照與已設定的提供者參照(file 或 exec)之間進行互動式選擇。
在非互動式 ref 模式下,提供者環境變數必須在程序環境中設定。
現在,如果傳入內聯金鑰旗標但沒有對應的環境變數,將會快速失敗。
範例:
openclaw onboard --non-interactive \ --mode local \ --auth-choice openai-api-key \ --secret-input-mode ref \ --accept-risk特定提供者的範例
Section titled “特定提供者的範例”Gemini 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" }。
新增另一個代理程式
Section titled “新增另一個代理程式”使用 openclaw agents add <name> 建立具有獨立工作區、
階段作業和 auth profiles 的個別代理程式。若不帶 --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。
- 上架中心:上架 (CLI)
- 完整參考:CLI 設定參考
- 指令參考:
openclaw onboard