Using Nano-Banana through Chat Completions API
You can generate images (also known as Nano-Banana) through LLM format by using the gemini-2.5-flash-image-preview
model.
Please note that in this usage scenario, you MUST use streaming mode.
Example
curl https://api.mulerun.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Your API Token>" \
-d '{
"model": "gemini-2.5-flash-image-preview",
"stream": true,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Create a picture of mule"
}
]
}
]
}'
You will receive the following response:
data: {
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": [
{
"image_url": {
"url": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIA..."
},
"type": "image_url"
}
]
},
"finish_reason": "STOP"
}
],
"usage": {
"completion_tokens": 1290,
"prompt_tokens": 6,
"total_tokens": 1296
}
}
data: {
"id": "",
"object": "chat.completion.chunk",
"created": 0,
"model": "gemini-2.5-flash-image-preview",
"system_fingerprint": "",
"choices": [],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 0,
"total_tokens": 13,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 0,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null
}
}
data: [DONE]
In the url
field of image_url
, you’ll get the Base64 encoded image data.