Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>AI Token UsageNew to Visual Studio Code? Get it now.
AI Token Usage

AI Token Usage

AI Token Usage

|
1 install
| (0) | Free
Theo dõi token usage của API AI ngay trên status bar VSCode (cấu hình linh hoạt cho mọi endpoint).
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

AI Token Usage

Extension VSCode hiển thị thông tin token usage của API AI ngay trên status bar góc dưới phải, giúp theo dõi lượng token đang dùng một cách trực quan. Cấu hình linh hoạt nên dùng được với nhiều endpoint khác nhau, không khoá cứng vào một API cụ thể.

Tính năng

  • Hiển thị token còn lại + phần trăm ngay trên status bar.
  • Hover để xem chi tiết: đã dùng / còn lại / tổng, rate limit, ngày hết hạn, kèm thanh tiến trình màu liền mạch (giống Copilot).
  • Tự đổi màu cảnh báo (vàng khi còn ≤15%, đỏ khi còn ≤5%).
  • Tự động làm mới theo chu kỳ (mặc định 60 giây).
  • Lưu API key an toàn bằng VSCode SecretStorage (không lưu plaintext trong settings).
  • Cấu hình linh hoạt: tự đặt base URL, path, tên header API key, prefix và ánh xạ field JSON.

Cài đặt & chạy thử (development)

npm install
npm run compile

Sau đó nhấn F5 trong VSCode để mở cửa sổ Extension Development Host.

Sử dụng

  1. Mở Command Palette (Ctrl+Shift+P).
  2. Chạy lệnh AI Token Usage: Thiết lập API Key và nhập API key (dạng sk-...).
  3. Thông tin token sẽ xuất hiện ở góc dưới phải. Bấm vào để xem chi tiết.

Lệnh

Lệnh Mô tả
AI Token Usage: Thiết lập API Key Nhập / thay đổi / xoá API key
AI Token Usage: Làm mới Làm mới thủ công
AI Token Usage: Xem chi tiết Mở hộp thoại chi tiết

Cấu hình

Thiết lập Mặc định Mô tả
aiTokenUsage.apiBaseUrl https://api.nghimmo.com Base URL của API
aiTokenUsage.apiPath /v1/usage Path của endpoint usage (ghép sau base URL, hoặc URL đầy đủ)
aiTokenUsage.apiKeyHeader x-api-key Tên HTTP header gửi API key
aiTokenUsage.apiKeyPrefix `` Tiền tố trước API key (vd Bearer cho header Authorization)
aiTokenUsage.refreshIntervalSeconds 60 Chu kỳ tự làm mới (giây, tối thiểu 10)
aiTokenUsage.fieldMap (xem dưới) Ánh xạ field JSON response sang dữ liệu hiển thị

Ánh xạ field JSON (aiTokenUsage.fieldMap)

Cho phép map response của API bất kỳ về dữ liệu extension hiển thị. Hỗ trợ dot-path cho JSON lồng nhau (vd data.tokens.used).

Mặc định khớp với response dạng:

{
  "name": "Key 1",
  "tokens_total": 10000000,
  "tokens_used": 311879,
  "tokens_remaining": 9688121,
  "rate_limit_per_min": 60,
  "expires_at": "2026-06-11T08:01:13.573Z"
}

Ví dụ map cho một API có cấu trúc lồng nhau khác (header Authorization: Bearer ...):

{
  "aiTokenUsage.apiBaseUrl": "https://api.example.com",
  "aiTokenUsage.apiPath": "/account/quota",
  "aiTokenUsage.apiKeyHeader": "Authorization",
  "aiTokenUsage.apiKeyPrefix": "Bearer ",
  "aiTokenUsage.fieldMap": {
    "name": "account.label",
    "tokensTotal": "quota.limit",
    "tokensUsed": "quota.used",
    "tokensRemaining": "",
    "rateLimitPerMin": "quota.rpm",
    "expiresAt": "quota.reset_at"
  }
}

Nếu tokensRemaining bỏ trống, extension tự tính tokensTotal - tokensUsed.

Đóng gói (.vsix)

npm install -g @vscode/vsce
vsce package
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft