Native Gemini
Gemini image generation endpoint.
Request Conventions
| Item | Value |
|---|---|
| Base URL | https://token.wdcloud.ai |
| Authentication header | Authorization: Bearer <API_KEY> |
Endpoint
POST /v1beta/models/{model}:generateContent
Parameters
| Field | Type | Required | Example | Description |
|---|---|---|---|---|
model | string | Yes | gemini-3-pro-image | Gemini image model; supports gemini-*-image and its preview/generation variants |
contents | array | Yes | [{"role":"user","parts":[...]}] | Conversation content array |
contents[].role | string | No | user | Message role, usually user or model |
contents[].parts | array | Yes | [{"text":"Generate a movie poster"}] | Message parts; text and images can be combined |
contents[].parts[].text | string | No | Generate a movie poster | Text prompt |
contents[].parts[].inlineData | object | No | {"mimeType":"image/png","data":"..."} | Inline image input, commonly used for image-to-image generation |
contents[].parts[].inlineData.mimeType | string | Yes | image/png | Image MIME type, such as image/png or image/jpeg |
contents[].parts[].inlineData.data | string | Yes | iVBORw0KGgo... | Base64-encoded image data |
contents[].parts[].fileData | object | No | {"mimeType":"image/png","fileUri":"..."} | File reference input; availability depends on the selected channel and upstream capabilities |
generationConfig | object | No | {"responseModalities":["TEXT","IMAGE"]} | Generation settings |
generationConfig.responseModalities | array | No | ["TEXT","IMAGE"] | Response modalities. ["TEXT","IMAGE"] is recommended for image generation |
generationConfig.imageConfig | object | No | {"aspectRatio":"16:9","imageSize":"2K"} | Image generation settings |
generationConfig.imageConfig.aspectRatio | string | No | 16:9 | Output aspect ratio. Common values: 1:1, 3:2, 2:3, 4:3, 3:4, 16:9 |
generationConfig.imageConfig.imageSize | string | No | 2K | Output size tier. Available values: 1K, 2K, 4K |
Request Examples
Text to Image
bash
curl -X POST "https://token.wdcloud.ai/v1beta/models/gemini-2.0-flash-exp:generateContent" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{ "role": "user", "parts": [{ "text": "Generate a city skyline at sunrise." }] }
],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {
"aspectRatio": "1:1",
"imageSize": "1024x1024"
}
}
}'Image to Image: Image URL
bash
curl -X POST "https://token.wdcloud.ai/v1beta/models/nano-banana-pro:generateContent" \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Replace the city skyline background with a blue sky and white clouds, then add a central park."
},
{
"fileData": {
"mimeType": "image/png",
"fileUri": "https://img.wdcloud.ai/images/2026/08/27/b986d080-6d96-442d-a864-45b0a27009a4.png"
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "1:1",
"imageSize": "4K"
}
}
}'Image to Image: Base64 Image
bash
curl -X POST "https://token.wdcloud.ai/v1beta/models/gemini-3-pro-image:generateContent" \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Replace the city skyline background with a blue sky and white clouds, then add a central park."
},
{
"inlineData": {
"mimeType": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUg..."
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "1:1",
"imageSize": "4K"
}
}
}'Response Example
json
{
"candidates": [
{
"content": {
"parts": [
{
"text": "The image has been generated."
},
{
"inlineData": {
"mimeType": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUg..."
}
}
],
"role": "model"
}
}
],
"usageMetadata": {
"promptTokenCount": 11,
"candidatesTokenCount": 7,
"totalTokenCount": 18
}
}