Chat-to-image/Edit nano-banana
Overview
- Method:
POST - Path:
/v1/chat/completions
Authentication
- Use HTTP Bearer Token, e.g.:
Authorization: Bearer sk-xxxxx
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model selection: nano-banana / gemini-2.5-flash-image etc. |
| messages | array | Yes | Array of role messages, supports text and image_url |
| stream | boolean | No | Stream output or not |
Request Example
json
{
"model": "nano-banana",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "Draw a colorful artwork, theme optional."}
]
}
]
}Response Example
json
{
"id": "abc123",
"model": "nano-banana",
"object": "chat.completion",
"created": 1725000000,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": [{"type": "text", "text": "Generation completed"}]
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 30,
"prompt_tokens_details": {"text_tokens": 7, "image_tokens": 3},
"completion_tokens_details": {"image_tokens": 20}
}
}