Skip to content

按次计费的配音也要预算:MiniMax 按量付费、ElevenLabs、阿里云百炼没写预算就不调 - #236

Merged
ZLHad merged 10 commits into
mainfrom
claude/paid-speech-budget
Nov 22, 2026
Merged

ZLHad merged 10 commits into
mainfrom
claude/paid-speech-budget

Conversation

@ZLHad

@ZLHad ZLHad commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

A voice billed per use now waits for a budget, the way a generated picture or a Lyria track already does. Since #234, a key saved in Studio reaches every command, the agent in Studio's column included, so bin/vh tts and bin/vh voices audition could spend money with no budget at all. Three flaky checks are fixed too, each in its own commit.

Which calls need a budget, and why

Call Budget? Why
tts / voices audition --provider minimax with MINIMAX_API_KEY alone yes pay-as-you-go: "from your account balance based on usage" (MiniMax's pricing page)
… with MINIMAX_TOKEN_PLAN_KEY (tts tries it first) no, as before spends the Token Plan's credits, not the balance
--provider elevenlabs yes "API usage is billed in US dollars, not credits" (ElevenLabs' API pricing page)
--provider dashscope yes per 10,000 characters of input, after a new account's free quota
qwen, say no this computer
edge no no key, nothing billed
gemini, gemini-lite, --align gemini, voices list / design / delete no, as before the free quota first (the architect's call: the user's films run on it)

How it works (as image and lyria do)

  • The key first, then the budget. When both are missing the person reads the key line (Studio settings (c): a missing API Key says where to set it, and the film's now line says it waits on it #235's sentence): a budget is no use without a key.
  • The whole run first. Before any request and before the old takes are deleted, the run's estimate goes through budget.check:
    • which requests count: the lines or blocks still to make (--resume counts only those left, --candidates N N of each);
    • the estimate: characters × the price.
    • With no Budget line (BRIEF, else LOCAL.md's 默认预算), a budget of 0, or one it would go over, nothing is called. One line says what to write, or how much is missing.
  • Each request is held, then settled. Every request is held at its own estimate in the film's assets/spend.jsonl, then settled at what the answer says was billed:
    • MiniMax: extra_info.usage_characters, "Number of billable characters used in this synthesis";
    • DashScope: usage.characters;
    • ElevenLabs: its answer says nothing, so the estimate stands. That is an upper bound, since characters a plan includes are not billed per use; the run's end line and the ledger entry both say so.
  • What a failed request costs:
    • an error answer (HTTP error, a MiniMax error status) or a request that never left: 0;
    • a timeout or an answer cut off: the estimate stays, said as "may have been billed";
    • each MiniMax retry is a request of its own.
  • The end line. bin/vh tts ends with how many requests were made, what they cost, and the budget line.
  • Unknown price. A model or an endpoint the table lacks (another *_MODEL, a *_BASE_URL elsewhere) needs a Budget line that is not 0. Each request is then recorded as "cost not known, maybe billed".
  • Audition. It reads the budget of the film its text file is in (BRIEF.md at or above it). A text in no film is refused before any request.
  • budget.py. Two holds made in one millisecond used to share an id, so settling one counted the other as settled. Ids now carry a per-process count. Retries and back-to-back auditions made this reachable.

Prices, each read on the provider's own page on 2026-11-22

The table is in tools/audio/speechcost.py, with each page's URL beside its numbers; python3 tools/audio/speechcost.py lists it.

  • MiniMax, international (the default): speech-2.8-hd and 2.6/02-hd "$100 / M characters"; the turbo models "$60 / M characters". Page: https://platform.minimax.io/docs/guides/pricing. This page does not say how characters are counted, so the China page's rule (a 汉字 = 2) is used: the larger count.
  • MiniMax, China platform (MINIMAX_BASE_URL on minimaxi.com or minimax.cn): hd 3.50 元/万字符, turbo 2.00 元/万字符, "1 个汉字算 2 个字符". Page: https://platform.minimax.cn/docs/guides/pricing (platform.minimaxi.com redirects there).
  • ElevenLabs: eleven_multilingual_v2 (the default) and eleven_v3 "$0.08" per 1K characters; the Flash/Turbo v2.5 models "$0.04". Page: https://elevenlabs.io/pricing/api.
  • A model not in the table, on an endpoint in it: priced as that endpoint's most expensive model, said as assumed (review round 1).
  • Alibaba Cloud Model Studio, qwen3-tts-flash:

Three flaky checks (one commit each)

  • words_checks: it looked for "L8" anywhere in the report, and the report prints the temp path. It now matches the line-number column only. Shown failing before and passing after with a temp folder named wL8L8.
  • The Studio app check: the stand-in app's window thread can write "lost" after "quit". The check now reads how the app ended with the "lost" lines left out. A logic table over the orders seen covers it: the flaky order passes, a real failure still fails.
  • The page tools' browser start (tools/textcheck/browser.mjs), seen as readcheck --export failing on GitHub's macOS runner:
    • a browser that did not start (no answer within 60 s, or gone before one) is closed, and a second one is started, said in one line;
    • a program that is not there is not tried again.
    • This one has its own change note.

What the first full run turned up (fixed in 2b51325)

  • Two older tts checks now meet the budget gate:
    • the DashScope --resume check gets a Budget line in yuan;
    • the in-process MiniMax --candidates check uses a stand-in Token Plan key. On this machine it had passed only because the shell holds a real Token Plan key, which tts tries first; on GitHub's runner it would have stopped at "no budget".
  • The fake minimax_tts takes the new out=.
  • The settings page's key-read rule flagged del os.environ["MINIMAX_TOKEN_PLAN_KEY"] in the new check. It is now an assignment to "".
  • tools/artifacts.json lists tts and voices as writers and readers of assets/spend.jsonl and its lock.

Checks run

  • tools/ci.sh --committed:
  • New paid_speech_checks, under assets_checks, with stand-ins only: no key, no network, OVH_KEYSTORE=none, a dead proxy as a guard.
    • The refusals from the command line: the key first, and with no budget nothing is called, deleted or recorded.
    • Each provider's settle path from stand-in answers.
    • End to end: a stand-in T2A server, two requests on record, the end line, --resume asking nothing more.
    • An audition outside a film.
  • 13 mutations, each turning the right check red:
    • no check before the run, or the check after the old takes are deleted;
    • the Token Plan key metered;
    • usage_characters ignored, DashScope's usage ignored;
    • an error status billed, a request that never left taken as sent;
    • ElevenLabs' upper bound unsaid;
    • a 汉字 counted as 1, China's MiniMax at international prices;
    • an unknown price allowed with no budget;
    • an audition outside a film allowed;
    • two holds in one millisecond sharing an id.
      Two more for the browser start: no second try, and a missing program retried.
  • Looked at: Studio's settings → Services, the new budget sentence in Chinese and English. This was in an isolated console: every folder temporary, port 8836, no app window, OVH_KEYSTORE=none.

Not looked at, or not in this PR

  • The two CLAUDE.md sentences (the baseline's last sentence and hard rule 7) are in c0249cf, the architect's commit, with AGENTS.md regenerated and playbook/05's line on keys.
  • No real provider was called (no key, no money). Two things therefore come from the docs and are not seen live:
    • the shape of usage.characters in DashScope's SDK answer (read as a dict or an attribute);
    • MiniMax's international counting rule.
  • bin/vh tts --provider dashscope with a key and no budget first lets uv fetch the dashscope package, then refuses. bin/vh picks the packages before tts.py runs, and the CI checks call tts.py directly.
  • The real 60 s start case was not reproduced; a browser that exits before answering stands in for it, through the same code.

Review round 1 (cef42c4, 7ebcd82)

  1. An unlisted model no longer turns any budget into no cap.
    • A model the table lacks, on an endpoint it has, is priced as that endpoint's most expensive model, with the usual hold and settle. The run's line, the refusal and the ledger say the price was assumed.
    • Model names match whatever their case (speech-2.8-HD).
    • "Cost not known, maybe billed" is now only for an endpoint the table lacks (a proxy, a stand-in), and each such request is still recorded.
    • Checks: speech-2.9-hd under Budget: $0.0001 is refused; Speech-2.8-TURBO is priced as turbo; an older ElevenLabs name is priced at $0.08.
  2. The up-front check is tested for every provider:
    • a command-line no-budget refusal each for elevenlabs and dashscope, as for minimax: nothing deleted, exit 1, the budget sentence;
    • --candidates 2 on minimax: a budget that fits one take of each block, not two, is refused before anything.
  3. The estimate cannot be under the bill.
    • It counts the body each request carries: tts.body_of, the same function the MiniMax request uses, so <#0.5#> counts as the <#0.50#> that is sent.
    • Where a Chinese character counts as 2, every character that is not ASCII does: 〇, full-width punctuation, kana.
    • Check: a budget of exactly the text as written ($0.0037; $0.0038 as sent) is refused.
  4. bin/vh web's last-resort deadline (tools/web/chrome.mjs and web.py's chrome_budget) allows two starts of each browser: 3 * (2 * 70 + tab). The comments say so.
  5. Docs:
    • an unknown endpoint takes BRIEF's Budget or LOCAL.md's default;
    • minimax.cn as well as minimaxi.com;
    • the refusal exits 1;
    • the gate goes by the key's name: a pay-as-you-go key stored under the Token Plan name is not gated.

Mutations: 7 more (an unlisted model not priced, model names by case, only Han counted as 2, the estimate of the text as written, --candidates counted once, no up-front check but MiniMax's, DashScope's usage ignored), each turning the right check red; 20 in all with the earlier ones. The DashScope stand-in now bills 26 characters against an estimate of 30, so ignoring its count shows.

Full run: tools/ci.sh --committed at 7ebcd82: 792 checks passed, one known skip (frames on a HyperFrames composition).

GitHub's Linux job on c0249cf: my browser start check failed there. The behaviour was right: started again, the tab came up, a browser that never starts failed after the second try, a missing program not retried. But Linux reports the browser gone as EPIPE or ECONNRESET where macOS says "exit 1", and the check matched the exact text. e031ac2 counts the lines instead, whatever the reason and in any order. GitHub's Linux output passes it; both browser mutations still turn it red. Groups run for it (--committed --changed 7ebcd82: static, doc, readpath, film): 51 checks, all passed.

ZLHad added 10 commits November 22, 2026 17:06
…-as-you-go, ElevenLabs, DashScope

bin/vh tts and bin/vh voices audition read the film's Budget before the first request and before anything is
deleted (the key is checked first), each request is held and settled at what the answer says was billed
(ElevenLabs': the estimate, an upper bound), and the run ends with what it spent. Prices from the providers' own
pages, read 2026-11-22, in tools/audio/speechcost.py; an unknown model or endpoint needs a Budget line and is
recorded as cost not known. Local voices, edge, Gemini and the Token Plan key are used as before. budget.py: two
holds in one millisecond no longer share an id.
…temp folder's name could hold L8 and fail the run)
… 'lost' line (the stream's own thread can note it after quit)
… answer within 60 s, or gone before one); a program that is not there is not tried again
… and read spend.jsonl; the older tts checks run with a budget, or the Token Plan key, as a voice billed per use now needs; the fake minimax_tts takes out=
…a key comes from the environment or the one saved in Studio

The two sentences the maintainer approved: the baseline bullet's last sentence (bin/vh tts, music and voices
on local, subscription or free quota as before; MiniMax pay-as-you-go, ElevenLabs and DashScope under the
budget) and hard rule 7 (the environment, or the key Studio's settings page keeps in the system's password
store, both through tools/keys.py). AGENTS.md regenerated; playbook/05's line on keys says the same.
…pensive one; the estimate is of the body as sent, every character that is not ASCII as 2

- A model the price table lacks, on an endpoint it has, is priced as that endpoint's most expensive model, with the
  usual hold and settle, said to be assumed; model names match whatever their case. Only an unknown endpoint (a proxy,
  a stand-in) is still "cost not known", and each of its requests is still recorded.
- The estimate counts the body each request carries (tts.body_of: MiniMax's pause marks as rewritten), and where a
  Chinese character counts as 2 every non-ASCII character does (〇, full-width punctuation, kana): an upper bound.
- Checks: a no-budget refusal from the command line for elevenlabs and dashscope too (nothing deleted, exit 1);
  --candidates N counted in the run's estimate; the body as sent; the unlisted model, a name in another case, the count.
- Docs: LOCAL.md's default counts for an unknown endpoint; minimax.cn as well as minimaxi.com; the refusal exits 1;
  the gate goes by the key's name.
…r (a start that did not answer is now tried once more)
…was gone (Linux says EPIPE or ECONNRESET where macOS says exit 1), in any order
@ZLHad
ZLHad marked this pull request as ready for review November 22, 2026 10:40
@ZLHad
ZLHad enabled auto-merge (squash) November 22, 2026 10:40
@ZLHad
ZLHad merged commit f91bbc0 into main Nov 22, 2026
4 checks passed
@ZLHad
ZLHad deleted the claude/paid-speech-budget branch November 22, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant