> ## Documentation Index
> Fetch the complete documentation index at: https://docs.znapai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Vertex Image editing

***

## Request

<CodeGroup>
  ```shellscript cURL theme={null}
  curl --location 'https://api.znapai.com/v1beta1/projects/default/locations/global/publishers/google/models/gemini-2.5-flash-image:generateContent' \
  --header 'Authorization: Bearer $ZnapAI_API_KEY' \
  --header 'Content-Type: application/json' \
  --header 'spend-logs-metadata: {"user_id": "user-123", "project_id": "proj_abc", "env": "production"}' \
  --data '{
      "contents": [
        {
          "role": "user",
          "parts": [
            {
              "text": "Edit this image and draw a smiley in it"
            },
            {
              "inlineData": {
                "mimeType": "image/jpeg",
                "data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wAARCABAAEADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwCxRRRXsHAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9k="
              }
            }
          ]
        }
      ],
      "generationConfig": {
        "responseModalities": ["IMAGE", "TEXT"]
      }
    }'
  ```
</CodeGroup>

## Input

<Frame>
  <img src="https://mintcdn.com/znapai/YqLy5V4XqDwqd3Qg/images/contents_0__parts_1__inlineData_data.jpg?fit=max&auto=format&n=YqLy5V4XqDwqd3Qg&q=85&s=484c91ee7f0c6a4ba170676873fc5ce5" alt="Contents 0 Parts 1 Inline Data Data" width="64" height="64" data-path="images/contents_0__parts_1__inlineData_data.jpg" />
</Frame>

## Response

```json theme={null}
{
    "candidates": [
        {
            "content": {
                "role": "model",
                "parts": [
                    {
                        "inlineData": {
                            "mimeType": "image/png",
                            "data": "iVBORw0KGgo...uQmCC"
                        }
                    }
                ]
            },
            "finishReason": "STOP"
        }
    ],
    "usageMetadata": {
        "promptTokenCount": 1812,
        "candidatesTokenCount": 1290,
        "totalTokenCount": 3102,
        "trafficType": "ON_DEMAND",
        "promptTokensDetails": [
            {
                "modality": "TEXT",
                "tokenCount": 6
            },
            {
                "modality": "IMAGE",
                "tokenCount": 1806
            }
        ],
        "candidatesTokensDetails": [
            {
                "modality": "IMAGE",
                "tokenCount": 1290
            }
        ]
    },
    "modelVersion": "gemini-2.5-flash-image",
    "createTime": "2026-04-08T17:50:54.995975Z",
    "responseId": "fpXWaYflPLqnpt8P8svDwAE"
}
```

***

## Image from base64 data

<Frame>
  <img src="https://mintcdn.com/znapai/YqLy5V4XqDwqd3Qg/images/candidates_0__content_parts_0__inlineData_data-(1).png?fit=max&auto=format&n=YqLy5V4XqDwqd3Qg&q=85&s=9a2d0f35a3e83a0b64671181febdc1bf" alt="Candidates 0 Content Parts 0 Inline Data Data (1)" width="1024" height="1024" data-path="images/candidates_0__content_parts_0__inlineData_data-(1).png" />
</Frame>

***

## Parameters

<ParamField path="spend-logs-metadata" type="header" required={false}>
  An optional header used for spend logging metadata, containing JSON properties like `user_id`, `project_id`, and `env`.
</ParamField>

<ParamField path="contents" type="array" required>
  The conversation history or input prompts as an array of content objects.

  <Expandable title="contents[]" defaultOpen="True">
    <ResponseField name="role" type="string">
      The role of the creator of the content (e.g. `"user"` or `"model"`).
    </ResponseField>

    <ResponseField name="parts" type="array" required>
      An ordered list of parts that constitute a single message turn.

      <Expandable title="parts[]" defaultOpen="True">
        <ResponseField name="text" type="string">
          The text instruction prompt for editing.
        </ResponseField>

        <ResponseField name="inlineData" type="object">
          The inline image data to be edited.

          <Expandable title="inlineData" defaultOpen="True">
            <ResponseField name="mimeType" type="string" required>
              The IANA media type of the image (e.g. `image/png`, `image/jpeg`).
            </ResponseField>

            <ResponseField name="data" type="string" required>
              The base64-encoded image bytes.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="systemInstruction" type="object">
  Instructions to the model that dictate how it should behave.

  <Expandable title="systemInstruction" defaultOpen="True">
    <ResponseField name="parts" type="array" required>
      An ordered list of parts that constitute the system instruction.

      <Expandable title="parts[]" defaultOpen="True">
        <ResponseField name="text" type="string">
          The text of the system instruction.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="tools" type="array">
  A list of `Tools` the model may use to generate the next response. Supported tools are function declarations, code execution, and Google Search.

  <Expandable title="tools[]" defaultOpen="False">
    <ResponseField name="functionDeclarations" type="array">
      A list of function declarations the model can call.

      <Expandable title="functionDeclarations[]">
        <ResponseField name="name" type="string" required>
          The name of the function to call.
        </ResponseField>

        <ResponseField name="description" type="string">
          A description of what the function does.
        </ResponseField>

        <ResponseField name="parameters" type="object">
          Describes the parameters for the function in JSON Schema format.

          <Expandable title="parameters">
            <ResponseField name="type" type="string">
              The type of the parameters object. Usually `"object"`.
            </ResponseField>

            <ResponseField name="properties" type="object">
              A map of parameter names to their schema definitions.
            </ResponseField>

            <ResponseField name="required" type="array">
              List of required parameter names.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="codeExecution" type="object">
      Enables the model to execute code as part of generation. Pass an empty object `{}` to enable.
    </ResponseField>

    <ResponseField name="googleSearch" type="object">
      Tool to support Google Search grounding in model responses. Pass an empty object `{}` to enable.
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="toolConfig" type="object">
  Tool configuration for any `Tool` specified in the request.

  <Expandable title="toolConfig" defaultOpen="False">
    <ResponseField name="functionCallingConfig" type="object">
      Configuration for function calling behavior.

      <Expandable title="functionCallingConfig">
        <ResponseField name="mode" type="string">
          Controls how the model uses the provided functions. One of:

          * `"AUTO"` — model decides whether to call a function or respond in text
          * `"ANY"` — model must call one of the provided functions
          * `"NONE"` — model must not call any functions
        </ResponseField>

        <ResponseField name="allowedFunctionNames" type="array">
          Optional. When `mode` is `"ANY"`, limits the model to only call functions from this list.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="generationConfig" type="object">
  Configuration options for the generation.

  <Expandable title="generationConfig" defaultOpen="True">
    <ResponseField name="candidateCount" type="integer" default={1}>
      Number of generated images to return.
    </ResponseField>

    <ResponseField name="temperature" type="number">
      Controls the randomness of the output.
    </ResponseField>

    <ResponseField name="topP" type="number">
      The maximum cumulative probability of tokens to consider when sampling.
    </ResponseField>

    <ResponseField name="topK" type="number">
      The maximum number of tokens to consider when sampling.
    </ResponseField>

    <ResponseField name="maxOutputTokens" type="number">
      The maximum number of tokens to include in a candidate.
    </ResponseField>

    <ResponseField name="stopSequences" type="array">
      A list of sequences that will stop generation.
    </ResponseField>

    <ResponseField name="responseModalities" type="array">
      Allowed modalities of the output. Use `["IMAGE", "TEXT"]` to request image output.
    </ResponseField>

    <ResponseField name="imageConfig" type="object">
      Settings for the output image.

      <Expandable title="imageConfig">
        <ResponseField name="aspectRatio" type="string">
          Aspect ratio of the output image (e.g. `"16:9"`, `"1:1"`).
        </ResponseField>

        <ResponseField name="imageSize" type="string">
          Output image resolution level (e.g. `"1K"`, `"2K"`, `"4K"`).
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="safetySettings" type="array">
  A list of unique safety settings for blocking unsafe content.

  <Expandable title="safetySettings[]" defaultOpen="True">
    <ResponseField name="category" type="string">
      The category for this setting.
    </ResponseField>

    <ResponseField name="threshold" type="string">
      The threshold for blocking.
    </ResponseField>
  </Expandable>
</ParamField>

***

## Params to Avoid

| Param                                                   | Reason                                                                                                                                      |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `prompt`, `n`, `size`, `quality`                        | OpenAI/Azure OpenAI parameters; sending these at the root level will fail schema validation. Use `contents` and `generationConfig` instead. |
| `response_format`, `output_format`                      | Not supported by the Gemini API. Response format is determined by `responseModalities`.                                                     |
| `background`, `output_compression`, `style`             | OpenAI/Azure specific parameters; not supported by Gemini models.                                                                           |
| `generationConfig.responseMimeType: "application/json"` | Not supported when `responseModalities` includes `"IMAGE"`.                                                                                 |
| `inline_data`, `mime_type`                              | Snake case keys are used in the Google GenAI Developer API, but the Vertex AI API requires camelCase (`inlineData`, `mimeType`).            |
| `spend-logs-metadata`                                   | This metadata must be passed as an HTTP header, not in the JSON request body                                                                |

<Warning>
  Ensure you do not mix OpenAI or Azure-specific parameters (such as `prompt`, `size`, `quality`, or `n`) with Gemini/Vertex AI request structure. Vertex AI expects prompt text and the image input inside the nested `contents.parts` object using camelCase keys.
</Warning>
