Skip to content

Refresh minimax_video to the official MiniMax API (direct global/CN endpoints, Hailuo 2.3 contract) - #452

Open
octo-patch wants to merge 1 commit into
calesthio:mainfrom
octo-patch:octo/20260729-parameter-refresh-recvq8UIW6357f
Open

Refresh minimax_video to the official MiniMax API (direct global/CN endpoints, Hailuo 2.3 contract)#452
octo-patch wants to merge 1 commit into
calesthio:mainfrom
octo-patch:octo/20260729-parameter-refresh-recvq8UIW6357f

Conversation

@octo-patch

Copy link
Copy Markdown

Reason: Refresh minimax_video to the first-party MiniMax video API with direct global and CN endpoints and the current Hailuo 2.3 request/response contract.

minimax_video previously 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.py
    • Auth via MINIMAX_API_KEY with Authorization: Bearer <key> (was gateway credentials).
    • Region selection: MINIMAX_REGION=global (default, https://api.minimax.io) or cn (https://api.minimaxi.com), with an optional MINIMAX_BASE_URL override.
    • Current model slugs (MiniMax-Hailuo-2.3, MiniMax-Hailuo-2.3-Fast, MiniMax-Hailuo-02, and the T2V-01/I2V-01 families), default MiniMax-Hailuo-2.3.
    • Direct request/response contract: POST /v1/video_generation → poll GET /v1/query/video_generationGET /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 surface base_resp.status_code/status_msg, with API-key redaction in error messages.
    • Idempotency key now covers the output-affecting fields (model, operation, first_frame_image, prompt_optimizer, fast_pretreatment, duration, resolution).
  • .env.example and docs/PROVIDERS.md: document MINIMAX_API_KEY / MINIMAX_REGION / MINIMAX_BASE_URL and move minimax_video from 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, and base_resp error surfacing. HTTP is mocked with monkeypatch.setattr on the live requests module so the shared requests import stays intact for the rest of the suite.

Checks

  • python -m pytest tests/tools/test_minimax_video.py -v — 6 passed
  • python -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

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.
@octo-patch
octo-patch requested a review from calesthio as a code owner July 29, 2026 11:21

@0xDevNinja 0xDevNinja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_image for providers whose schema exposes it (parallel to the existing image_url branch), or
  • accept reference_image_url / image_url as an alias in minimax and map it to first_frame_image inside execute().

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.

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.

2 participants