Skip to content

feat(image-gen): add MiniMax image-01 backend plugin - #25451

Closed
ayushere wants to merge 5 commits into
NousResearch:mainfrom
ayushere:feat/image-gen-minimax
Closed

feat(image-gen): add MiniMax image-01 backend plugin#25451
ayushere wants to merge 5 commits into
NousResearch:mainfrom
ayushere:feat/image-gen-minimax

Conversation

@ayushere

Copy link
Copy Markdown
Contributor

Summary

Adds a new image generation backend plugin for MiniMax's image-01 model.

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, and xai backends.

What this adds

  • plugins/image_gen/minimax/__init__.py — full ImageGenProvider implementation
    • Calls POST https://api.minimax.io/v1/image_generation
    • Supports all 9 MiniMax-native aspect ratios: 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9
    • Downloads generated image from returned URL and caches locally under HERMES_HOME/cache/images/; falls back to raw URL on download failure
    • Implements get_setup_schema() for hermes tools picker integration
    • Model catalog entry with speed/strengths/price metadata
    • Config key: image_gen.minimax.model (or MINIMAX_IMAGE_MODEL env var)
  • plugins/image_gen/minimax/plugin.yaml — manifest following existing plugin conventions

Usage

# config.yaml
image_gen:
  provider: minimax
  model: image-01

Requires MINIMAX_API_KEY in ~/.hermes/.env.

Notes

  • Follows the same patterns as plugins/image_gen/xai/ and plugins/image_gen/openai/
  • Uses requests (consistent with other plugins, not urllib)
  • Error handling covers: missing API key, network errors, MiniMax error codes (1002 rate limit, 1004 auth, 1008 balance, 1026 content policy)
  • MiniMax Token Plan users get quota-based image generation (50–200 images/day depending on tier)

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
Copilot AI review requested due to automatic review settings May 14, 2026 05:28

Copilot AI 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.

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 minimax plugin metadata (plugin.yaml) including required env var.
  • Implements MiniMaxImageProvider with model selection and API calls to MiniMax’s image_generation endpoint.
  • 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.

Comment on lines +131 to +140
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:
Comment on lines +45 to +46
# MiniMax natively supports these aspect ratios
_ASPECT_RATIOS = {"1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "21:9"}
Comment on lines +120 to +121
# Fall back to 1:1 for any ratio not natively supported
mm_ratio = aspect_ratio if aspect_ratio in _ASPECT_RATIOS else "1:1"
Comment thread plugins/image_gen/minimax/__init__.py Outdated
image=image_path,
model=model,
prompt=prompt,
aspect_ratio=aspect_ratio,
Comment thread plugins/image_gen/minimax/__init__.py Outdated
Comment on lines +169 to +176
# 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)
Comment thread plugins/image_gen/minimax/__init__.py Outdated

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
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/vision Vision analysis and image generation labels May 14, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #10389 — MiniMax image generation plugin. See also competing PRs #11067 and the broader provider-native approach in #9954.

ayushere added 3 commits May 14, 2026 12:45
…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.
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the MiniMax image-generation implementation and for following the existing ImageGenProvider shape.

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 plugins/.

  • This PR adds the MiniMax-specific backend at plugins/image_gen/minimax/__init__.py and its bundled manifest at plugins/image_gen/minimax/plugin.yaml (PR head 50abc004f8c3).
  • Hermes already supports the intended extension path: image providers register through ImageGenProvider / ctx.register_image_gen_provider(...), and user-installed backends live at ~/.hermes/plugins/image_gen/<name>/ or are distributed through pip entry points (website/docs/developer-guide/image-gen-provider-plugin.md:17-25).
  • The prior discussion is useful context: @alt-glitch linked the competing MiniMax implementations Adding Minimax support for image generation #10389 and [verified] feat: prefer MiniMax for image generation #11067; both were resolved under this same maintenance-boundary policy.

Please publish or continue this work as a standalone MiniMax image-generation plugin repository, then share it in #plugins-skills-and-skins.


Automated hermes-sweeper review; closed as not planned under standing policy in-tree-provider-integration. This is a maintenance-boundary decision, not a judgment of the implementation's quality.


Closed as not-planned per standing maintainer policy (in-tree-provider-integration). This is a design-direction decision, not a code-quality judgment — see the Contribution Rubric in AGENTS.md for what the project is looking for. If you believe this policy was misapplied to your change, comment here and a maintainer will take a look.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) tool/vision Vision analysis and image generation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants