Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/client/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/config/detect-region.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions test/auth/timeout-fix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand All @@ -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 } });
}
Expand All @@ -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),
},
});
Expand Down
12 changes: 8 additions & 4 deletions test/client/endpoints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
2 changes: 1 addition & 1 deletion test/sdk/quota.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
Loading