Задача Разобраться почему не все image-модели в openrouter доступны
Разобраться почему не все image-модели в openrouter доступны
Часть моделей нормально работает, например google/gemini-2.5-flash-image, google/gemini-3.1-flash-image-preview, а часть моделей отдает 404, например black-forest-labs/flux.2-klein-4b, black-forest-labs/flux.2-pro, black-forest-labs/flux.2-max
Ворклоги
Как оказалось, проблема вот в этом параметре была:
modalities: ['image', 'text']
И тут я усматриваю очень паршивое поведение openrouter-api. В чем была проблема? Некоторые модели действительно поддерживают и image и text, а какие-то только image или только text. И у openrouter есть метод для полечения моделей с учетом конкретной модалити.
curl "https://openrouter.ai/api/v1/models?output_modalities=image"
Но, прикол в том, что у них нет метода для получения моделей, которые поддерживают и то и другое. То есть мы не можем одним запросом выяснить поддерживает ли модель все необходимые нам модалити. Более того, мы не все модели можем увидеть в запросе sh curl "https://openrouter.ai/api/v1/models"
без указания модалити. К примеру, вот мы видим флюкс
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"
}
},
Но мы не увидим ее в общем списке моделей.
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
Но и это еще не все :-) Если в запросе указать только modalities: ['image'], то модели типа gemini-2.5/3 ошибку возвращают "No endpoints found that support the requested output modalities: image", хотя в самой модели указано
"architecture": {
"modality": "text+image->text+image",
"input_modalities": [
"image",
"text"
],
"output_modalities": [
"image",
"text"
],
"tokenizer": "Gemini",
"instruct_type": null
}
То есть берется не одно из возможных, а именно все должны совпадать. Это прям странно для меня. Приходится вообще не указывать модалити.