Repository navigation
feat(ai): add MiniMax image generation - #59929
Conversation
There was a problem hiding this comment.
Looks sound. I ran the new MiniMax image tests, the recorded cassettes, the export and entrypoint tests and the existing MiniMax tests (all pass), plus typecheck:tsc in packages/ai and packages/core. I also drove the minimax/images entrypoint against a local mock server: image-01-live sent the expected aspect_ratio/response_format/seed body with Bearer auth to {baseURL}/image_generation, and 16:9 at 2K failed with the closest-preset error. The structure matches the Alibaba and Z.ai image providers. No concerns.
Public API, all backwards compatible:
- adds
MiniMax.configure().image(modelID, providerOptions?)andMiniMax.image - adds
MiniMax.imageModeland theMiniMaxImageOptionstype - adds the
@opencode/ai/providers/minimax/imagespackage export, also registered as a built-in in core MiniMax.modelonly got an internal refactor; its signature and behaviour are unchanged.
There was a problem hiding this comment.
The new commit looks good, and my earlier review left nothing open. The China host (api.minimax.cn/v1) now matches the minimax-cn base URLs in the models.dev snapshot. Dropping 21:9 for image-01-live behaves as intended: against a local mock, a 21:9 request on image-01-live fails with a closest-size error naming 16:9, and image-01 still sends aspect_ratio: "21:9". The MiniMax image tests and typecheck:tsc in packages/ai pass. The public API is unchanged from the previous review: new MiniMax.image/imageModel and the @opencode/ai/providers/minimax/images export, all backwards compatible.
There was a problem hiding this comment.
The new commit looks good, and my earlier reviews left nothing open. The base64 default is sent unless responseFormat (or a native response_format) overrides it. The new unit test covers this, and the recorded cassettes still pass now that they rely on the default. MiniMax image tests and typecheck:tsc in packages/ai pass. The public API is otherwise unchanged from my earlier reviews: this adds MiniMax.image/imageModel and the @opencode/ai/providers/minimax/images export, all backwards compatible. The only difference is that the new responseFormat option now defaults to base64.
I added an image route for MiniMax, so
image-01andimage-01-livecan be used through@opencode/ai. Before this the MiniMax provider only had chat, messages and responses.Change
providers/minimax.ts configure() messages / chat / responses + image(modelID) -> protocols/minimax-images.ts +providers/minimax/images.ts # `model` entrypoint for models.dev core/src/provider.ts + "@opencode/ai/providers/minimax/images"It posts to
POST {baseURL}/image_generation(defaulthttps://api.minimax.io/v1;baseURL: "https://api.minimax.cn/v1"for the China platform) with Bearer auth fromMINIMAX_API_KEY.How the shared fields map:
It asks for
response_format: "base64"by default so the bytes come back inline.responseFormat: "url"still works if you want the 24h links.promptOptimizer,seedand any other native field pass through. Nativeaspect_ratio/width/heighttogether with sharedaspect/resolutionfails, same as OpenAI'ssize. MiniMax returns errors as HTTP 200 withbase_resp.status_code. Those now map to typed errors: 1002 rate limit, 1004/2049 auth, 1008 quota, 1026 content policy, 2013 invalid request.Out of scope
models.dev doesn't list any MiniMax image models yet, so opencode won't offer them until it does. The catalog needs
image-01/image-01-livewithtype: "image"underminimax/minimax-cn, with an API entry whose opencode package is@opencode/ai/providers/minimax/images. I opened that as anomalyco/models.dev#11860.Verification
bun typecheckandbun run typecheck:tscinpackages/ai,bun typecheckinpackages/corebun run testinpackages/ai: 1955 pass, 0 fail. That includes new unit tests for request building, sizing, the closest-size errors and status code mappingRECORD=true, about $0.01): text to image at 512x512 and a subject reference generation. The returned dimensions are assertedInvalidRequest (2013)and a bad key asAuthentication (1004).image-01-liverejectswidth/heightandaspect_ratio: "21:9", which is why it only gets the other presetsbun run script/test.ts test/provider.test.ts test/aisdk-native.test.ts test/variant.test.tsinpackages/coreVisual
Added by the opencode bot (AI-generated).
Public API: adds MiniMax image generation (
MiniMax.image,imageModel, the@opencode/ai/providers/minimax/imagesexport); backwards compatible