This repository has moved into one monorepo.
The whole MiniMax set — the credit proxy, the daily check-in, the model-list sync, the composer quota chip, the MiniMax Code bridge, and the shared grant reader — now lives in
borncode-app/dsh-minimax-kit, one repository with one Plugins entry.
this repo new home dsh-minimax-authpackages/dsh-minimax-authdsh-minimax-creditpackages/dsh-minimax-creditdsh-minimax-checkinpackages/dsh-minimax-checkindsh-minimax-model-syncpackages/dsh-minimax-model-syncdsh-minimax-bridgepackages/dsh-minimax-bridgedsh-model-quotapackages/dsh-model-quotaThe code and its history are unchanged; only the repository is shared. Install
dsh-minimax-kitinstead of the individual bundles. This repository stays open so the old links keep working.
dsh-minimax-credit
Keeps the MiniMax route alive after the Token Plan quota is spent — and shows the credits left.
Where the one-entry kit lives
This plugin, dsh-minimax-checkin, dsh-minimax-model-sync, dsh-model-quota
and dsh-minimax-bridge are also published as one bundle:
dsh-minimax-kit.
Install the kit instead if you want the whole MiniMax set from a single Plugins entry. It ships these same packages as separate rows, so the code here is unchanged and each part keeps its own switch — this repository stays the home of the proxy, the quota probe, the credit and wallet reads, and the composer chip.
Where the sign-in code lives now
The MiniMax Code grant reader — reading ~/.minimax/auth, refreshing it under
the app's own auth.lock, and the token/generation bookkeeping — moved to
dsh-minimax-auth.
This plugin and dsh-minimax-checkin both import it, so one refresh path writes
the grant instead of two. The dependency is pinned to a commit; bump
@local/dsh-minimax-auth in package.json to take a newer one.
Nothing else moved: this repository still owns the proxy, the quota probe, the
credit and wallet reads, and the composer chip. The TokenSource export remains
here as a subclass that supplies this plugin's error class and
MINIMAX_CREDIT_* codes.
The problem
A MiniMax Token Plan API key (sk-cp-…) works against https://api.minimax.io/anthropic until the plan
quota runs out, and then it simply stops:
HTTP 429
{"type":"error","error":{"type":"rate_limit_error",
"message":"Token Plan usage limit reached: Upgrade your Token Plan or purchase Credits for more usage. (2056)"}}
Inside MiniMax Code the same moment is invisible, because that app calls the provider through its own proxy using
the account's OAuth grant (mcode-public) — a grant that is billed to credits once the plan is spent, on the
same Anthropic-Messages wire format. This plugin closes that gap for the Harness.
What it does
It serves a local Anthropic-Messages proxy and points the minimax-api route at it:
- forwards to the Token Plan endpoint while the plan has quota;
- on a genuine plan-quota 429, retries the request against the MiniMax Code credit endpoint with the account's OAuth token — automatically, no model switch, no new session;
- falls back to the plan the moment its quota comes back;
- reads and shows the remaining credits of the account as a chip on the composer.
Features
- Transparent failover — requests are relayed byte for byte (SSE,
tool_use,thinking, imagetool_resultincluded); nothing in the payload is rewritten. - Plan → credits → plan — no restart, no config flip; the direction is decided per request.
- Credits chip — the real balance from the account's membership record (
op_credit_summary), not the Token Plan credit pool. Yellow when the plan is spent or credits are 0; red when the grant cannot be used. - Reuses MiniMax Code's grant in place — reads
~/.minimax/auth/<buildEnv>/<region>/mcode-public/auth.json, refreshes it with the same OAuth flow app uses, and writes the new grant back in the app's own format (bumpinggeneration, taking the same lock file) so DSH and MiniMax Code never fight over one token. - Status route —
GET /plugins/minimax-credit/status(andGET :45677/status) reportsmode,plan.percent,credits.remaining,credits.wallet,token.ok, and request counters.
Requirements
| DeepSeek Harness | 0.2.x |
| Runtime | Node 24, supplied by the Harness runtime |
| MiniMax Code | Signed in on the same machine — the credit fallback has no other token source |
| Env | MINIMAX_API_KEY for the plan side |
| Port | 45677 free (configurable) |
| Peer | dsh-minimax-auth — the shared grant reader (a link: dependency, not a bundle) |
Install
git clone https://github.com/borncode-app/dsh-minimax-credit.git dsh-minimax-credit
git clone https://github.com/borncode-app/dsh-minimax-auth.git dsh-minimax-auth
cd dsh-minimax-credit && pnpm install
Then:
plugin_manager install_bundle target=C:\path\to\dsh-minimax-credit
Finally point the route at the proxy — in your profile's cordis.patch.yml, the llm-pi-ai entry:
- id: llm-pi-ai
name: "@deepseek-ai/dsh-llm-pi-ai"
config:
providers:
minimax-api:
apiKeyEnv: MINIMAX_API_KEY
api: anthropic-messages
baseURL: http://127.0.0.1:45677/anthropic # was https://api.minimax.io/anthropic
# models: … unchanged
Restart once. A route's baseURL must be a literal origin, which is exactly why the proxy lives on loopback.
Configuration
| field | default | meaning |
|---|---|---|
enabled |
true |
false = plain proxy with no credit fallback |
listenHost / listenPort |
127.0.0.1 / 45677 |
Where the proxy listens — must match baseURL |
minimaxHome |
'' |
Empty selects $MINIMAX_HOME, else ~/.minimax |
buildEnv / region |
prod / en |
Locates the OAuth files under ~/.minimax/auth/… |
oauthTokenURL |
'' |
Empty selects https://account.minimax.io/oauth2/token (cn uses .cn) |
planBaseURL |
https://api.minimax.io/anthropic |
Token Plan upstream |
creditBaseURL |
https://agent.minimax.io/mavis/api/v1/llm/v1 |
MiniMax Code credit upstream |
quotaURL |
…/coding_plan/remains |
Where plan quota is read |
creditURL |
…/token_plan_credit |
Fallback-switch / Token Plan credit pool |
membershipURL |
…/commerce/get_membership_info |
Where credits remaining are read |
walletURL |
…/account/query_balance |
Wallet balance |
apiKeyEnv |
MINIMAX_API_KEY |
Credential ref used for the plan side |
quotaCacheMs / creditsCacheMs |
60000 |
Cache lifetimes for the two probes |
refreshSkewMs |
600000 |
Refresh the OAuth grant this far ahead of expiry |
How it works
llm-pi-ai route "minimax-api" (baseURL → 127.0.0.1:45677/anthropic)
│
â–¼
dsh-minimax-credit proxy
├─ read plan quota (cached 60 s)
├─ plan has quota ──▶ api.minimax.io/anthropic (API key)
└─ plan spent ──▶ agent.minimax.io/mavis/…/llm/v1 (OAuth grant)
│
â–¼
credits chip ── membership endpoint ── op_credit_summary
Things worth knowing
- Credits have a price. When fallback runs, every turn is billed to your credit balance.
- MiniMax Code must be signed in on the same machine. No grant, no fallback — the chip turns red and says so.
- The balance can lag. The membership endpoint caches on their side; do not use the number for real-time billing decisions.
- The proxy has no auth of its own. It binds loopback only. Do not expose the port.
Files
| file | role |
|---|---|
index.js |
proxy, quota probe, credit/wallet reads, status route; the grant reader comes from dsh-minimax-auth |
client.js |
the credits chip |
cordis.patch.yml |
the bundle patch with the row and its defaults |
locale/{en,th,zh}.json |
UI strings |
icon.svg |
plugin icon |
test-proxy.mjs |
offline suite (14 cases: decision, fallback, 401, stream, status, credits) |
test-live.mjs, test-refresh.mjs |
live checks against the real endpoints (not shipped to npm) |
ภาษาไทย
Token Plan หมดà¹à¸¥à¹‰à¸§ route minimax-api ขà¸à¸‡ DSH จะตายทันที (429) à¹à¸•่ในà¹à¸à¸› MiniMax Code ไม่ตาย เพราะมันยิงผ่าน
proxy ขà¸à¸‡à¸•ัวเà¸à¸‡à¸”้วย OAuth grant (mcode-public) ที่**หัà¸à¹€à¸›à¹‡à¸™à¹€à¸„รดิต**ได้ Plugin นี้ทำà¹à¸šà¸šà¹€à¸”ียวà¸à¸±à¸™à¹ƒà¸«à¹‰ DSH:
- เปิด proxy à¹à¸šà¸š Anthropic-Messages บน
127.0.0.1:45677à¹à¸¥à¹‰à¸§à¸Šà¸µà¹‰baseURLขà¸à¸‡ route มาที่นี่ - โควตายังมี → ส่งต่à¸à¹„ป Token Plan; เจภ429 เพราะโควตาหมด → ส่งต่à¸à¹„ป credit endpoint ด้วย OAuth token ขà¸à¸‡à¹à¸à¸›
- โควตาà¸à¸¥à¸±à¸šà¸¡à¸² → à¸à¸¥à¸±à¸šà¹„ปใช้ Token Plan เà¸à¸‡à¸à¸±à¸•โนมัติ (ไม่ต้à¸à¸‡à¸ªà¸¥à¸±à¸šà¹‚มเดล/เริ่ม session ใหม่)
- มีป้าย "เครดิต N" ใต้ช่à¸à¸‡à¸žà¸´à¸¡à¸žà¹Œ (ตัวเลขจริงจาà¸
op_credit_summaryตรงà¸à¸±à¸šà¸«à¸™à¹‰à¸² Usage ขà¸à¸‡ MiniMax Code) - à¸à¹ˆà¸²à¸™/ต่à¸à¸à¸²à¸¢à¸¸ token ขà¸à¸‡ MiniMax Code ในไฟล์เดิม พร้à¸à¸¡ lock/generation เหมืà¸à¸™à¹à¸à¸› → ไม่à¹à¸¢à¹ˆà¸‡ token à¸à¸±à¸™
âš ï¸ à¹€à¸„à¸£à¸”à¸´à¸•à¸¡à¸µà¸¡à¸¹à¸¥à¸„à¹ˆà¸² — เมื่ภfallback ทำงาน ทุà¸à¹€à¸—ิร์นจะถูà¸à¸«à¸±à¸à¹€à¸‡à¸´à¸™à¸ˆà¸£à¸´à¸‡, ต้à¸à¸‡à¸¡à¸µ MiniMax Code ล็à¸à¸à¸à¸´à¸™à¸šà¸™à¹€à¸„รื่à¸à¸‡à¹€à¸”ียวà¸à¸±à¸™, à¹à¸¥à¸° proxy ไม่มี auth ขà¸à¸‡à¸•ัวเà¸à¸‡ (ผูภloopback เท่านั้น)
License
MIT © 2026 BornCode
No comments yet. Be the first to write one.