CLI Automation

Dùng --non-interactive để tự động hóa openclaw onboard.

Lưu ý: --json không có nghĩa là chế độ không tương tác. Cho script, dùng --non-interactive (và --workspace).

Ví dụ không tương tác cơ bản

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

Thêm --json để có tóm tắt máy đọc được.

Dùng --secret-input-mode ref để lưu env-backed ref trong auth profile thay vì giá trị plaintext. Lựa chọn tương tác giữa env ref và ref provider đã cấu hình (file hoặc exec) có sẵn trong quy trình trình hướng dẫn onboarding.

Trong chế độ ref không tương tác, biến môi trường provider phải được đặt trong môi trường tiến trình. Truyền flag key inline mà không có biến môi trường tương ứng sẽ lỗi ngay.

Ví dụ:

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

Ví dụ theo provider

Ví dụ 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
```
Ví dụ 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
```
Ví dụ 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
```
Ví dụ 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
```
Ví dụ 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
```
Ví dụ 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
```
Ví dụ 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
```
Ví dụ 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
```
Đổi sang `--auth-choice opencode-go --opencode-go-api-key "$OPENCODE_API_KEY"` cho danh mục Go.
Ví dụ 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
```
Ví dụ custom provider
```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` là tùy chọn. Nếu bỏ qua, onboarding kiểm tra `CUSTOM_API_KEY`.

Biến thể chế độ 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
```

Trong chế độ này, onboarding lưu `apiKey` dưới dạng `{ source: "env", provider: "default", id: "CUSTOM_API_KEY" }`.

Thêm agent khác

Dùng openclaw agents add <name> để tạo agent riêng với workspace, session và auth profile riêng. Chạy không có --workspace sẽ khởi động trình hướng dẫn.

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

Nó đặt:

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

Lưu ý:

  • Workspace mặc định theo mẫu ~/.openclaw/workspace-<agentId>.
  • Thêm bindings để định tuyến tin nhắn đến (trình hướng dẫn có thể làm việc này).
  • Flag không tương tác: --model, --agent-dir, --bind, --non-interactive.

Tài liệu liên quan