Task: Figure out why not all image models are available in openrouter
Figure out why not all image models are available in openrouter
Some models work normally, for example google/gemini-2.5-flash-image, google/gemini-3.1-flash-image-preview, while some models return 404, for example black-forest-labs/flux.2-klein-4b, black-forest-labs/flux.2-pro, black-forest-labs/flux.2-max
Ворклоги
As it turned out, the problem was with this parameter:
modalities: ['image', 'text']
And here I see some really crappy behavior from the openrouter API. What was the issue? Some models actually support both image and text, while others support only image or only text. And OpenRouter has a method to fetch models filtered by a specific modality.
curl "https://openrouter.ai/api/v1/models?output_modalities=image"
However, the catch is that they don't have a method to get models that support both. That means we can't figure out with a single request whether a model supports all the modalities we need. Moreover, we can't see all models in the sh curl "https://openrouter.ai/api/v1/models" request without specifying a modality. For example, here we can see Flux:
curl "https://openrouter.ai/api/v1/models?output_modalities=image" |jq|grep black -A 15
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 39411 0 39411 0 0 172k 0 --:--:-- --:--:-- --:--:-- 171k
"id": "black-forest-labs/flux.2-klein-4b",
"canonical_slug": "black-forest-labs/flux.2-klein-4b",
"hugging_face_id": "black-forest-labs/FLUX.2-klein-4B",
"name": "Black Forest Labs: FLUX.2 Klein 4B",
"created": 1768429228,
"description": "FLUX.2 [klein] 4B is the fastest and most cost-effective model in the FLUX.2 family, optimized for high-throughput use cases while maintaining excellent image quality. Pricing is based on the output...",
"context_length": 40960,
"architecture": {
"modality": "text+image->image",
"input_modalities": [
"text",
"image"
],
"output_modalities": [
"image"
],
"tokenizer": "Other",
"instruct_type": null
--
"details": "/api/v1/models/black-forest-labs/flux.2-klein-4b/endpoints"
}
},
But we won't see it in the general list of models.
curl "https://openrouter.ai/api/v1/models" |jq|grep black -A 15
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 488k 0 488k 0 0 1496k 0 --:--:-- --:--:-- --:--:-- 1498k
But that's not all :-) If you specify only modalities: ['image'] in the request, models like gemini-2.5/3 return an error: "No endpoints found that support the requested output modalities: image", even though the model itself specifies
"architecture": {
"modality": "text+image->text+image",
"input_modalities": [
"image",
"text"
],
"output_modalities": [
"image",
"text"
],
"tokenizer": "Gemini",
"instruct_type": null
}
In other words, it doesn't just pick one of the possibilities; instead, all of them must match. This feels really strange to me. I end up having to not specify modalities at all.