diff --git a/CLAUDE.md b/CLAUDE.md index 97e947b..28116f2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -140,7 +140,7 @@ prefixes determine routing: - **Moonshot AI** (Kimi API, OpenAI-compatible, api.moonshot.ai): kimi-k3.1-pro - **NEAR AI** (NEAR AI Cloud, OpenAI-compatible, cloud-api.near.ai): deepseek-v4.1-flash-abliterated - **Z.ai** (Model API, OpenAI-compatible): image generation: glm-image (glm-5.2 chat is routed through BytePlus ModelArk, see ByteDance above) -- **WaveSpeed** (async prediction API): image generation: krea-3 (Krea's model, always `berry` at `reasoning_level: medium`), qwen-image-3.0-pro (Alibaba's model); each is two WaveSpeed endpoints, text-to-image and edit +- **WaveSpeed** (async prediction API): image generation: minimax-h3-image (MiniMax's model), krea-3 (Krea's model, always `berry` at `reasoning_level: medium`), qwen-image-3.0-pro (Alibaba's model); each is two WaveSpeed endpoints, text-to-image and edit Models kept registered but no longer offered to new clients — each still resolves so older SDK versions keep working, and each is priced at what the @@ -192,10 +192,11 @@ means the default tier, and the field is rejected on single-resolution models. Seedream 5.0 (`1.5K` at $0.045 is the default; `2K` at $0.09 is what every request used to be pinned to), Krea 3 (`1K` $0.03 default, `2K` $0.12, each reference billed at the same price as the output, per WaveSpeed's -`$0.03 x MP x (1 + references)` formula) and Qwen Image 3.0 Pro (`1K` $0.04 default, -`2K` $0.075) are the tiered models today. +`$0.03 x MP x (1 + references)` formula), Qwen Image 3.0 Pro (`1K` $0.04 default, +`2K` $0.075) and MiniMax H3 Image (`1K` $0.03, `2K` $0.03 default, `4K` $0.09) +are the tiered models today. -**WaveSpeed** (krea-3, qwen-image-3.0-pro) is the one image provider that does not +**WaveSpeed** (minimax-h3-image, krea-3, qwen-image-3.0-pro) is the one image provider that does not answer in a single call. `image_generation._generate_wavespeed` submits an async prediction to `/{model_id}` — the `…/text-to-image` model, or the `…/edit` model (`image_edit_model`) when the turn carries references — then @@ -206,13 +207,13 @@ prediction so WaveSpeed's history no longer holds the prompt or output. WaveSpeed takes references as URLs only: inline `data:` references are uploaded through its `/media/uploads` ticket (a keyless PUT to the signed URL, which is a credential and is never logged), plain URLs are passed -through, and at most `image_max_references` (Qwen 3, Krea 8) are sent. Its +through, and at most `image_max_references` (Qwen 3, Krea 8, MiniMax 10) are sent. Its input images are billed too — `per_reference_image_price_usd` (Qwen $0.003 -each; Krea per tier, at the output's price) on top of the per-image price, +each; MiniMax $0.008; Krea per tier, at the output's price) on top of the per-image price, counted from the references actually forwarded. One image per prediction; `n` is ignored. Every Qwen request sends `enable_prompt_expansion: false`, and -every Krea request `model: berry` + `reasoning_level: medium` -(`image_extra_params`). +every Krea request `model: berry` + `reasoning_level: medium`, and every +MiniMax request `output_format: png` (`image_extra_params`). ### Web Search diff --git a/README.md b/README.md index 8415da8..1d3a363 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ The gateway solves this by running inside a hardware-isolated Nitro Enclave wher | Moonshot AI | kimi-k3.1-pro | | NEAR AI | deepseek-v4.1-flash-abliterated | -Image generation: krea-3 and qwen-image-3.0-pro (via WaveSpeed), gpt-image-2, +Image generation: minimax-h3-image, krea-3 and qwen-image-3.0-pro (via WaveSpeed), gpt-image-2, gpt-image-2.6-flare, gpt-image-2.6-sunburst, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gemini-2.5-flash-image, gemini-nano-banana-2.1, gemini-3.1-flash-image, grok-2-image, grok-imagine-image-2.0, seedream-4.0, seedream-5.0-lite, seedance-4.5, seedance-5.0, glm-image. @@ -71,7 +71,7 @@ export ZAI_API_KEY=... # Z.ai Model API export ABLITERATION_API_KEY=... # abliteration.ai export MOONSHOT_API_KEY=... # Moonshot AI (Kimi) export NEARAI_API_KEY=... # NEAR AI Cloud -export WAVESPEED_API_KEY=... # WaveSpeed (krea-3, qwen-image-3.0-pro) +export WAVESPEED_API_KEY=... # WaveSpeed (minimax-h3-image, krea-3, qwen-image-3.0-pro) # Run server (starts the Flask/connexion app on port 8000) make test-local # Werkzeug dev server (development only) diff --git a/tee_gateway/model_registry.py b/tee_gateway/model_registry.py index b6cad30..e39d131 100644 --- a/tee_gateway/model_registry.py +++ b/tee_gateway/model_registry.py @@ -296,6 +296,9 @@ def image_tier(self, resolution: Optional[str]) -> Optional[ImageResolutionTier] "21:9", ) } +# MiniMax H3 Image on WaveSpeed (text-to-image and edit) takes the same +# fifteen ratios, passed through unchanged. +_WAVESPEED_MINIMAX_H3_ASPECT_RATIOS = _WAVESPEED_QWEN_IMAGE_ASPECT_RATIOS # WaveSpeed's Krea 3 takes explicit ``width*height`` sizes (multiples of 16) # and bills by them: $0.03 per started megapixel (1,048,576 px) of output, and @@ -1360,6 +1363,48 @@ class SupportedModel(Enum): }, image_default_resolution="1K", ) + # MiniMax H3 Image — served through WaveSpeed's `minimax/h3-image` + # endpoints. Two endpoints, text-to-image and edit (1-16 reference images; the gateway forwards at + # most 10). Priced from WaveSpeed's model pages: $0.03 per image at 1k or + # 2k, $0.09 at 4k, plus $0.008 per input image on edits at any tier. + # WaveSpeed's `resolution` field is what it bills by, so it is exposed as + # resolution tiers; omitted means 2K, which costs the same as 1K. Output + # is lossless PNG (also WaveSpeed's default). No seed or prompt rewriting + # field is exposed on these endpoints. + MINIMAX_H3_IMAGE = ModelConfig( + provider="wavespeed", + api_name="minimax/h3-image/text-to-image", + input_price_usd=Decimal("0"), + output_price_usd=Decimal("0"), + image_generation=True, + per_image_price_usd=Decimal("0.03"), + image_response_format=None, + image_send_n=False, + image_supports_reference=True, + image_edit_model="minimax/h3-image/edit", + image_max_references=10, + per_reference_image_price_usd=Decimal("0.008"), + image_extra_params={"output_format": "png"}, + image_aspect_ratios=_WAVESPEED_MINIMAX_H3_ASPECT_RATIOS, + image_resolutions={ + "1K": ImageResolutionTier( + per_image_price_usd=Decimal("0.03"), + aspect_ratios=_WAVESPEED_MINIMAX_H3_ASPECT_RATIOS, + extra_params={"resolution": "1k"}, + ), + "2K": ImageResolutionTier( + per_image_price_usd=Decimal("0.03"), + aspect_ratios=_WAVESPEED_MINIMAX_H3_ASPECT_RATIOS, + extra_params={"resolution": "2k"}, + ), + "4K": ImageResolutionTier( + per_image_price_usd=Decimal("0.09"), + aspect_ratios=_WAVESPEED_MINIMAX_H3_ASPECT_RATIOS, + extra_params={"resolution": "4k"}, + ), + }, + image_default_resolution="2K", + ) # ── Legacy models (not in current SDK — retained for older SDK versions) ── # grok-3 was retired on 2026-05-15 alongside the slugs above and is @@ -1544,6 +1589,11 @@ class SupportedModel(Enum): "qwen-image-3-pro": SupportedModel.QWEN_IMAGE_3_0_PRO, "alibaba/qwen-image-3.0-pro": SupportedModel.QWEN_IMAGE_3_0_PRO, "alibaba/qwen-image-3.0-pro/text-to-image": SupportedModel.QWEN_IMAGE_3_0_PRO, + "minimax-h3-image": SupportedModel.MINIMAX_H3_IMAGE, + "minimax-h3": SupportedModel.MINIMAX_H3_IMAGE, + "minimax/minimax-h3-image": SupportedModel.MINIMAX_H3_IMAGE, + "minimax/h3-image": SupportedModel.MINIMAX_H3_IMAGE, + "minimax/h3-image/text-to-image": SupportedModel.MINIMAX_H3_IMAGE, # Legacy — not in current SDK, retained for older SDK versions "grok-3-mini-beta": SupportedModel.GROK_3_MINI, # old beta alias "grok-3-mini": SupportedModel.GROK_3_MINI, diff --git a/tee_gateway/test/test_image_generation.py b/tee_gateway/test/test_image_generation.py index f21aac0..42ec7c2 100644 --- a/tee_gateway/test/test_image_generation.py +++ b/tee_gateway/test/test_image_generation.py @@ -35,6 +35,7 @@ GPT_IMAGE = "gpt-image-2" QWEN_IMAGE = "qwen-image-3.0-pro" KREA_3 = "krea-3" +MINIMAX_H3 = "minimax-h3-image" def _mock_response(data: list[dict]) -> MagicMock: @@ -610,6 +611,53 @@ def test_krea_3_ratio_and_tier_select_the_size(self): self.assertEqual(body["size"], size) self.assertNotIn("aspect_ratio", body) + def test_minimax_h3_defaults_to_2k_png_on_minimax_endpoint(self): + client = _WaveSpeedClient([_ws_prediction("completed", outputs=[_WS_OUTPUT])]) + with patch.object(llm_backend, "wavespeed_http_client", client): + generate_images(MINIMAX_H3, "a lighthouse at dusk", aspect_ratio="2:3") + path, body = client.submitted() + self.assertEqual(path, "/minimax/h3-image/text-to-image") + self.assertEqual( + body, + { + "prompt": "a lighthouse at dusk", + "output_format": "png", + "resolution": "2k", + "aspect_ratio": "2:3", + }, + ) + + def test_minimax_h3_resolution_tier_is_sent(self): + for tier, sent in (("1K", "1k"), ("2K", "2k"), ("4K", "4k")): + with self.subTest(tier=tier): + client = _WaveSpeedClient( + [_ws_prediction("completed", outputs=[_WS_OUTPUT])] + ) + with patch.object(llm_backend, "wavespeed_http_client", client): + generate_images(MINIMAX_H3, "p", resolution=tier) + _, body = client.submitted() + self.assertEqual(body["resolution"], sent) + + def test_minimax_h3_edit_uses_the_edit_model(self): + client = _WaveSpeedClient([_ws_prediction("completed", outputs=[_WS_OUTPUT])]) + with patch.object(llm_backend, "wavespeed_http_client", client): + generate_images( + MINIMAX_H3, "p", reference_images=["https://example.com/photo.jpg"] + ) + path, body = client.submitted() + self.assertEqual(path, "/minimax/h3-image/edit") + self.assertEqual(body["images"], ["https://example.com/photo.jpg"]) + self.assertEqual(body["resolution"], "2k") + # No ratio picked: WaveSpeed derives it from the references. + self.assertNotIn("aspect_ratio", body) + + def test_minimax_h3_rejects_an_unknown_resolution(self): + client = _WaveSpeedClient([]) + with patch.object(llm_backend, "wavespeed_http_client", client): + with self.assertRaisesRegex(ValueError, "Unsupported resolution"): + generate_images(MINIMAX_H3, "p", resolution="8K") + self.assertEqual(client.posts, []) + def test_krea_3_edit_uses_the_edit_model_and_keeps_framing(self): client = _WaveSpeedClient([_ws_prediction("completed", outputs=[_WS_OUTPUT])]) with patch.object(llm_backend, "wavespeed_http_client", client): @@ -1344,6 +1392,7 @@ def test_single_image_charged_flat_price(self): GPT_IMAGE, QWEN_IMAGE, KREA_3, + MINIMAX_H3, ): with self.subTest(model=model): cfg = get_model_config(model) @@ -1412,6 +1461,22 @@ def test_krea_3_references_are_billed_at_the_tier_output_price(self): cost = compute_session_cost(KREA_3, usage, image_count=1, **kwargs) self.assertEqual(cost.cost_usd, expected) + def test_minimax_h3_reference_images_are_billed(self): + # WaveSpeed: $0.03 at 1k/2k, $0.09 at 4k, plus $0.008 per input image. + usage = self._zero_usage() + cases = [ + ({}, Decimal("0.03")), + ({"resolution": "1K"}, Decimal("0.03")), + ({"resolution": "4K"}, Decimal("0.09")), + ({"reference_count": 1}, Decimal("0.038")), + ({"reference_count": 10}, Decimal("0.11")), + ({"resolution": "4K", "reference_count": 2}, Decimal("0.106")), + ] + for kwargs, expected in cases: + with self.subTest(**kwargs): + cost = compute_session_cost(MINIMAX_H3, usage, image_count=1, **kwargs) + self.assertEqual(cost.cost_usd, expected) + def test_reference_images_free_on_models_without_a_reference_price(self): usage = self._zero_usage() cost = compute_session_cost(SEEDREAM, usage, image_count=1, reference_count=3) diff --git a/tests/test_pricing.py b/tests/test_pricing.py index ecbb9f5..b6078d4 100644 --- a/tests/test_pricing.py +++ b/tests/test_pricing.py @@ -834,6 +834,44 @@ def test_qwen_image_3_0_pro_aliases_resolve(self): get_model_config(alias), get_model_config("qwen-image-3.0-pro") ) + def test_minimax_h3_image_resolves(self): + cfg = get_model_config("minimax-h3-image") + self.assertEqual(cfg.provider, "wavespeed") + self.assertEqual(cfg.api_name, "minimax/h3-image/text-to-image") + self.assertEqual(cfg.image_edit_model, "minimax/h3-image/edit") + self.assertTrue(cfg.image_generation) + # WaveSpeed's model pages: $0.03 per image at 1k/2k, $0.09 at 4k, + # $0.008 per input image on edits at any tier. + self.assertEqual(cfg.per_image_price_usd, Decimal("0.03")) + self.assertEqual(cfg.per_reference_image_price_usd, Decimal("0.008")) + self.assertEqual(cfg.image_default_resolution, "2K") + self.assertEqual( + { + k: (t.per_image_price_usd, dict(t.extra_params)) + for k, t in cfg.image_resolutions.items() + }, + { + "1K": (Decimal("0.03"), {"resolution": "1k"}), + "2K": (Decimal("0.03"), {"resolution": "2k"}), + "4K": (Decimal("0.09"), {"resolution": "4k"}), + }, + ) + self.assertEqual(dict(cfg.image_extra_params), {"output_format": "png"}) + self.assertEqual(cfg.image_max_references, 10) + + def test_minimax_h3_image_aliases_resolve(self): + for alias in ( + "minimax-h3", + "minimax/minimax-h3-image", + "minimax/h3-image", + "minimax/h3-image/text-to-image", + "MiniMax-H3-Image", + ): + with self.subTest(alias=alias): + self.assertEqual( + get_model_config(alias), get_model_config("minimax-h3-image") + ) + def test_krea_3_resolves(self): cfg = get_model_config("krea-3") self.assertEqual(cfg.provider, "wavespeed")