Skip to content

feat(python-sdk): add MiniMax video provider routing#783

Open
octo-patch wants to merge 2 commits into
Agent-Field:mainfrom
octo-patch:octo/20260709-add-minimax-video-support-recvoRQXkrgaiU
Open

feat(python-sdk): add MiniMax video provider routing#783
octo-patch wants to merge 2 commits into
Agent-Field:mainfrom
octo-patch:octo/20260709-add-minimax-video-support-recvoRQXkrgaiU

Conversation

@octo-patch

Copy link
Copy Markdown

Summary

Adds a direct MiniMax video provider to the Python SDK media router. The provider submits asynchronous generation tasks, polls their status, retrieves the generated file URL, and supports configurable global and China API bases while leaving existing video defaults unchanged.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs only
  • Tests only
  • CI / tooling
  • Breaking change

Test plan

  • sdk/python/.venv/bin/ruff check sdk/python
  • sdk/python/.venv/bin/pytest -c sdk/python/pyproject.toml sdk/python/tests

Test coverage

  • I ran tests for the Python SDK locally.
  • New request, routing, validation, and error paths are covered by tests.
  • No coverage baseline changes were needed.
  • The coverage gate check is green in CI before requesting review.

Checklist

  • I have read docs/CONTRIBUTING.md and docs/DEVELOPMENT.md.
  • Commits are signed and follow conventional-commits style.
  • I have linked any related issues.

Related issues / PRs

@octo-patch
octo-patch requested review from a team and AbirAbbas as code owners July 16, 2026 07:05
@CLAassistant

CLAassistant commented Jul 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

Performance

SDK Memory Δ Latency Δ Tests Status
Python 9.5 KB +6% 0.32 µs -9%

✓ No regressions detected

@github-actions

Copy link
Copy Markdown
Contributor

📊 Coverage gate

Thresholds from .coverage-gate.toml: per-surface ≥ 84%, aggregate ≥ 85%, max per-surface regression ≤ 1.0 pp, max aggregate regression ≤ 0.50 pp.

Surface Current Baseline Δ
control-plane 86.80% 87.40% ↓ -0.60 pp 🟡
sdk-go 92.50% 92.00% ↑ +0.50 pp 🟢
sdk-python 93.82% 93.73% ↑ +0.09 pp 🟢
sdk-typescript 90.47% 90.42% ↑ +0.05 pp 🟢
web-ui 84.75% 84.79% ↓ -0.04 pp 🟡
aggregate 85.51% 85.75% ↓ -0.24 pp 🟡

✅ Gate passed

No surface regressed past the allowed threshold and the aggregate stayed above the floor.

@github-actions

Copy link
Copy Markdown
Contributor

📐 Patch coverage gate

Threshold: 80% on lines this PR touches vs origin/main (from .coverage-gate.toml:thresholds.min_patch).

Surface Touched lines Patch coverage Status
control-plane 0 ➖ no changes
sdk-go 0 ➖ no changes
sdk-python 0 ➖ no changes
sdk-typescript 0 ➖ no changes
web-ui 0 ➖ no changes

✅ Patch gate passed

Every surface whose lines were touched by this PR has patch coverage at or above the threshold.

@AbirAbbas AbirAbbas 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 the contribution — the provider implementation and test coverage of the submit/poll/retrieve flow look solid. Ran this through PR-AF (our review agent) and hand-verified its findings against the diff; nothing blocking, but four items worth addressing inline below. Separately: the CLA check is still unsigned, which will block merge regardless.

model="minimax/video-model",
poll_interval=0,
)
assert error_session.calls[0][1] == f"{MINIMAX_GLOBAL_BASE_URL}/video_generation"

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.

This assertion makes the test environment-sensitive: the provider is constructed at line 131 without an explicit base_url, and MiniMaxProvider.__init__ falls back to os.environ["MINIMAX_BASE_URL"] before MINIMAX_GLOBAL_BASE_URL (media_providers.py lines 665-667). Since the README tells users to export exactly that variable, the test fails on any machine/CI where it's set.

Suggest isolating it at the top of the test:

monkeypatch.delenv("MINIMAX_BASE_URL", raising=False)

(or pass base_url=MINIMAX_GLOBAL_BASE_URL explicitly at line 131).

if extra:
body.update(extra)
if kwargs:
body.update(kwargs)

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.

These two body.update(...) calls run after the validated fields are set, so extra or stray kwargs can silently overwrite model, prompt, duration, or resolution — e.g. extra={"duration": 3.5} bypasses the whole-number check at lines 767-770, and extra={"resolution": "1080p"} skips the .upper() normalization.

Consider guarding reserved keys before merging:

reserved = body.keys() & {**(extra or {}), **kwargs}.keys()
if reserved:
    raise ValueError(f"extra/kwargs may not override: {sorted(reserved)}")

(or document that extra intentionally wins, and merge it before validation so the checks still apply).

status_code = base_resp.get("status_code")
if status_code not in (None, 0):
status_msg = base_resp.get("status_msg") or "unknown error"
raise RuntimeError(

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.

Non-blocking consistency note: MiniMax wraps all API failures in bare RuntimeError (here, in _read_response, and the missing-task_id case), plus ValueError for validation and TimeoutError for polling — while FalProvider lets native client exceptions propagate. Callers of ai_generate_video end up needing provider-specific error handling.

Worth considering a shared typed exception for media-provider failures (or matching Fal's propagation behavior) so errors are catchable uniformly across providers.

Comment thread sdk/python/README.md
export MINIMAX_VIDEO_MODEL="..."
```

The global API base is used by default. Set `MINIMAX_BASE_URL` to select a region:

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.

Worth a one-liner on precedence here: AIConfig(minimax_base_url=...) silently overrides MINIMAX_BASE_URL (agent_ai.py passes the config value as base_url, which wins in the provider's base_url or env or default chain — same for minimax_api_key vs MINIMAX_API_KEY). As written, a reader would expect the env var to take effect when both are set.

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.

4 participants