> ## 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.

# OpenAI Image editing

***

## Request

<CodeGroup>
  ```shellscript cURL theme={null}
  curl -X POST "https://api.znapai.com/v1/images/edits" \
    -H "Authorization: Bearer $ZnapAI_API_KEY" \
    -H 'spend-logs-metadata: {"user_id": "user-123", "project_id": "proj_abc", "env": "production"}' \
    -F "model=gemini-3-pro-image" \
    -F "image=@output.png" \
    -F "prompt=An office group photo of these people, they are making funny faces." \
  ```

  ```python OpenAI (Python) theme={null}
  from openai import OpenAI

  # Initialize client with your proxy URL
  client = OpenAI(
      base_url="https://api.znapai.com/", 
      api_key="$ZnapAI_API_KEY"
  )

  # Edit an image
  response = client.images.edit(
      model="gemini-3-pro-image",
      image=open("output.png", "rb"),
      prompt="An office group photo of these people, they are making funny faces.",
      n=1,
      size="1024x1024"
  )

  print(response)
  ```

  ```typescript OpenAI (JS) theme={null}
  import fs from "fs";
  import OpenAI, { toFile } from "openai";

  const client = new OpenAI({
      apiKey: "$ZnapAI_API_KEY",
      baseURL: "https://api.znapai.com/"
  });

  const imageFiles = [
      "output.png",
  ];

  const images = await Promise.all(
      imageFiles.map(async (file) =>
          await toFile(fs.createReadStream(file), null, {
              type: "image/png",
          })
      ),
  );

  const rsp = await client.images.edit({
      model: "gemini-3-pro-image",
      image: images,
      prompt: "An office group photo of these people, they are making funny faces.",
  });

  // Save the image to a file
  const image_base64 = rsp.data[0].b64_json;
  const image_bytes = Buffer.from(image_base64, "base64");
  fs.writeFileSync("basket.png", image_bytes);
  ```
</CodeGroup>

## Input

<Frame>
  <img src="https://mintcdn.com/znapai/brMaqJtnOrFJ3jGG/images/output.png?fit=max&auto=format&n=brMaqJtnOrFJ3jGG&q=85&s=8aa00dfa9864e87800dac7e1f4322113" alt="Output" width="1024" height="1024" data-path="images/output.png" />
</Frame>

## Response

<Frame>
  <img src="https://mintcdn.com/znapai/brMaqJtnOrFJ3jGG/images/result.png?fit=max&auto=format&n=brMaqJtnOrFJ3jGG&q=85&s=679c2eed51594d57d93c423422abc74e" alt="Result" width="2304" height="1856" data-path="images/result.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="model" type="string" required>
  Name of the model to use (for example: gemini-3.1-flash-image-preview). To see the complete list of supported image generation models, visit: [https://znapai.com/models/image\_generation](https://znapai.com/models/image_generation)
</ParamField>

<ParamField path="prompt" type="string" required>
  Text description of the desired edit.
</ParamField>

<ParamField path="image" type="file | array" required>
  Reference image(s) to edit. Must be uploaded via multipart form data — image URLs are not supported.

  Supported number of images:

  * `gemini-2.5-flash-image`: up to 3 images

  * `gemini-3.1-flash-image`: up to 14 images

  * `gemini-3-pro-image`: up to 14 images

  * GPT models: up to 16 images

  * `-F "image=@file.png"` or `-F "image[]=@file1.png" -F "image[]=@file2.png"`
</ParamField>

<ParamField path="mask" type="file | object">
  Alpha mask PNG. Transparent areas are regenerated; opaque areas are preserved. Must be uploaded via multipart — mask URLs are not supported.

  * `-F "mask=@mask.png"`
</ParamField>

<ParamField path="size" type="string" default="1024x1024">
  Output image dimensions. Supports arbitrary `WIDTHxHEIGHT` where both edges are multiples of 16, aspect ratio between 1:3 and 3:1, max edge 3840.

  Standard values: `1024x1024`, `1536x1024`, `1024x1536`, `auto`.

  Supported values depend on the selected model. See the [OpenAI image generation guide](https://developers.openai.com/api/docs/guides/image-generation) for the latest model-specific ranges.
</ParamField>

<ParamField path="quality" type="string" default="auto">
  Allowed values: `low`, `medium`, `high`, `auto`
</ParamField>

<ParamField path="n" type="integer" default="1">
  Number of edited images to return.
</ParamField>

<ParamField path="output_format" type="string" default="png">
  Allowed values: `png`, `jpeg`

  <Warning>`webp` is not supported on Azure gpt-image-2.</Warning>
</ParamField>

<ParamField path="output_compression" type="integer">
  Compression level (0–100). Only applies when `output_format` is `jpeg`.
</ParamField>

<ParamField path="moderation" type="string" default="auto">
  Allowed values: `auto`, `low`
</ParamField>

<ParamField path="stream" type="boolean" default="false">
  Stream partial edit results.
</ParamField>

<ParamField path="partial_images" type="integer">
  Number of partial images during streaming (0–3). Only used when `stream` is `true`.
</ParamField>

***

## Params to Avoid

| Param                       | Reason                                                                       |
| --------------------------- | ---------------------------------------------------------------------------- |
| `mask`                      | Some Gemini models do not support the mask parameter                         |
| `response_format: "url"`    | ZnapAI image endpoint only returns `b64_json`                                |
| `background: "transparent"` | Not supported by image editing models                                        |
| `output_format: "webp"`     | WebP output format is not supported                                          |
| `spend-logs-metadata`       | This metadata must be passed as an HTTP header, not in the JSON request body |
