Automazione CLI

Usa --non-interactive per automatizzare openclaw onboard.

Nota: --json non implica la modalità non interattiva. Usa --non-interactive (e --workspace) per gli script.

Esempio base non interattivo

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

Aggiungi --json per un riepilogo leggibile dalle macchine.

Usa --secret-input-mode ref per salvare riferimenti basati su variabili d’ambiente nei profili di autenticazione invece dei valori in chiaro. La selezione interattiva tra riferimenti a variabili d’ambiente e riferimenti a provider configurati (file o exec) è disponibile nel flusso del wizard di onboarding.

In modalità non interattiva ref, le variabili d’ambiente dei provider devono essere impostate nell’ambiente del processo. Passare flag inline della key senza la variabile d’ambiente corrispondente ora produce un errore immediato.

Esempio:

openclaw onboard --non-interactive \
  --mode local \
  --auth-choice openai-api-key \
  --secret-input-mode ref \
  --accept-risk

Esempi per provider specifici

Esempio 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
```
Esempio 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
```
Esempio 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
```
Esempio 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
```
Esempio 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
```
Esempio 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
```
Esempio 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
```
Esempio 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
```
Sostituisci con `--auth-choice opencode-go --opencode-go-api-key "$OPENCODE_API_KEY"` per il catalogo Go.
Esempio 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
```
Esempio provider personalizzato
```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` è opzionale. Se omesso, l'onboarding controlla `CUSTOM_API_KEY`.

Variante in modalità 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
```

In questa modalità, l'onboarding salva `apiKey` come `{ source: "env", provider: "default", id: "CUSTOM_API_KEY" }`.

Aggiungere un altro agente

Usa openclaw agents add <nome> per creare un agente separato con il proprio workspace, sessioni e profili di autenticazione. Lanciandolo senza --workspace si avvia il wizard.

openclaw agents add work \
  --workspace ~/.openclaw/workspace-work \
  --model openai/gpt-5.2 \
  --bind whatsapp:biz \
  --non-interactive \
  --json

Cosa imposta:

  • agents.list[].name
  • agents.list[].workspace
  • agents.list[].agentDir

Note:

  • I workspace predefiniti seguono ~/.openclaw/workspace-<agentId>.
  • Aggiungi bindings per instradare i messaggi in ingresso (il wizard può farlo).
  • Flag non interattivi: --model, --agent-dir, --bind, --non-interactive.

Documentazione correlata