In ai_utils.py the gemini model is called with
response_modalities=['TEXT', 'IMAGE']
This allows the model to also only return text.
Current implementation assumes an image will always be present, resulting in:
RuntimeError: No image generated by the model.
This causes failures any time the model decides not to output an image.
Possible solutions:
- Force the model to produce an image or
- Provide a clear error message instructing the user to refine the
prompt
- Gracefully return text-only responses
Option A — Force the model to output images only
Change:
response_modalities=['TEXT', 'IMAGE']
to:
response_modalities=['IMAGE']
Option B — Add a helpful error message when no image is returned
Replace:
raise RuntimeError("No image generated by the model.")
with something like:
raise RuntimeError(
"The model returned no image. Try improving your prompt with more explicit visual instructions, or include a style reference image to guide output."
)
In ai_utils.py the gemini model is called with
response_modalities=['TEXT', 'IMAGE']
This allows the model to also only return text.
Current implementation assumes an image will always be present, resulting in:
This causes failures any time the model decides not to output an image.
Possible solutions:
prompt
Option A — Force the model to output images only
Change:
to:
Option B — Add a helpful error message when no image is returned
Replace:
with something like: