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 を使用すると、平文の値ではなく env ベースの参照を認証プロファイルに保存します。 対話モードでは、env 参照と設定済みプロバイダー参照(file または exec)のどちらかを選択できます。

非対話の ref モードでは、プロバイダーの環境変数がプロセス環境で設定されている必要があります。 対応する環境変数なしにインラインキーフラグを渡すと、即座にエラーになります。

例:

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
```
Go カタログに切り替える場合は `--auth-choice opencode-go --opencode-go-api-key "$OPENCODE_API_KEY"` を使用してください。
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` はオプションです。省略時は `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
```

このモードでは、オンボーディングが `apiKey` を `{ source: "env", provider: "default", id: "CUSTOM_API_KEY" }` として保存します。

別のエージェントを追加

openclaw agents add <name> を使うと、独自のワークスペース、セッション、認証プロファイルを持つ別のエージェントを作成できます。--workspace なしで実行するとウィザードが起動します。

openclaw agents add work \
  --workspace ~/.openclaw/workspace-work \
  --model openai/gpt-5.2 \
  --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

関連ドキュメント