Nano Banana โ
Nano Banana is an image generation model that supports text-to-image and reference-image editing. It is called synchronously via the TokenHub path, and the result is returned directly in the response body.
Basic Information โ
| Item | Value |
|---|---|
| model | custom-model-gn-v3.1 |
| Supported version | custom-model-gn-v3.1 / custom-model-gn-v3.1-lite / custom-model-gn-v3.0 / custom-model-gn-v2.5 |
| Default value | model=custom-model-gn-v3.1 / responseFormat=url |
| Supported operations | Text โ image generation, image editing |
| Output size | 1K / 2K / 4K |
| Supported aspect ratio | 16:9 / 1:1 / 4:3 / 3:4 / 9:16 |
| Return format | url / b64_json |
| Guardrail release support | Not supported |
Endpoint โ
| Item | Value |
|---|---|
| HTTP method | POST |
| Request domain | https://tokenhub.tencentcloudmaas.com |
| Image generation and editing | /v1/wand/gn-image/generation |
| Authentication | Authorization: Bearer <API_KEY> |
| Result return | Synchronous. The generation result is included in the response body |
Region-specific Access Addresses
The address above is based on Guangzhou. For region-specific addresses and backup addresses such as Singapore and Silicon Valley, refer to the API usage guide.
Prerequisites โ
- The TokenHub service must be activated and a API Key must have been issued. For the procedure, refer to the TokenHub Quick Start.
Input Parameters โ
| Parameter | Required | Type | Description |
|---|---|---|---|
model | Required | String | custom-model-gn-v3.1 / custom-model-gn-v3.1-lite / custom-model-gn-v3.0 / custom-model-gn-v2.5 |
contents | Required | Array | Content array consisting of role and parts |
contents.role | Optional | String | Message role. user |
contents.parts | Required | Array | Item array consisting of text or inlineData |
contents.parts.text | Required | String | Generation prompt |
contents.parts.inlineData | Optional | Object | Input image. Used only for image editing |
contents.parts.inlineData.mimeType | Optional | String | Input image type. image/png / image/jpeg |
contents.parts.inlineData.data | Optional | String | Input image. An accessible URL or a Base64 string |
generationConfig | Optional | Object | Generation settings |
generationConfig.responseModalities | Optional | Array | Return modality. ["IMAGE"] |
generationConfig.responseFormat | Optional | Object | Image output settings |
generationConfig.responseFormat.image.aspectRatio | Optional | String | 16:9 / 1:1 / 4:3 / 3:4 / 9:16 |
generationConfig.responseFormat.image.imageSize | Optional | String | 1K / 2K / 4K |
responseFormat | Optional | String | Return image format. url / b64_json. Default value url |
logoAdd | Optional | Integer | Whether to add a watermark. 1 adds it, 0 does not. Default value 0 |
Output Parameters โ
| Parameter | Type | Description |
|---|---|---|
candidates | Array | Generation result array |
candidates.content.parts.inlineData.data | String | Generated image. URL or Base64 depending on responseFormat |
candidates.content.parts.inlineData.mimeType | String | Generated image type |
candidates.finishReason | String | Reason for termination. STOP on normal completion |
candidates.index | Integer | Result sequence number |
modelVersion | String | Model version actually used for generation |
responseId | String | Response ID |
tokenhub_usage.total_tokens | Integer | Number of tokens used |
request_id | String | ID used to verify the request |
Request Example โ
bash
curl --location 'https://tokenhub.tencentcloudmaas.com/v1/wand/gn-image/generation' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
-d '{
"model": "custom-model-gn-v3.1",
"contents": [
{
"parts": [
{
"text": "Dancing"
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"responseFormat": {
"image": {
"aspectRatio": "9:16",
"imageSize": "2K"
}
}
}
}'Response Example โ
json
{
"candidates": [
{
"content": {
"parts": [
{
"inlineData": {
"data": "https://xxxxxx.jpg",
"mimeType": "image/jpeg"
},
"thoughtSignature": ""
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}
],
"modelVersion": "gemini-3.1-flash-image",
"responseId": "uXd8arrMAeu-_uMP7v-g4Ag",
"tokenhub_usage": {
"total_tokens": 394260
},
"request_id": "5f0b3bf8-3ea8-46b5-b8af-529dabbc25af"
}Image Editing โ
Adding inlineData to contents.parts makes it an edit that references the input image. The request body structure and the response structure are the same as for generation.
Input Parameters โ
| Parameter | Required | Type | Description |
|---|---|---|---|
contents.parts.inlineData | Required | Object | Input image |
contents.parts.inlineData.mimeType | Required | String | Input image type. image/png / image/jpeg |
contents.parts.inlineData.data | Required | String | Input image. An accessible URL or a Base64 string |
Generation and Editing Use the Same Endpoint
Text generation and image editing use the same endpoint. In an edit request, pass the reference image through inlineData.
Request Example โ
bash
curl --location 'https://tokenhub.tencentcloudmaas.com/v1/wand/gn-image/generation' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
-d '{
"model": "custom-model-gn-v3.1",
"contents": [
{
"parts": [
{
"text": "Dancing"
},
{
"inlineData": {
"mimeType": "image/png",
"data": "https://xxxxxxxxx.png"
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"responseFormat": {
"image": {
"aspectRatio": "9:16",
"imageSize": "2K"
}
}
}
}'Response Example โ
json
{
"candidates": [
{
"content": {
"parts": [
{
"inlineData": {
"data": "https://xxxxxx.jpg",
"mimeType": "image/jpeg"
},
"thoughtSignature": ""
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}
],
"modelVersion": "gemini-3.1-flash-image",
"responseId": "kT2pQmR7bvN-_yWL4w-h9De",
"tokenhub_usage": {
"total_tokens": 412870
},
"request_id": "a7c31e90-6d52-4f18-9b03-72e5cd14f8ba"
}