ModelScope's public OpenAPI (modelscope.cn/.well-known/openapi.json,
1.1.0+master.20261103) has GET /magicubes/balance at
https://modelscope.cn/openapi/v1, with bearerAuth ("ModelScope API
Token"): the same token API-Inference takes. Its reply is
{"success":true,"data":{"total_balance","available_balance",
"frozen_amount"}}; total is available plus what running tasks hold, so
the card shows available_balance, as "250 魔粒". A refusal
({"success":false,"message":…}) is told by balanceRefusal as ModelScope
words it. The Usage page's daily list (/magicubes/transactions) is not in
the OpenAPI, so what is spent a day comes from the card's own trend
(balanceTrend, "about N 魔粒 a day"). No web session is needed.
Run (mote): go test ./internal/provider (whole package, ok), plus the
Balance/Plan/Quota/Usage/Allowance/Key tests of internal/gui and
internal/gateway; GOOS=linux and GOOS=windows go vet ./internal/provider;
gofmt -l clean.
Broken by hand: with the api-inference.modelscope.cn case removed,
TestBalanceSourceByHost and TestModelScopeBalance go red.
Not tried: a real ModelScope token. None was at hand; unauthenticated and
fake-bearer calls to the live endpoint answer InvalidAuthentication, so
the route exists and wants a token, but a real reply's shape is the
OpenAPI's, not one seen. Short-term 魔粒 expire after 24h and the daily
grants come back, so the trend can count an expiry as spending.
Reported-by: jiabubu