Add MiniMax image generation provider (text-to-image and image-to-image) - #118
Conversation
Wire a direct MiniMax image-generation endpoint adapter alongside the existing direct OpenAI Responses and Atlas Cloud paths. The adapter calls POST /v1/image_generation with a Bearer API key, supports image-01 / image-01-live, maps attached reference images to the subject_reference field for image-to-image, and parses both url and base64 response formats. Region selects the global (api.minimax.io/v1) or China (api.minimaxi.com/v1) base URL. The minimax lane is registered through providerOptions, the model catalog, capabilities, key management, the classic/multimode/node/edit/agent pipelines, and the CLI lane resolver. Web search, reasoning, mask, and video controls are ignored on this provider; image-to-image supports at most one subject reference. Adds minimax model validation, runtime-context key fields, env/config wiring, a provider contract test, and updates the affected lane/provider contract tests.
|
Thanks for this — the MiniMax provider is now on I couldn't merge this branch as-is, so I fixed the blockers on top of your work rather than sending it back. What changed: Key validation was billing the user. Sending Validation was fail-open. Only The model was being swapped silently. With a reference attached, a user's The web UI had no MiniMax at all. Also fixed: timeouts were misclassified as network failures ( Closing this since the work landed in #120. Appreciate the contribution. |
MiniMax provider(lidge-jun#118)를 받기 전에 고쳐야 할 결함들이다. 키 검증이 실제로 이미지를 생성했다. `{model, prompt}`만 보내면 나머지가 기본값으로 채워져서 정상 생성 요청이 되고, 키를 저장하거나 바꿀 때마다 이미지 한 장 값이 나간다. 결과는 그대로 버려진다. MiniMax가 OpenAI 호환 `GET /v1/models`를 제공하므로 다른 provider와 같은 방식으로 바꿨다. 무효 키에 401/1004가 오는 것을 global·CN 양쪽에서 확인했다. 검증 URL도 region을 따라가게 했다 — 전에는 중국 리전 설정에서도 global 호스트를 때렸다. 판정도 뒤집었다. 예전엔 401/1004/2049만 거부해서 403·429·500이나 깨진 JSON이 오면 잘못된 키를 그냥 저장했다. 이제 문서화된 목록 형태를 확인했을 때만 통과시킨다. MiniMax는 200 안에 오류를 담아 보내기도 해서 `base_resp.status_code`까지 본다. reference를 붙이면 사용자가 고른 image-01을 image-01-live로 몰래 바꿔 보내면서 히스토리에는 원래 모델을 적었다. 공식 문서상 image-01도 subject_reference를 지원하니 바꿀 이유가 없다. 대신 global 리전에서 image-01-live를 참조 없이 쓰는 조합은 공식 허용 범위 밖이라 로컬에서 막고, 무엇을 하면 되는지 알려준다. 그 밖에: - `AbortSignal.timeout()`은 TimeoutError를 던지는데 AbortError만 보고 있어서 타임아웃이 네트워크 실패(502)로 새어 나갔다. 504로 잡는다. - 안전 차단 카운터를 숫자로만 읽어서, 공식 응답처럼 문자열로 오면 차단을 upstream 장애로 잘못 보고했다. - 결과 다운로드에 크기 제한이 없었다. grok 쪽 선례대로 50MB 스트리밍 상한을 두고, content-type을 믿는 대신 매직 바이트로 실제 이미지인지 확인한다. 인라인 base64 경로도 같은 검사를 거친다 — downstream이 미상 MIME을 PNG로 저장하기 때문에 HTML 오류 페이지가 깨진 .png로 남을 수 있었다. 검증: 어댑터 계약 19건, 키 검증 route 8건 통과. 가드를 되돌리는 ablation에서 해당 케이스만 실패하는 것을 확인했다.
Reason: Add the MiniMax image-generation provider (text-to-image and image-to-image) to the direct endpoint adapter layer.
Changes
lib/minimaxImageAdapter.tscallsPOST /v1/image_generationwith a Bearer API key.image-01(text-to-image) andimage-01-live(image-to-image).subject_referencefield (character subject, data URL).--sizeis mapped to the closest supportedaspect_ratio(1:1, 16:9, 4:3, 3:2, 2:3, 3:4, 9:16, 21:9);autodefers to the API default.urlandbase64response formats are parsed into a single base64 payload.https://api.minimax.io/v1) or China (https://api.minimaxi.com/v1) base URL.base_resp.status_codeis mapped to app error codes (auth, rate limit, balance, safety, bad request).lib/providerOptions.tsresolves theminimaxprovider and validates the model vianormalizeMinimaxImageModel(added tolib/imageModels.ts). Web search, reasoning, and size controls are disabled.routes/models.tsexposes aminimaxlane (image-01/image-01-live,key-missinguntil configured).lib/capabilities.ts,lib/agentSettings.ts, andbin/lib/modelResolver.tsregisterminimaxin their provider/lane lists.routes/keys.tsacceptsMINIMAX_API_KEY(env or config) with status, validation, hot-update, and removal.lib/runtimeContext.tsandserver.tsload and exposeminimaxApiKey.config.ts/config.jsadd aminimaxProviderblock (region, global/CN base URLs, default model, timeout).generateViaMinimax, including thejpegformat group, image-to-image reference handling, and a 1-subject-reference cap (MINIMAX_REF_TOO_MANY) plusMINIMAX_MASK_UNSUPPORTED.routes/auth.tsredactsMINIMAX_API_KEY(andATLASCLOUD_API_KEY) from the codex child env.gen/edit/multimode/node) anddocs/CLI.mdlist theminimaxlane.tests/minimax-provider-contract.test.tscovers provider options, key-missing, text-to-image wire shape, subject_reference mapping, CN routing, ref cap, and safety/auth error mapping.tests/models-endpoint-contract.test.ts,tests/cli-model-resolver.test.ts,tests/cli-capabilities-contract.test.js,tests/cli-feature-parity-contract.test.js, and the runtime test inventory for the new lane.Checks
tsc --noEmit -p tsconfig.json(server/lib/routes) — passtsc --noEmit -p tsconfig.bin.json(bin) — passnode --test tests/minimax-provider-contract.test.ts— pass (9 tests)node --testfor models-endpoint, cli-model-resolver, cli-feature-parity, cli-capabilities, atlascloud, gemini-api, image-model, generation-errors, reference-limits, generate route, agent-mode-llm-planner — passnode scripts/classify-tests.mjs --check(test inventory) — pass