feat(image-gen): add MiniMax image-01 backend plugin - #25451
Conversation
Adds a new image generation backend for MiniMax's image-01 model via https://api.minimax.io/v1/image_generation. - Implements ImageGenProvider with full setup schema, model catalog, and aspect ratio mapping (all 9 MiniMax-native ratios supported) - Downloads generated image from returned URL and caches locally under HERMES_HOME/cache/images/; falls back to raw URL on download failure - Requires MINIMAX_API_KEY; integrates with hermes tools picker - Consistent with existing openai/xai plugin patterns (uses requests, same error_response/success_response conventions) Select via: image_gen.provider: minimax in config.yaml
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new MiniMax-based image generation backend plugin to the image_gen system.
Changes:
- Introduces
minimaxplugin metadata (plugin.yaml) including required env var. - Implements
MiniMaxImageProviderwith model selection and API calls to MiniMax’simage_generationendpoint. - Adds optional image downloading/caching behavior after receiving a generated image URL.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| plugins/image_gen/minimax/plugin.yaml | Declares the new minimax backend plugin and required env configuration. |
| plugins/image_gen/minimax/init.py | Implements the MiniMax image generation provider, config resolution, API request/response handling, and registration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| resp = requests.post( | ||
| API_ENDPOINT, | ||
| json=payload, | ||
| headers={"Authorization": f"Bearer {api_key}"}, | ||
| timeout=120, | ||
| ) | ||
| resp.raise_for_status() | ||
| data = resp.json() | ||
| except requests.RequestException as exc: |
| # MiniMax natively supports these aspect ratios | ||
| _ASPECT_RATIOS = {"1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "21:9"} |
| # Fall back to 1:1 for any ratio not natively supported | ||
| mm_ratio = aspect_ratio if aspect_ratio in _ASPECT_RATIOS else "1:1" |
| image=image_path, | ||
| model=model, | ||
| prompt=prompt, | ||
| aspect_ratio=aspect_ratio, |
| # Download and cache the image locally | ||
| try: | ||
| img_resp = requests.get(image_urls[0], timeout=60) | ||
| img_resp.raise_for_status() | ||
| import base64 | ||
| b64 = base64.b64encode(img_resp.content).decode() | ||
| saved = save_b64_image(b64, prefix="minimax", extension="png") | ||
| image_path = str(saved) |
|
|
||
| import logging | ||
| import os | ||
| from typing import Any, Dict, List, Optional, Tuple |
- Remove unused Optional and Tuple imports; add urllib.parse.urlparse - Catch ValueError (JSONDecodeError) around resp.json() separately from RequestException, returning a clean error_response instead of raising - Return mm_ratio (the ratio actually sent to the API) in all success_response and error_response calls, not the original aspect_ratio which may have been silently remapped to 1:1 - Add SSRF guard: validate image URL is HTTPS and host matches an explicit MiniMax-controlled allowlist before issuing requests.get; fall back to returning the raw URL and log a warning on mismatch
…F allowlist
- subject_reference: character-consistent generation from a portrait URL
or base64 data URL. Passes subject_reference=[{type:character,image_file}]
to the MiniMax image_generation API when provided via kwargs.
- prompt_optimizer: forward prompt_optimizer=True to API when caller requests it.
- SSRF allowlist: add two additional MiniMax image CDN hosts seen in production
(aliyuncs accelerate + minimax-algeng) so generated images cache locally.
- Expose subject_reference in image_generate tool schema so the agent can use
character-consistent generation without manual API wiring.
- Pass **extra_kwargs through _dispatch_to_plugin_provider so future providers
can receive additional parameters.
|
Thanks for the MiniMax image-generation implementation and for following the existing This automated hermes-sweeper review is closing the PR under the standing third-party provider-integration policy: vendor-specific integrations must ship as standalone plugins, not as new in-tree directories under
Please publish or continue this work as a standalone MiniMax image-generation plugin repository, then share it in Automated hermes-sweeper review; closed as not planned under standing policy Closed as not-planned per standing maintainer policy ( |
Summary
Adds a new image generation backend plugin for MiniMax's
image-01model.MiniMax is already a fully-supported LLM provider in Hermes, but had no image generation support. This fills the gap using the same plugin architecture as the existing
openai,openai-codex, andxaibackends.What this adds
plugins/image_gen/minimax/__init__.py— fullImageGenProviderimplementationPOST https://api.minimax.io/v1/image_generation1:1,16:9,9:16,4:3,3:4,3:2,2:3,21:9HERMES_HOME/cache/images/; falls back to raw URL on download failureget_setup_schema()forhermes toolspicker integrationimage_gen.minimax.model(orMINIMAX_IMAGE_MODELenv var)plugins/image_gen/minimax/plugin.yaml— manifest following existing plugin conventionsUsage
Requires
MINIMAX_API_KEYin~/.hermes/.env.Notes
plugins/image_gen/xai/andplugins/image_gen/openai/requests(consistent with other plugins, noturllib)1002rate limit,1004auth,1008balance,1026content policy)