fix(api): allow text-to-image on dual-modality models + revive HuggingFace image host#7648
fix(api): allow text-to-image on dual-modality models + revive HuggingFace image host#7648danscMax wants to merge 1 commit into
Conversation
…gFace image host Two image-generation regressions surfaced while testing /v1/images/generations: 1. Dual-modality models (inputModalities ["text","image"]) were rejected with "Image input is required" because the gate treated any "image" modality as mandatory. That blocked pure text-to-image on 41 models (Together x10, Stability x10, LMArena x15, NVIDIA x3, BFL x2, NanoGPT x1). Only edit-only models (modalities ["image"] with no "text") should require an image input; extract modalitiesRequireImageInput() and gate on that. 2. The HuggingFace image provider pointed at api-inference.huggingface.co, which HF retired (DNS-dead -> "fetch failed" 502). Route through router.huggingface.co/hf-inference/models, matching the chat provider which already migrated. Regression guard: tests/unit/image-text-to-image-modality.test.ts (fails on base -- the helper did not exist and the baseUrl was the retired host).
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Thanks for tracking this down and including a live-tested regression guard — the dual-modality gate fix (BFL Kontext / Together / NVIDIA / LMArena / NanoGPT) and the HuggingFace host migration both check out, and I confirmed the new test runs correctly in One thing surfaced while cross-checking the registry: the same Could you carve those 10 out of the reclassification (keep |
Problem
Two independent defects break
/v1/images/generations, both found while testing image generation end-to-end against a live instance.1. Dual-modality models can't do text-to-image
The gate classified any model whose
inputModalitiesinclude"image"as requiring an image input:But in the registry,
["text", "image"]means the model accepts an image (edit-capable) — it can still run pure text-to-image. Treating that as mandatory rejected legitimate text-to-image with400 "Image input is required for image model: ...".41 models were blocked: Together ×10, Stability ×10, LMArena ×15, NVIDIA ×3, Black Forest Labs ×2, NanoGPT ×1. Only edit-only models (
["image"], no"text") should require an image.Fix: extract
modalitiesRequireImageInput()and gate onincludes("image") && !includes("text").2. HuggingFace image provider points at a retired host
The image registry used
https://api-inference.huggingface.co/models, which HuggingFace has retired — it no longer resolves (fetch failed→502 Image provider error). The chat provider already migrated torouter.huggingface.co; the image entry was left behind.Fix:
https://router.huggingface.co/hf-inference/models. Verified live — both/hf-inference/models/{model}and the old host were probed: old host → connection failure (HTTP 000), new host →401(reachable, awaits auth). This revives 3 free models (FLUX.1-dev, FLUX.1-schnell, SDXL) on already-connected HF accounts.Test
tests/unit/image-text-to-image-modality.test.ts— fails on base (the helper did not exist and thebaseUrlwas the retired host), passes with the fix. Asserts:modalitiesRequireImageInputclassifies edit-only / dual / text-only / nullish correctly["text","image"]registry model is gated as image-requiredbaseUrlis the live router host, and${baseUrl}/${model}yields the router URLnpm run typecheck:coreclean;eslintclean on changed files; existingimage-registry-gpt56.test.tsstill passes.Scope
Surgical — only the modality gate and the HF host. Not touched (flagged for follow-up): wiring
gemini/imageninto the image registry via the:predictAPI, and the Gemini free-tierlimit: 0cooldown classification.