Chuyển đến nội dung chính
Hướng dẫn này dành cho người dùng self-hosted OpenClaw muốn kết nối TokenLab làm provider AI của họ.

Khuyến nghị: cài đặt plugin

Để chạy agent OpenClaw theo cách tiêu chuẩn, hãy cài đặt plugin provider TokenLab:
openclaw plugins install @tokenlabai/openclaw-provider
openclaw onboard --tokenlab-api-key "$TOKENLAB_API_KEY"
Plugin tải danh mục model chat trực tiếp của TokenLab và giữ 18 model dự phòng để khám phá khi ngoại tuyến. Model sử dụng định dạng tokenlab/<model-id>. Gói npm · Trang ClawHub · Mã nguồn

Cấu hình provider thủ công

Chỉ dùng các mục models.providers thủ công bên dưới khi bạn thực sự cần các route riêng cho Responses API, Claude native, Gemini native hoặc MiniMax native. Nếu bạn chọn cấu hình thủ công, chỉ cần cấu hình tokenlab là đủ. Chỉ thêm các provider khác khi bạn thực sự cần hành vi Responses API, Claude native, Gemini native, hoặc MiniMax native.
Nhà cung cấpOpenClaw apiPhù hợp chobaseUrl
tokenlabopenai-completionsGPT, DeepSeek, Qwen, và hầu hết các gọi tương thích OpenAIhttps://api.tokenlab.sh/v1
tokenlab-responsesopenai-responsesCác luồng công việc OpenAI Responses mong đợi ngữ nghĩa /v1/responseshttps://api.tokenlab.sh/v1
tokenlab-claudeanthropic-messagesAPI Messages gốc của Claudehttps://api.tokenlab.sh
tokenlab-geminigoogle-generative-aiĐịnh dạng API Gemini gốchttps://api.tokenlab.sh
tokenlab-minimaxanthropic-messagesĐiều hướng MiniMax gốchttps://api.tokenlab.sh
Chỉ sử dụng hậu tố /v1 cho openai-completionsopenai-responses.Các nhà cung cấp gốc như anthropic-messagesgoogle-generative-ai nên dùng https://api.tokenlab.sh mà không có /v1, nếu không OpenClaw có thể tạo sai đường dẫn upstream.

Yêu cầu tiên quyết

  • Một instance OpenClaw self-hosted
  • Một TokenLab API Key — Get one here

Cấu hình

Chỉnh sửa cấu hình OpenClaw của bạn:
  • Tự lưu trữ: ~/.openclaw/openclaw.json
Thêm provider TokenLab dưới models.providers:
{
  agents: {
    defaults: {
      model: {
        primary: "tokenlab-claude/claude-sonnet-4-6"
      }
    }
  },
  models: {
    mode: "merge",
    providers: {
      tokenlab: {
        api: "openai-completions",
        baseUrl: "https://api.tokenlab.sh/v1",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "gpt-4o", name: "GPT-4o" },
          { id: "deepseek-r1", name: "DeepSeek R1" },
          { id: "qwen3-coder-flash", name: "Qwen 3 Coder Flash" }
        ]
      },
      "tokenlab-responses": {
        api: "openai-responses",
        baseUrl: "https://api.tokenlab.sh/v1",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "gpt-4o", name: "GPT-4o (Responses)" },
          { id: "gpt-5.2", name: "GPT-5.2 (Responses)" }
        ]
      },
      "tokenlab-claude": {
        api: "anthropic-messages",
        baseUrl: "https://api.tokenlab.sh",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
          { id: "claude-opus-4-6", name: "Claude Opus 4.6" }
        ]
      },
      "tokenlab-gemini": {
        api: "google-generative-ai",
        baseUrl: "https://api.tokenlab.sh",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "gemini-3.5-flash", name: "Gemini 3.5 Flash" },
          { id: "gemini-2.5-pro", name: "Gemini 2.5 Pro" }
        ]
      },
      "tokenlab-minimax": {
        api: "anthropic-messages",
        baseUrl: "https://api.tokenlab.sh",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "minimax-m3", name: "MiniMax M3" }
        ]
      }
    }
  }
}
Cả 5 nhà cung cấp đều dùng cùng một API Key. Bạn chỉ cần một tài khoản TokenLab.
Các mảng models ở trên chỉ hiển thị các ví dụ phổ biến. Thêm các model ID khác cho từng nhà cung cấp khi cần.

Sử dụng Models

OpenClaw vẫn tham chiếu các model theo định dạng provider/model:
{
  agents: {
    defaults: {
      model: {
        primary: "tokenlab-gemini/gemini-3.5-flash"
      }
    }
  }
}

Ví dụ Model

Nhà cung cấpTham chiếu modelMô tả
tokenlabtokenlab/gpt-4oRoute tương thích OpenAI
tokenlabtokenlab/deepseek-r1Mô hình suy luận DeepSeek
tokenlab-responsestokenlab-responses/gpt-4oRoute Responses API
tokenlab-claudetokenlab-claude/claude-sonnet-4-6Route Messages gốc của Claude
tokenlab-geminitokenlab-gemini/gemini-3.5-flashRoute Gemini gốc
tokenlab-minimaxtokenlab-minimax/minimax-m3Route MiniMax gốc
Browse all available models at tokenlab.sh/models.

Khi nào sử dụng provider nào

  • tokenlab: lựa chọn mặc định cho hầu hết các trường hợp sử dụng agent và chat đa dụng.
  • tokenlab-responses: dùng khi luồng công việc OpenClaw của bạn phụ thuộc rõ ràng vào ngữ nghĩa OpenAI Responses.
  • tokenlab-claude: dùng khi bạn muốn hành vi Messages gốc của Claude.
  • tokenlab-gemini: dùng khi bạn cần định dạng yêu cầu/đáp trả gốc của Gemini hoặc tích hợp theo kiểu Gemini hiện có.
  • tokenlab-minimax: dùng khi bạn muốn MiniMax theo route gốc của nó.
Nếu bạn không cần hành vi Gemini-gốc, bạn vẫn có thể gọi các model Gemini thông qua tokenlab/gemini-* trên route tương thích OpenAI.

Những lỗi phổ biến

Tài liệu OpenClaw hiện tại sử dụng models.providers. Nếu bạn giữ định dạng mảng providers cấp cao cũ, OpenClaw có thể bỏ qua cấu hình hoặc không thể giải quyết tiền tố provider như mong đợi.
openai-responses ánh xạ đến đường dẫn /v1/responses của TokenLab, nên tokenlab-responses phải sử dụng https://api.tokenlab.sh/v1.
anthropic-messagesgoogle-generative-ai nên sử dụng https://api.tokenlab.sh mà không có /v1. Thêm /v1 có thể tạo ra các đường dẫn yêu cầu không chính xác.
Có. Tài liệu OpenClaw hiện tại vẫn bao gồm provider tích hợp sẵn google và cũng hỗ trợ các provider tùy chỉnh sử dụng api: "google-generative-ai". Vì vậy tokenlab-gemini vẫn là một route Gemini gốc hợp lệ cho người dùng OpenClaw.

Xác minh cấu hình

Sau khi lưu cấu hình, khởi động lại instance OpenClaw của bạn và thử với một tin nhắn đơn giản. Nếu bạn nhận được phản hồi, provider đã được cấu hình chính xác.
# Tự lưu trữ: khởi động lại dịch vụ
systemctl --user restart openclaw    # Linux
launchctl stop cc.tokenlab.openclaw && launchctl start cc.tokenlab.openclaw  # macOS

Bước tiếp theo

Khi OpenClaw đã kết nối, các hướng dẫn sau sẽ giúp bạn sử dụng TokenLab hiệu quả hơn:
  • Định dạng API — hiểu sự khác nhau giữa các route OpenAI, Responses, Anthropic và Gemini
  • IDE / SDK Compatibility — xem khi nào /v1/responses là lựa chọn phù hợp hơn
  • Xử lý lỗi — tìm hiểu các chế độ thất bại phổ biến và các mẫu phục hồi
  • Tổng quan mô hình — duyệt các ID model trước khi kết nối chúng vào agents