Refresh minimax_video to the official MiniMax API (direct global/CN endpoints, Hailuo 2.3 contract) - #452
Conversation
Route minimax_video through the first-party MiniMax video API with MINIMAX_API_KEY (Bearer auth) instead of the gateway path. Add global/CN region selection (MINIMAX_REGION, optional MINIMAX_BASE_URL), the current model slugs (Hailuo 2.3 family plus prior generations), and the direct request/response contract: POST /v1/video_generation, poll GET /v1/query/video_generation, then GET /v1/files/retrieve and download. Update .env.example and docs/PROVIDERS.md for the direct key, and add a contract test that mocks requests via monkeypatch.setattr so the shared requests module stays intact for the rest of the suite.
0xDevNinja
left a comment
There was a problem hiding this comment.
Thanks for moving minimax onto the first-party API — the get_status fix (declaring env:MINIMAX_API_KEY instead of gating on FAL_KEY) and the redacted-key error path are both real improvements, and the text_to_video flow looks good end to end.
One merge blocker on the image_to_video path when minimax is reached through video_selector:
The schema swap renames the reference input from image_url to first_frame_image and drops image_url entirely, but video_selector only knows how to bridge a shared reference image into image_url:
# tools/video/video_selector.py (unchanged by this PR)
if adapted.get("operation") == "image_to_video" and adapted.get("reference_image_path"):
tool_props = getattr(tool, "input_schema", {}).get("properties", {})
if "image_url" in tool_props and "image_url" not in adapted: # <- never true for minimax now
adapted["image_url"] = upload_image_fal(adapted["reference_image_path"])minimax still advertises supports["image_to_video"] = True, so the candidate filter (supports.get("image_to_video") or "image_url" in props or "reference_image_url" in props) keeps selecting it for image_to_video. But nothing in video_selector.py or tools/video/_shared.py maps any shared input to first_frame_image — I grepped both, no references. So a selector-routed image_to_video request (e.g. preferred_provider=minimax with reference_image_path) reaches execute() with first_frame_image unset and hard-fails:
image_to_video requires 'first_frame_image'.
This worked before the PR: the old image_url prop was populated by the selector's upload_image_fal bridge. So it's a regression in the selector→provider contract for image_to_video, not just a rename. It's surfaced (not silent) and fallback tools are returned, but the provider can no longer serve image_to_video via the selector.
Two ways to close it:
- teach the selector to populate
first_frame_imagefor providers whose schema exposes it (parallel to the existingimage_urlbranch), or - accept
reference_image_url/image_urlas an alias in minimax and map it tofirst_frame_imageinsideexecute().
Either one plus a selector→minimax image_to_video test would make this mergeable. text_to_video itself is fine — this is scoped to the image_to_video route.
Reason: Refresh
minimax_videoto the first-party MiniMax video API with direct global and CN endpoints and the current Hailuo 2.3 request/response contract.minimax_videopreviously routed through a third-party gateway with gateway credentials and gateway-specific model slugs, so it lacked the direct MiniMax endpoints and the current first-party request/response contract. This refreshes the tool to call the official MiniMax video API directly.Changes
tools/video/minimax_video.pyMINIMAX_API_KEYwithAuthorization: Bearer <key>(was gateway credentials).MINIMAX_REGION=global(default,https://api.minimax.io) orcn(https://api.minimaxi.com), with an optionalMINIMAX_BASE_URLoverride.MiniMax-Hailuo-2.3,MiniMax-Hailuo-2.3-Fast,MiniMax-Hailuo-02, and theT2V-01/I2V-01families), defaultMiniMax-Hailuo-2.3.POST /v1/video_generation→ pollGET /v1/query/video_generation→GET /v1/files/retrieve→ download the returned URL. Request fields:model,prompt,first_frame_image(image-to-video),prompt_optimizer,fast_pretreatment,duration,resolution,callback_url. Errors surfacebase_resp.status_code/status_msg, with API-key redaction in error messages..env.exampleanddocs/PROVIDERS.md: documentMINIMAX_API_KEY/MINIMAX_REGION/MINIMAX_BASE_URLand moveminimax_videofrom the gateway entries to a dedicated direct-API section.tests/tools/test_minimax_video.py: new contract test covering registry discovery, availability, region routing, the text-to-video direct-API request/response flow, the image-to-video first-frame requirement, andbase_resperror surfacing. HTTP is mocked withmonkeypatch.setattron the liverequestsmodule so the sharedrequestsimport stays intact for the rest of the suite.Checks
python -m pytest tests/tools/test_minimax_video.py -v— 6 passedpython -m pytest tests/contracts/test_jimeng_video.py tests/tools/test_provider_model_defaults.py tests/tools/test_video_selector_routing.py -q— 76 passed (no regressions)python -m py_compile tools/base_tool.py tools/tool_registry.py tools/video/minimax_video.py tests/tools/test_minimax_video.py