Image editing
Choose the supported protocol
Section titled “Choose the supported protocol”Both the model and route must support editing. OpenAI Images edits normally use multipart files; Gemini-native requests use inlineData. A remote API cannot read a local path such as C:\\photo.png supplied as ordinary JSON.
OpenAI Images edit structure
Section titled “OpenAI Images edit structure”POST https://wudiapi.com/v1/images/edits
Use this only with a GPT Image route confirmed to support editing:
curl https://wudiapi.com/v1/images/edits \ -H "Authorization: Bearer $WUDI_API_KEY" \ -F 'model=gpt-image-2' \ -F 'prompt=Keep the cup shape, change its color to dark blue, and keep the white background' \ -F 'image=@./cup.png'Let the HTTP library set the multipart Content-Type boundary. File type, size, image count, mask support and other limits depend on the target model. Start with one file and no optional mask parameters.
Gemini image content blocks
Section titled “Gemini image content blocks”Put text and an image together in contents[0].parts. Replace data with actual Base64 without a Data URL prefix:
{ "contents":[{"parts":[ {"text":"Keep the subject and make the background white"}, {"inlineData":{"mimeType":"image/png","data":"IMAGE_BASE64"}} ]}], "generationConfig":{"responseModalities":["TEXT","IMAGE"]}}See Nano Banana for the route and model ID. A text description of an input image is not an edited image result.
Make the edit clear
Section titled “Make the edit clear”Describe the subject, text and layout to preserve, then identify a specific change. Check important text manually after generation; edits are not guaranteed to preserve every pixel. Keep the original and save the result under a new name.
Upload failures
Section titled “Upload failures”A 400 can indicate an unsupported field or file; 413 indicates an oversized request, and 415 an unsupported content type. Test one small PNG before increasing complexity. If editing is not available, confirm support rather than assuming an upload failure is a balance problem.
