From a4bbafcbd4860e8984ed18cd0fa0eaf32a1d29ae Mon Sep 17 00:00:00 2001 From: yuanhe Date: Thu, 16 Apr 2026 12:11:21 -0700 Subject: [PATCH] fix: use correct token_plan/remains endpoint for quota query The old endpoint v1/api/openplatform/coding_plan/remains returned incorrect data. Switch to v1/token_plan/remains and fix the usage calculation that previously treated usage_count as remaining. Bump version to 1.0.8. --- package.json | 2 +- src/client/endpoints.ts | 2 +- src/output/quota-table.ts | 6 +-- test/fixtures/quota-response.json | 90 ++++++++++++++----------------- 4 files changed, 45 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 0998b41..a4813c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mmx-cli", - "version": "1.0.7", + "version": "1.0.8", "description": "CLI for the MiniMax AI Platform", "type": "module", "engines": { diff --git a/src/client/endpoints.ts b/src/client/endpoints.ts index e4a4f45..617c703 100644 --- a/src/client/endpoints.ts +++ b/src/client/endpoints.ts @@ -41,7 +41,7 @@ export function vlmEndpoint(baseUrl: string): string { export function quotaEndpoint(baseUrl: string): string { // Quota endpoint uses api subdomain const host = baseUrl.includes('minimaxi.com') ? 'https://api.minimaxi.com' : 'https://api.minimax.io'; - return `${host}/v1/api/openplatform/coding_plan/remains`; + return `${host}/v1/token_plan/remains`; } export function fileUploadEndpoint(baseUrl: string): string { diff --git a/src/output/quota-table.ts b/src/output/quota-table.ts index 34b0e6f..5b5fbe4 100644 --- a/src/output/quota-table.ts +++ b/src/output/quota-table.ts @@ -114,13 +114,11 @@ export function renderQuotaTable(models: QuotaModelRemain[], config: Config): vo for (const m of models) { console.log(boxLine(W, '├', '─', '┤', useColor)); - const remaining = m.current_interval_usage_count; + const used = m.current_interval_usage_count; const limit = m.current_interval_total_count; - const used = Math.max(0, limit - remaining); const usedPct = limit > 0 ? Math.round((used / limit) * 100) : 0; - const weekRemaining = m.current_weekly_usage_count; + const weekUsed = m.current_weekly_usage_count; const weekLimit = m.current_weekly_total_count; - const weekUsed = Math.max(0, weekLimit - weekRemaining); const resets = formatDuration(m.remains_time, L.now); const nameStr = m.model_name.padEnd(maxNameLen); diff --git a/test/fixtures/quota-response.json b/test/fixtures/quota-response.json index bff90ef..6dff3be 100644 --- a/test/fixtures/quota-response.json +++ b/test/fixtures/quota-response.json @@ -3,53 +3,45 @@ "status_code": 0, "status_msg": "success" }, - "data": { - "plan": "Max-Highspeed", - "period_start": "2025-08-01", - "period_end": "2025-09-01", - "models": [ - { - "model": "MiniMax-M2.7-highspeed", - "used": 8241, - "limit": 15000, - "reset": "rolling 5h", - "unit": "requests" - }, - { - "model": "speech-2.8-hd", - "used": 4300, - "limit": 19000, - "reset": "daily", - "unit": "characters" - }, - { - "model": "image-01", - "used": 42, - "limit": 200, - "reset": "daily", - "unit": "images" - }, - { - "model": "Hailuo-2.3", - "used": 1, - "limit": 3, - "reset": "daily", - "unit": "videos" - }, - { - "model": "Hailuo-2.3-Fast", - "used": 0, - "limit": 3, - "reset": "daily", - "unit": "videos" - }, - { - "model": "music-2.5", - "used": 2, - "limit": 7, - "reset": "daily", - "unit": "songs" - } - ] - } + "model_remains": [ + { + "model_name": "MiniMax-M*", + "start_time": 1776355200000, + "end_time": 1776373200000, + "remains_time": 7151954, + "current_interval_total_count": 1500, + "current_interval_usage_count": 228, + "current_weekly_total_count": 0, + "current_weekly_usage_count": 0, + "weekly_start_time": 1776009600000, + "weekly_end_time": 1776614400000, + "weekly_remains_time": 248351954 + }, + { + "model_name": "speech-hd", + "start_time": 1776355200000, + "end_time": 1776441600000, + "remains_time": 75551954, + "current_interval_total_count": 9000, + "current_interval_usage_count": 0, + "current_weekly_total_count": 63000, + "current_weekly_usage_count": 0, + "weekly_start_time": 1776009600000, + "weekly_end_time": 1776614400000, + "weekly_remains_time": 248351954 + }, + { + "model_name": "image-01", + "start_time": 1776355200000, + "end_time": 1776441600000, + "remains_time": 75551954, + "current_interval_total_count": 100, + "current_interval_usage_count": 0, + "current_weekly_total_count": 700, + "current_weekly_usage_count": 0, + "weekly_start_time": 1776009600000, + "weekly_end_time": 1776614400000, + "weekly_remains_time": 248351954 + } + ] }