Image Generation
gemini-3-pro-image-preview Image Generation API
Designed for professional-grade image assets, complex instructions, multi-turn editing, text rendering, and high-resolution output.
Authorization
BearerAuth
Model relay interface recognition. Request heading: Autoration: Bearer .
In: header
Path Parameters
Gemini model name.
"gemini-3-pro-image-preview"Request Body
application/json
Enter an array of content to carry one or more rounds of messages between users, models or tools. Each element is a Content object, usually consisting of __ FD_PROTECT_0 __ and __ FD_PROTECT_1 __: __ FD_PROTECT_2 __, commonly known as _ FD_PROTECT_3 __, _ FD_PROTECT_4 __, single-cycle user_9 _ with _ FD_PROTECT_10, _ FD_PROTECT_11 __, _ FD_PROTECT_12 __, _ FD_PRT_13 _ _ _ _ _ _FCED_14 Applies to scenarios such as text conversations, image/audio/video/document understanding, function calls and multimodular generation. The number of arrays and media sizes are based on upstream model and operational configuration limits.
Gemini system command.
Generates configurations such as temperature, TopK, TopP, maximum output length.
Security policy settings. List of safetySettings. Scope: An array length is based on upstream or business configuration.
Gemini tool definition. . Scope: The length of arrays and the complexity of schema are based on upstream limits.
Response Body
application/json
curl -X POST "https://api.tokaify.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \ -H "Content-Type: application/json" \ -d '{ "contents": [ { "parts": [ { "text": "Writing a four-word Chinese short poem on the theme of urban night rain." } ] } ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 100000 } }'{
"candidates": [],
"usageMetadata": {},
"modelVersion": "string"
}Request Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
contents | array | Yes | None | Gemini content array supporting text and input images. |
contents[].parts[].text | string | Yes | None | Generation prompt. For complex tasks, describe the aspect ratio, text, layout, materials, and constraints. |
contents[].parts[].inline_data | object | No | None | Input reference image containing mime_type and Base64 data. |
generationConfig.responseModalities | string[] | No | ["TEXT","IMAGE"] | Returned modalities. For image generation, ["IMAGE"] or ["TEXT","IMAGE"] is recommended. |
generationConfig.imageConfig.aspectRatio | string | No | 1:1 | Supports 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, and 21:9. |
generationConfig.imageConfig.imageSize | string | No | 1K | Output size tier. Supports up to 4K; exact available values depend on the provider channel. |
generationConfig.candidateCount | integer | No | 1 | Candidate count. Keeping this at 1 is recommended to reduce latency and cost. |
safetySettings | array | No | None | Gemini safety settings. |
Example Code
curl "https://api.tokaify.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
-H "Authorization: Bearer $TOKAIFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{ "role": "user", "parts": [{ "text": "Generate a 4K product poster titled Tokaify API with a dark tech aesthetic and crisp text." }] }],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": { "aspectRatio": "16:9", "imageSize": "4K" }
}
}'import requests
response = requests.post(
"https://api.tokaify.com/v1beta/models/gemini-3-pro-image-preview:generateContent",
headers={"Authorization": "Bearer YOUR_TOKAIFY_API_KEY"},
json={
"contents": [{"role": "user", "parts": [{"text": "Generate a 4K product poster titled Tokaify API with a dark tech aesthetic and crisp text."}]}],
"generationConfig": {"responseModalities": ["IMAGE"], "imageConfig": {"aspectRatio": "16:9", "imageSize": "4K"}},
},
)
print(response.json())const response = await fetch("https://api.tokaify.com/v1beta/models/gemini-3-pro-image-preview:generateContent", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.TOKAIFY_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
contents: [{ role: "user", parts: [{ text: "Generate a 4K product poster titled Tokaify API with a dark tech aesthetic and crisp text." }] }],
generationConfig: { responseModalities: ["IMAGE"], imageConfig: { aspectRatio: "16:9", imageSize: "4K" } },
}),
});
console.log(await response.json());Response Example
{
"candidates": [
{
"content": {
"role": "model",
"parts": [{ "inlineData": { "mimeType": "image/png", "data": "iVBORw0KGgoAAAANSUhEUg..." } }]
},
"finishReason": "STOP"
}
],
"usageMetadata": { "promptTokenCount": 48, "candidatesTokenCount": 4096, "totalTokenCount": 4144 }
}Notes
Billing follows the configured model and channel ratios. High resolution significantly increases latency and usage, and preview models may change in availability, so production deployments should configure a fallback model.
How is this guide?
Last updated on