Skip to content

Commit f42ee5e

Browse files
authored
Merge pull request #175 from MiniMax-AI/fix/cli-quota-endpoint-token-plan
fix(quota): use /v1/token_plan/remains and honor custom base URL
2 parents 109287d + c3a58e9 commit f42ee5e

5 files changed

Lines changed: 14 additions & 12 deletions

File tree

src/client/endpoints.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ export function vlmEndpoint(baseUrl: string): string {
3939
}
4040

4141
export function quotaEndpoint(baseUrl: string): string {
42-
// Quota endpoint uses api subdomain
43-
const host = baseUrl.includes('minimaxi.com') ? 'https://api.minimaxi.com' : 'https://api.minimax.io';
44-
return `${host}/v1/api/openplatform/coding_plan/remains`;
42+
return `${baseUrl}/v1/token_plan/remains`;
4543
}
4644

4745
export function fileUploadEndpoint(baseUrl: string): string {

src/config/detect-region.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { REGIONS, type Region } from "./schema";
22
import { readConfigFile, writeConfigFile } from "./loader";
33

4-
const QUOTA_PATH = "/v1/api/openplatform/coding_plan/remains";
4+
const QUOTA_PATH = "/v1/token_plan/remains";
55

66
function quotaUrl(region: Region): string {
77
return REGIONS[region] + QUOTA_PATH;

test/auth/timeout-fix.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('detect-region: probeRegion auth style fallback', () => {
2929
it('succeeds when endpoint only accepts Bearer token', async () => {
3030
server = createMockServer({
3131
routes: {
32-
'/v1/api/openplatform/coding_plan/remains': (req) => {
32+
'/v1/token_plan/remains': (req) => {
3333
if (req.headers.get('Authorization') === 'Bearer bearer-only-key') {
3434
return jsonResponse({ base_resp: { status_code: 0 } });
3535
}
@@ -55,7 +55,7 @@ describe('detect-region: probeRegion auth style fallback', () => {
5555
it('succeeds when endpoint only accepts x-api-key header', async () => {
5656
server = createMockServer({
5757
routes: {
58-
'/v1/api/openplatform/coding_plan/remains': (req) => {
58+
'/v1/token_plan/remains': (req) => {
5959
if (req.headers.get('x-api-key') === 'xapikey-only-key') {
6060
return jsonResponse({ base_resp: { status_code: 0 } });
6161
}
@@ -80,7 +80,7 @@ describe('detect-region: probeRegion auth style fallback', () => {
8080
it('falls back to global when key is invalid for all auth styles and regions', async () => {
8181
server = createMockServer({
8282
routes: {
83-
'/v1/api/openplatform/coding_plan/remains': () =>
83+
'/v1/token_plan/remains': () =>
8484
jsonResponse({ error: 'unauthorized' }, 401),
8585
},
8686
});

test/client/endpoints.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { describe, it, expect } from 'bun:test';
22
import { quotaEndpoint } from '../../src/client/endpoints';
33

44
describe('quotaEndpoint', () => {
5-
it('uses coding_plan/remains for global', () => {
6-
expect(quotaEndpoint('https://api.minimax.io')).toBe('https://api.minimax.io/v1/api/openplatform/coding_plan/remains');
5+
it('uses token_plan/remains for global', () => {
6+
expect(quotaEndpoint('https://api.minimax.io')).toBe('https://api.minimax.io/v1/token_plan/remains');
77
});
88

9-
it('uses coding_plan/remains for cn', () => {
10-
expect(quotaEndpoint('https://api.minimaxi.com')).toBe('https://api.minimaxi.com/v1/api/openplatform/coding_plan/remains');
9+
it('uses token_plan/remains for cn', () => {
10+
expect(quotaEndpoint('https://api.minimaxi.com')).toBe('https://api.minimaxi.com/v1/token_plan/remains');
11+
});
12+
13+
it('honors a custom base URL', () => {
14+
expect(quotaEndpoint('https://gateway.example.com')).toBe('https://gateway.example.com/v1/token_plan/remains');
1115
});
1216
});

test/sdk/quota.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MiniMaxSDK } from '../../src/sdk';
44
describe('MiniMaxSDK.quota', () => {
55
it('should get quota info successfully', async () => {
66
const mockFetch = mock(async (url: string) => {
7-
if (url.includes('/v1/api/openplatform/coding_plan/remains')) {
7+
if (url.includes('/v1/token_plan/remains')) {
88
return new Response(JSON.stringify({
99
model_remains: [
1010
{

0 commit comments

Comments
 (0)