跳转到主要内容
Use this endpoint to edit or transform an existing image by uploading the original file and describing the desired modification in a text prompt. The endpoint accepts multipart/form-data rather than JSON because it receives a binary image file. Endpoint: POST https://api.qhaigc.net/v1/images/edits
This endpoint uses multipart/form-data encoding, not application/json. Set the Content-Type header to multipart/form-data or omit it and let your HTTP client set it automatically when you attach a file.

Request Parameters

image
file
必填
The source image file to edit (binary). Common formats: PNG, JPEG, WEBP.
model
string
必填
The image editing model to use. Example: nano-banana-1.
prompt
string
必填
A text description of the edit to apply. Be specific — describe what should change and what should remain the same. Example: "Change the background to white".
size
string
Desired output dimensions. If omitted, the model may use the source image’s dimensions or a default size.

Response Fields

created
integer
Unix timestamp of when the edited image was generated.
data
array
Array of edited image objects.

Code Examples

import requests

url = "https://api.qhaigc.net/v1/images/edits"
headers = {
    "Authorization": "Bearer sk-your-api-key-here"
    # Do NOT set Content-Type here — requests sets it automatically with the correct boundary
}

with open("original_image.png", "rb") as image_file:
    files = {"image": image_file}
    data = {
        "model": "nano-banana-1",
        "prompt": "Change the background to a clean white studio setting"
    }
    response = requests.post(url, headers=headers, files=files, data=data)

result = response.json()
print(result["data"][0]["url"])

Example Response

{
  "created": 1761223754,
  "data": [
    {
      "url": "https://images.qhaigc.net/img/edited_image.webp"
    }
  ]
}

Tips for Effective Edits

Vague prompts produce unpredictable edits. Specify what should change and what should stay the same. For example: "Replace the red car with a blue car, keep all other elements identical" is better than "Make it blue".
The editing model works best with clear, well-lit images. Blurry or low-resolution source images may produce poor results.
Upload images in PNG, JPEG, or WEBP format. Very large files may time out — resize your image to under 4MB if you encounter errors.