gateway: a MiniMax API key makes videos with H3 (_tigerqueen_05867)

A MiniMax API-key provider (api.minimax.io, api.minimaxi.com, api.minimax.cn)
now lists MiniMax-H3, -H3-Highspeed, -H3-Lite and -H3-Max as video models.
They are never in chat lists. generate_video and /v1/videos start a task at
<host>/v2/video_generation, poll /v2/query/video_generation/<id> and hand back
the MP4. The prompt, seconds (raised to each model's minimum and capped at
15), resolution (from Extra or size, clamped to the model), ratio, first and
last frame and up to 9 reference images go through. /v1/videos now reads
last_frame; MiniMax and a remote magpie pass it on, other videomakers
ignore it. The MCP schema is unchanged.

Failures say which one it is: a turned-away key (1004/2049/401), no
pay-as-you-go balance (1008/402), refused input or output (1026/1027), a
Token Plan key without H3 (2061/2068/2057, which moves on to the next key),
or the rate limit. AutoVideomaker puts MiniMax last, so generate_video,
which has no model argument, uses MiniMax-H3 only when nothing else makes
videos. All of it is gated on a MiniMax host, so no other vendor changes.

Run on mote at 798c8fd48 (base a0ba8e1f2). The pushed head's only other
change is fb5959553, one test file in internal/usage, which none of these
packages import:
- gofmt -l: nothing listed.
- go vet ./... (darwin), GOOS=linux -tags nogui, GOOS=windows: ok.
- go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider
  ./internal/imagemcp: ok (gateway 557s, provider 95s, imagemcp 6.5s).

The fake server answers with the literal samples from MiniMax's docs (create,
succeeded, failed 1026, 401, 402, 422), plus a task stuck past the timeout.

Broken by hand, each watched go red:
- no Videomakers hook (the old code): TestMiniMaxKeysMakeH3Videos,
  TestMiniMaxH3IsNoChatModel, TestImageMCPMakesMiniMaxVideos.
- minimaxWhy returning "": TestMiniMaxVideoFailuresSayWhy.
- MiniMax not put last: TestMiniMaxComesAfterOtherVideomakers.
- no move past a Token Plan key: TestMiniMaxVideoMovesPastATokenPlanKey.

Not tried:
- the real MiniMax API: no MiniMax key is on this machine. The bodies follow
  the docs' samples only.
- the GUI: nothing changed there (it lists no video models per provider).
- test runs on Windows and Linux; vet only.
- last_frame from the MCP tool, whose schema doesn't take it.
This commit is contained in:
yetone
2026-10-29 04:56:46 +08:00
parent fb59595530
commit b2d005bf38
8 changed files with 918 additions and 16 deletions
+38
View File
@@ -475,6 +475,43 @@ on the key that started the video. A gateway key's account and model holds
apply to all three routes (`videoAsker`, `videoModelHeld`), and to Grok's
and Volcengine's polls and downloads as well.
A MiniMax API key (no account, a Chat, Anthropic or Responses base on
api.minimax.io, api.minimaxi.com or api.minimax.cn: `filmsMiniMax`,
`minimaxHost`; a relay serving MiniMax's models is not one) makes videos
with the H3 models, MiniMax-H3, -Highspeed, -Lite and -Max
([`video_minimax.go`](../../internal/gateway/video_minimax.go),
`minimaxVideoModels`). They are video models only (`Films`), listed by
`Videomakers` and never added to a chat list. A video starts at
`<host>/v2/video_generation` on that key's own host, so international and
Chinese keys each reach their platform, and is polled at
`<host>/v2/query/video_generation/<task_id>`. Its MP4 is `task.content.url`,
fetched as other vendors' video URLs are (`vendorClient`). `minimaxVideoBody`
sends the prompt and images in `content` (`first_frame` from
`input_reference`, `last_frame` from the request's `last_frame`, references
as `reference_image`). It turns away frames and references together, or more
than 9 references, with a 400 before MiniMax is asked. The duration is 5
unless set, raised to the model's shortest (4, or 5 for Max) and cut at 15.
The resolution is the request's own `resolution`, else derived from `size`'s
shorter side among the model's resolutions (H3 768P/2K, Highspeed 768P,
Lite and Max 768P/480P). The ratio is the nearest of MiniMax's to `size`.
None is sent with a frame, since the video takes the image's shape. Text
alone, and Lite's references, default to 16:9. No `callback_url` is ever
sent. Ids carry the key's mark (`markedKey`), as a custom provider's do,
and a key whose plan doesn't make H3 (codes 2061/2068/2057: a Token Plan
key) hands the video to the provider's next key. Failures are said for what
they are before MiniMax's own words (`minimaxWhy`, `minimaxError`): a bad
key (1004, 2049, 401), an empty pay-as-you-go balance (1008, 402), refused
content (1026, 1027), a plan without H3, and the rate limit (1002, 1045,
429). A failed task's `error.code` is explained the same way.
`AutoVideomaker` puts a MiniMax key after every other video maker: H3 is
paid by the second, so a subscription that made the videos before keeps
making them, and generate_video, which names no model, uses MiniMax-H3 only
when nothing else makes videos. Covered by `TestMiniMaxKeysMakeH3Videos`,
`TestMiniMaxVideoIsStartedPolledAndFetched`, `TestMiniMaxVideoBody`,
`TestMiniMaxVideoFailuresSayWhy`, `TestImageMCPMakesMiniMaxVideos`,
`TestMiniMaxComesAfterOtherVideomakers` and
`TestMiniMaxVideoMovesPastATokenPlanKey`.
## Turning provider search off
[Settings](../../internal/settings/settings.go)' `searcher: "off"` disables magpie's provider-assisted search,
@@ -915,6 +952,7 @@ vendor) and the other `TestTool*` tests.
Covered by `TestImageMCPDrawsAndServesTheImage`, `TestImageMCPSaysWhenOff`,
`TestImageMCPGuarded`, `TestImageMCPHeldToKeyLimit`,
`TestImageMCPSlowDrawingIsWaitedOn`, `TestImageMCPMakesVideos`,
`TestImageMCPMakesMiniMaxVideos`,
`TestImageMCPIsServed` and `image-mcp.test.cjs`.
## Side models magpie picks: allowance first