feat(minimax): add video generation actions - #225
Conversation
Add text_to_video, image_to_video, query_video_generation, and download_video actions to the MiniMax provider, covering the global and China hosts, the documented MiniMax-Hailuo-2.3 video models, required request fields, asynchronous task query, and generated file retrieval.
Summary by CodeRabbit
WalkthroughMiniMax now exposes text-to-video, image-to-video, task-status query, and video-download actions with schemas for asynchronous requests and responses. Credentials support global and China regions, and request helpers route through the selected API host. Video handlers use the regional context, while response handling maps MiniMax body-level errors. Tests cover validation, output typing, error mapping, regional routing, metadata, and invalid regions. Sequence Diagram(s)sequenceDiagram
participant ProviderAction
participant minimaxActionHandlers
participant minimaxRequestJson
participant MiniMaxAPI
ProviderAction->>minimaxActionHandlers: invoke video action
minimaxActionHandlers->>minimaxRequestJson: pass normalized request
minimaxRequestJson->>MiniMaxAPI: create task, query status, or download video
MiniMaxAPI-->>minimaxRequestJson: return response or body-level error
minimaxRequestJson-->>ProviderAction: return action result or mapped error
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/providers/minimax/actions.ts (1)
218-279: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winShared model enum doesn't restrict text-to-video vs. image-to-video model compatibility.
videoModelSchema(built from the singlevideoModelslist) is reused verbatim for bothtextToVideoInputSchemaandimageToVideoInputSchema. But per MiniMax's naming/documentation,T2V-01-Director/T2V-01are text-to-video-only andI2V-01-Director/I2V-01-live/I2V-01are image-to-video-only, andMiniMax-Hailuo-2.3-Fastis documented as image-to-video only (not available for text-to-video). With the shared enum, a client can requesttext_to_videowithI2V-01orMiniMax-Hailuo-2.3-Fast, orimage_to_videowithT2V-01, and the invalid combination will only surface as an opaque MiniMax error after task submission instead of being caught by the schema.Consider splitting into
textToVideoModels/imageToVideoModels(or two enums) so each input schema only accepts models valid for that mode.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/minimax/actions.ts` around lines 218 - 279, Split the shared videoModels/videoModelSchema definitions into mode-specific model lists and schemas. Update textToVideoInputSchema to accept only text-to-video models, and imageToVideoInputSchema to accept only image-to-video models, including MiniMax-Hailuo-2.3-Fast only for image-to-video. Keep the existing defaults and schema descriptions where applicable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/providers/minimax/actions.ts`:
- Around line 218-279: Split the shared videoModels/videoModelSchema definitions
into mode-specific model lists and schemas. Update textToVideoInputSchema to
accept only text-to-video models, and imageToVideoInputSchema to accept only
image-to-video models, including MiniMax-Hailuo-2.3-Fast only for
image-to-video. Keep the existing defaults and schema descriptions where
applicable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7699679e-703d-47df-b8a5-d7da37d7e782
📒 Files selected for processing (2)
src/providers/minimax/actions.tssrc/providers/minimax/executors.ts
|
这次把 MiniMax 的 region 收到 API key 连接配置里,校验和后续请求会统一走对应的 global/china host。同时补了 base_resp 的错误处理,拆分了文生视频和图生视频的模型范围,并收紧了 duration、resolution 以及 file_id 的 schema。相关回归测试也补上了,fix-check 和全量测试都已通过。 |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/providers/minimax/executors.ts (1)
72-95: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant region re-validation.
readMinimaxRegion(input.values.region)is called explicitly, then its result is fed intominimaxBaseUrlForRegion, which callsreadMinimaxRegionagain internally on the already-normalized value.createContext(Line 65) shows the simpler pattern of passing the raw value straight tominimaxBaseUrlForRegion.♻️ Proposed simplification
async apiKey(input, { fetcher, signal }) { - const region = readMinimaxRegion(input.values.region); - const apiBaseUrl = minimaxBaseUrlForRegion(region); + const apiBaseUrl = minimaxBaseUrlForRegion(input.values.region); const payload = await minimaxGetJson("/v1/models", {Also applies to: 173-186
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/minimax/executors.ts` around lines 72 - 95, Remove the explicit readMinimaxRegion call in credentialValidators.apiKey and pass input.values.region directly to minimaxBaseUrlForRegion, matching the pattern used by createContext. Apply the same simplification to the other affected region-handling block around the alternate referenced section.src/providers/minimax/actions.ts (1)
229-250: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueAlign
stringEnumcall shapes consistently
stringEnumintentionally supports both(values, options?)and(description, values)forms, so these resolution schemas are not malformed. Pick one call shape for consistency.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/minimax/actions.ts` around lines 229 - 250, Align the call shape of textToVideoResolutionSchema and imageToVideoResolutionSchema with the surrounding stringEnum schemas, using one consistent supported signature for both resolution definitions. Preserve their existing descriptions and allowed resolution values.src/providers/minimax/definition.ts (1)
18-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd a schema-level constraint for the MiniMax region value.
regionis accepted astextin the definition, whilereadMinimaxRegion()only allowsglobalorchinaand throws a 400 otherwise. Add an enum/validation constraint in the metadata/schema or normalize the value before constructing the API base URL so invalid regions fail during validation rather than at connect time.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/minimax/definition.ts` around lines 18 - 30, Add schema-level validation to the MiniMax extraFields region definition so only “global” and “china” are accepted, matching readMinimaxRegion(). Ensure invalid values are rejected during configuration validation before the API base URL is constructed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/providers/minimax/actions.ts`:
- Around line 229-250: Align the call shape of textToVideoResolutionSchema and
imageToVideoResolutionSchema with the surrounding stringEnum schemas, using one
consistent supported signature for both resolution definitions. Preserve their
existing descriptions and allowed resolution values.
In `@src/providers/minimax/definition.ts`:
- Around line 18-30: Add schema-level validation to the MiniMax extraFields
region definition so only “global” and “china” are accepted, matching
readMinimaxRegion(). Ensure invalid values are rejected during configuration
validation before the API base URL is constructed.
In `@src/providers/minimax/executors.ts`:
- Around line 72-95: Remove the explicit readMinimaxRegion call in
credentialValidators.apiKey and pass input.values.region directly to
minimaxBaseUrlForRegion, matching the pattern used by createContext. Apply the
same simplification to the other affected region-handling block around the
alternate referenced section.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b4fb12ea-a014-4bf4-85e1-1f6e80225f42
📒 Files selected for processing (4)
src/providers/minimax/actions.tssrc/providers/minimax/definition.tssrc/providers/minimax/executors.test.tssrc/providers/minimax/executors.ts
Reason: The MiniMax connector exposed only model listing, model retrieval, text Responses, and token estimation, so it could not generate video.
This extends the existing
minimaxprovider with asynchronous video generation actions:text_to_videoandimage_to_videocreatePOST /v1/video_generationtasks.text_to_videorequiresmodelandprompt;image_to_videorequiresmodelandfirst_frame_image. Both accept the optionalprompt_optimizer,fast_pretreatment,duration,resolution, andcallback_urlrequest fields.query_video_generationpolls task progress viaGET /v1/query/video_generationand surfacestask_id,status, andfile_id.download_videoretrieves the generated file metadata and its download URL viaGET /v1/files/retrieve.modelfield is an enum that defaults toMiniMax-Hailuo-2.3and covers the documented video models.regionfield selects the global (https://api.minimax.io) or China (https://api.minimaxi.com) host; the existing text actions keep using the global host. All requests continue to go through the shared SSRF-guarded fetcher.Checks:
npm run fix-check(oxlint + oxfmt +srctypecheck)npm run generate:catalognpm test(vitest, 554 tests passing)