diff --git a/src/client/endpoints.ts b/src/client/endpoints.ts index c1a608aa..6d44c701 100644 --- a/src/client/endpoints.ts +++ b/src/client/endpoints.ts @@ -39,9 +39,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 `${baseUrl}/v1/token_plan/remains`; } export function fileUploadEndpoint(baseUrl: string): string { diff --git a/src/config/detect-region.ts b/src/config/detect-region.ts index e8283c12..25d86c70 100644 --- a/src/config/detect-region.ts +++ b/src/config/detect-region.ts @@ -1,7 +1,7 @@ import { REGIONS, type Region } from "./schema"; import { readConfigFile, writeConfigFile } from "./loader"; -const QUOTA_PATH = "/v1/api/openplatform/coding_plan/remains"; +const QUOTA_PATH = "/v1/token_plan/remains"; function quotaUrl(region: Region): string { return REGIONS[region] + QUOTA_PATH; diff --git a/test/auth/timeout-fix.test.ts b/test/auth/timeout-fix.test.ts index 13ac7d7d..b26c08ab 100644 --- a/test/auth/timeout-fix.test.ts +++ b/test/auth/timeout-fix.test.ts @@ -29,7 +29,7 @@ describe('detect-region: probeRegion auth style fallback', () => { it('succeeds when endpoint only accepts Bearer token', async () => { server = createMockServer({ routes: { - '/v1/api/openplatform/coding_plan/remains': (req) => { + '/v1/token_plan/remains': (req) => { if (req.headers.get('Authorization') === 'Bearer bearer-only-key') { return jsonResponse({ base_resp: { status_code: 0 } }); } @@ -55,7 +55,7 @@ describe('detect-region: probeRegion auth style fallback', () => { it('succeeds when endpoint only accepts x-api-key header', async () => { server = createMockServer({ routes: { - '/v1/api/openplatform/coding_plan/remains': (req) => { + '/v1/token_plan/remains': (req) => { if (req.headers.get('x-api-key') === 'xapikey-only-key') { return jsonResponse({ base_resp: { status_code: 0 } }); } @@ -80,7 +80,7 @@ describe('detect-region: probeRegion auth style fallback', () => { it('falls back to global when key is invalid for all auth styles and regions', async () => { server = createMockServer({ routes: { - '/v1/api/openplatform/coding_plan/remains': () => + '/v1/token_plan/remains': () => jsonResponse({ error: 'unauthorized' }, 401), }, }); diff --git a/test/client/endpoints.test.ts b/test/client/endpoints.test.ts index 2cba0d18..9976cb2d 100644 --- a/test/client/endpoints.test.ts +++ b/test/client/endpoints.test.ts @@ -2,11 +2,15 @@ import { describe, it, expect } from 'bun:test'; import { quotaEndpoint } from '../../src/client/endpoints'; describe('quotaEndpoint', () => { - it('uses coding_plan/remains for global', () => { - expect(quotaEndpoint('https://api.minimax.io')).toBe('https://api.minimax.io/v1/api/openplatform/coding_plan/remains'); + it('uses token_plan/remains for global', () => { + expect(quotaEndpoint('https://api.minimax.io')).toBe('https://api.minimax.io/v1/token_plan/remains'); }); - it('uses coding_plan/remains for cn', () => { - expect(quotaEndpoint('https://api.minimaxi.com')).toBe('https://api.minimaxi.com/v1/api/openplatform/coding_plan/remains'); + it('uses token_plan/remains for cn', () => { + expect(quotaEndpoint('https://api.minimaxi.com')).toBe('https://api.minimaxi.com/v1/token_plan/remains'); + }); + + it('honors a custom base URL', () => { + expect(quotaEndpoint('https://gateway.example.com')).toBe('https://gateway.example.com/v1/token_plan/remains'); }); }); diff --git a/test/sdk/quota.test.ts b/test/sdk/quota.test.ts index 46e9abf7..d31b605a 100644 --- a/test/sdk/quota.test.ts +++ b/test/sdk/quota.test.ts @@ -4,7 +4,7 @@ import { MiniMaxSDK } from '../../src/sdk'; describe('MiniMaxSDK.quota', () => { it('should get quota info successfully', async () => { const mockFetch = mock(async (url: string) => { - if (url.includes('/v1/api/openplatform/coding_plan/remains')) { + if (url.includes('/v1/token_plan/remains')) { return new Response(JSON.stringify({ model_remains: [ {