Tokaify APITokaify API
API Reference
AI Model APIImagesGemini APIgemini-2.5-flash-image

Image Editing

gemini-2-5-flash-image Image Editing API

Gemini image editing is handled through multimodal input in generateContent: place the text instruction in parts[].text and the source image in parts[].inline_data.

POST
/v1beta/models/{model}:generateContent

Authorization

BearerAuth

AuthorizationBearer <token>

Model relay interface recognition. Request heading: Autoration: Bearer .

In: header

Path Parameters

model*string

Gemini model name.

Default"gemini-2.5-flash-image"

Request Body

application/json

contents?

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.

systemInstruction?object

Gemini system command.

generationConfig?

Generates configurations such as temperature, TopK, TopP, maximum output length.

safetySettings?

Security policy settings. List of safetySettings. Scope: An array length is based on upstream or business configuration.

tools?

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-2.5-flash-image: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

FieldTypeRequiredDefaultDescription
contentsarrayYesNoneGemini content array.
contents[].parts[].textstringYesNoneEdit instruction.
contents[].parts[].inline_data.mime_typestringYesNoneInput image MIME type. Supports image/png, image/jpeg, image/webp, image/heic, and image/heif.
contents[].parts[].inline_data.datastringYesNoneBase64-encoded source image.
generationConfig.responseModalitiesstring[]No["TEXT","IMAGE"]Recommended value: ["IMAGE"].
generationConfig.imageConfig.aspectRatiostringNo1:1Supports 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, and 21:9.

Example Code

curl "https://api.tokaify.com/v1beta/models/gemini-2.5-flash-image:generateContent" \
  -H "Authorization: Bearer $TOKAIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "role": "user",
      "parts": [
        { "text": "Keep the person and clothing unchanged, and change the background to a seaside sunset." },
        { "inline_data": { "mime_type": "image/png", "data": "BASE64_IMAGE" } }
      ]
    }],
    "generationConfig": { "responseModalities": ["IMAGE"] }
  }'
import requests

response = requests.post(
    "https://api.tokaify.com/v1beta/models/gemini-2.5-flash-image:generateContent",
    headers={"Authorization": "Bearer YOUR_TOKAIFY_API_KEY"},
    json={
        "contents": [{"role": "user", "parts": [
            {"text": "Keep the person and clothing unchanged, and change the background to a seaside sunset."},
            {"inline_data": {"mime_type": "image/png", "data": "BASE64_IMAGE"}},
        ]}],
        "generationConfig": {"responseModalities": ["IMAGE"]},
    },
)
print(response.json())
const response = await fetch("https://api.tokaify.com/v1beta/models/gemini-2.5-flash-image:generateContent", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.TOKAIFY_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    contents: [{ role: "user", parts: [
      { text: "Keep the person and clothing unchanged, and change the background to a seaside sunset." },
      { inline_data: { mime_type: "image/png", data: "BASE64_IMAGE" } },
    ] }],
    generationConfig: { responseModalities: ["IMAGE"] },
  }),
});
console.log(await response.json());

Response Example

{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [{ "inlineData": { "mimeType": "image/png", "data": "iVBORw0KGgoAAAANSUhEUg..." } }]
      },
      "finishReason": "STOP"
    }
  ]
}

Notes

Billing follows the configured model and channel ratios. If you only need image output, set responseModalities=["IMAGE"].

How is this guide?

Last updated on