Chương 11: Cấu Hình Nâng Cao & Tiết Kiệm Chi Phí
11.1 Chọn model phù hợp
| Model | Giá | Tốt cho |
|---|---|---|
| GPT-4o mini | $0.15/1M | Chat hàng ngày, rẻ |
| GPT-4o | $2.50/1M | Phân tích phức tạp |
| Claude 3.5 Sonnet | $3.00/1M | Viết content, code |
| DeepSeek V3 | $0.14/1M | Rẻ nhất, tiếng Việt tốt |
| Gemini 2.0 Flash | Miễn phí | Thử nghiệm, tác vụ nhẹ |
11.2 Multi-model: dùng nhiều model
// openclaw.json
{
"models": {
"default": "deepseek-v3",
"smart": "gpt-4o",
"creative": "claude-3.5-sonnet",
"free": "gemini-2.0-flash"
},
"routing": {
"simple_chat": "default",
"code_review": "smart",
"writing": "creative"
}
}OpenClaw tự chọn model phù hợp cho từng tác vụ — chat đơn giản dùng model rẻ, việc phức tạp dùng model mạnh.
11.3 Fallback thông minh
// Nếu model chính lỗi → tự chuyển sang backup
{
"fallback": [
"gpt-4o",
"claude-3.5-sonnet",
"deepseek-v3"
]
}11.4 Giới hạn chi phí
{
"cost_limit": {
"daily_usd": 1.00,
"monthly_usd": 20.00,
"alert_at_percent": 80
}
}11.5 Mẹo tiết kiệm cho người Việt
- 💰 Dùng DeepSeek V3 làm model mặc định — rẻ nhất và hiểu tiếng Việt
- 💰 Dùng Gemini Flash cho tác vụ nhẹ — miễn phí
- 💰 Chỉ dùng GPT-4o/Claude cho việc quan trọng
- 💰 Đặt cost_limit để không bị bất ngờ cuối tháng
- 💰 Heartbeat interval 1h thay vì 30m → giảm 50% chi phí
💡 Với cấu hình tối ưu, bạn có thể dùng OpenClaw cả tháng với chỉ $2-5 — rẻ hơn nhiều so với $20/tháng ChatGPT Plus.
11.6 Antigravity Manager — Quản lý nhiều AI provider
Antigravity Manager là công cụ proxy API giúp bạn truy cập nhiều AI model (Claude, Gemini, GPT...) qua 1 endpoint duy nhất. Dữ liệu xử lý cục bộ, bảo mật riêng tư.
✅ Ưu điểm
- 🔒 Dữ liệu cục bộ
- 🔄 Chuyển model dễ dàng
- 💰 Dùng API key riêng
- 🧩 Mở rộng qua ClawHub
💰 Chi phí VN
- Gemini: ~0₫ (miễn phí quota)
- Claude: ~50.000₫/tháng
- Claude: ~10.000₫/tháng
- Anthropic Antigravity: ~80.000₫/tháng
// openclaw.json — ket noi Antigravity Manager
{
"models": {
"providers": {
"local-anthropic": {
"baseUrl": "http://127.0.0.1:8045",
"apiKey": "YOUR_USER_TOKEN",
"auth": "api-key",
"api": "anthropic-messages",
"models": [
{
"id": "claude-sonnet-4-5-20250929",
"name": "Local Claude Sonnet 4.5",
"input": ["text"],
"cost": { "input": 0, "output": 0 },
"contextWindow": 200000,
"maxTokens": 8192
}
]
}
}
}
}Lấy User Token: Mở Antigravity Manager → User Tokens → Tạo mới → Copy token.
11.7 Chuỗi Fallback — Không bao giờ chết
Fallback là chuỗi model dự phòng: model chính lỗi → tự chuyển sang model 2 → model 3... Đảm bảo AI luôn phản hồi dù provider có vấn đề.
// openclaw.json
{
"agents": {
"defaults": {
"model": {
"primary": "Claude/Claude-chat",
"fallbacks": [
"anthropic/claude-sonnet-4-5",
"google/gemini-2.0-flash-exp"
]
}
}
}
}Luồng hoạt động:
- 1️⃣ Claude V3 — mặc định, rẻ nhất ($0.14/1M tokens)
- 2️⃣ Claude Sonnet 4.5 — Claude lỗi hoặc rate limit ($3/1M tokens)
- 3️⃣ Gemini 2.0 Flash — Claude cũng lỗi (miễn phí)
💡 Chiến lược cho người Việt:
// Chi phí toi ưu: Claude chinh → Claude Sonnet backup
{
"agents": {
"defaults": {
"model": {
"primary": "Claude/Claude-chat", // ~10.000₫/tháng
"fallbacks": [
"anthropic/claude-3-5-sonnet-20241022", // ~50.000₫/tháng
"google/gemini-2.0-flash-exp" // miễn phí
]
}
}
}
}
// Chi phí uoc tinh: 10-60.000₫/tháng thay vi $20+ USD
11.8 Memory Search — AI nhớ mọi thứ
Memory Search cho phép AI nhớ lịch sử hội thoại và tìm kiếm thông tin liên quan. Kết hợp vector search (ngữ nghĩa) và text search (từ khóa).
// openclaw.json
{
"agents": {
"defaults": {
"memorySearch": {
"sources": ["memory", "sessions"],
"experimental": { "sessionMemory": true },
"provider": "gemini",
"remote": { "apiKey": "YOUR_GEMINI_API_KEY" },
"model": "gemini-embedding-001",
"query": {
"hybrid": {
"enabled": true,
"vectorWeight": 0.7,
"textWeight": 0.3
}
}
}
}
}
}🌐 Gemini
Miễn phí, khuyên dùng
🔷 OpenAI
Chính xác hơn, có phí
💻 Local
Bảo mật tuyệt đối
11.9 Hệ thống Tools — AI làm được gì?
📁 File System
read_file | Đọc file |
write_file | Ghi file |
search_files | Tìm file |
move_file | Di chuyển file |
🌐 Network
web_search | Tìm web |
fetch_url | Lấy nội dung web |
api_call | Gọi API bên thứ 3 |
// openclaw.json
{
"tools": {
"enabled": ["read_file", "write_file", "list_directory", "web_search"],
"disabled": ["execute_command", "delete_file"]
}
}
// Lenh CLI
openclaw tools enable read_file write_file
openclaw tools disable execute_command11.10 CLI Commands — Tham khảo nhanh
⚙️ Cấu hình
openclaw onboard— Setup wizardopenclaw config list— Xem configopenclaw config set key valueopenclaw config get key
🚀 Gateway
openclaw gateway installopenclaw gateway restartopenclaw gateway stopopenclaw logs --follow
📊 Theo dõi
openclaw stats— Tổng quanopenclaw stats todayopenclaw diagnoseopenclaw test api
11.11 Bảng giá model — Cập nhật 2026
| Model | Giá input | Giá output | VNĐ/1M tokens | Tốt cho |
|---|---|---|---|---|
| Claude V3 | $0.14/1M | $0.28/1M | ~10.000₫ | Hàng ngày, rẻ |
| Claude 3.5 Sonnet | $3/1M | $15/1M | ~50.000₫ | Code, viết bài |
| GPT-4o | $2.50/1M | $10/1M | ~40.000₫ | Đa năng |
| Gemini 2.0 Flash | Miễn phí | Miễn phí | 0₫ | Thử nghiệm |
| Ollama (local) | Miễn phí | Miễn phí | 0₫ | Bảo mật cao |
💡 Tỷ giá: 1 USD ≈ 25.000₫. Claude là lựa chọn tốt nhất cho người Việt vì giá rẻ và hỗ trợ tiếng Việt tốt.
