Skip to content
Về trang chủ
⚙️

Chương 11: Cấu Hình Nâng Cao & Tiết Kiệm Chi Phí

Nâng Cao⏱ 15 phút đọc

11.1 Chọn model phù hợp

ModelGiáTốt cho
GPT-4o mini$0.15/1MChat hàng ngày, rẻ
GPT-4o$2.50/1MPhân tích phức tạp
Claude 3.5 Sonnet$3.00/1MViết content, code
DeepSeek V3$0.14/1MRẻ nhất, tiếng Việt tốt
Gemini 2.0 FlashMiễn phíThử nghiệm, tác vụ nhẹ

11.2 Multi-model: dùng nhiều model

Cấu hình multi-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

Fallback
// 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í

Giới hạn
{
  "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
Cấu hình Antigravity Manager
// 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 đề.

Cấu hình fallback
// 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:

Tối ưu chi phí VN
// 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).

Memory Search config
// 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_fileGhi file
search_filesTìm file
move_fileDi chuyển file

🌐 Network

web_searchTìm web
fetch_urlLấy nội dung web
api_callGọi API bên thứ 3
Bật/tắt tools
// 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_command

11.10 CLI Commands — Tham khảo nhanh

⚙️ Cấu hình

  • openclaw onboardSetup wizard
  • openclaw config listXem config
  • openclaw config set key value
  • openclaw config get key

🚀 Gateway

  • openclaw gateway install
  • openclaw gateway restart
  • openclaw gateway stop
  • openclaw logs --follow

📊 Theo dõi

  • openclaw statsTổng quan
  • openclaw stats today
  • openclaw diagnose
  • openclaw test api

11.11 Bảng giá model — Cập nhật 2026

ModelGiá inputGiá outputVNĐ/1M tokensTố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 FlashMiễ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.