Skip to content

Your lightweight open-source personal agent.

Fix image mime detection for MiniMax

Haisam Abbase6587a8d8e37
diff --git a/tests/providers/test_image_generation.py b/tests/providers/test_image_generation.py
index 3bee376d8..eea3a3fe6 100644
--- a/tests/providers/test_image_generation.py
+++ b/tests/providers/test_image_generation.py
@@ -390,6 +390,17 @@ async def test_minimax_payload_and_response_with_reference_image(tmp_path: Path)
assert body["subject_reference"][0]["image_file"].startswith("data:image/png;base64,")
+async def test_minimax_base64_response_uses_detected_mime() -> None:
+ raw_b64 = base64.b64encode(JPEG_BYTES).decode("ascii")
+ fake = FakeClient(FakeResponse({"data": {"image_base64": [raw_b64]}}))
+ client = MiniMaxImageGenerationClient(api_key="sk-mm-test", client=fake) # type: ignore[arg-type]
+
+ response = await client.generate(prompt="draw", model="image-01")
+
+ assert response.images == [f"data:image/jpeg;base64,{raw_b64}"]
+
+
# ---------------------------------------------------------------------------
# StepFun (阶跃星辰)
# ---------------------------------------------------------------------------