Skip to main content
The GPT-Image-1 models are earlier GPT Image versions. Use GPT Image 2.5 for new integrations and migrate existing ones early.
  • gpt-image-1, gpt-image-1.5, and gpt-image-1-mini are still in LaoZhang API’s public pricing as of September 24, 2026, so you can keep calling them for now.
  • OpenAI plans to remove gpt-image-1 from its API on October 23, 2026.
  • OpenAI plans to remove gpt-image-1.5 and gpt-image-1-mini on December 1, 2026 (see OpenAI deprecations).
  • LaoZhang API stops serving each model at the same time.

Feature Overview

Send OpenAI-format edit requests to POST https://api.laozhang.ai/v1/images/edits through LaoZhang API: upload the original image, a mask, and a prompt to change specific regions of the image. The GPT-Image-1 models are billed by tokens; prices and groups are listed under Pricing and groups in GPT-Image-1 image generation (archived).

Introduction

The Image Edit API allows you to edit specific parts of an image by providing the original image, a mask, and a text prompt. This feature is particularly suitable for:
  • Localized Modifications: Only modify specific regions of an image
  • Content Replacement: Replace certain elements in an image
  • Creative Editing: Add new elements while maintaining overall style
  • Image Restoration: Repair or improve specific parts of an image

API Working Principle

Image editing requires three key elements:
  1. Original Image: The base image to edit
  2. Mask Image: Specifies the region to edit (transparent areas will be edited)
  3. Prompt: Describes what you want to generate in the edited region
Fully transparent areas of the mask (alpha channel = 0) mark the parts to edit. GPT Image models use the mask as guidance and may not follow its exact shape.

Quick Start

The examples on this page use older code:
  • The Python examples rely on openai.Image.create_edit from the openai 0.x SDK.
  • None of the edit requests set model, and results are read from url.
To edit with the GPT-Image-1 models, add model to every edit request (for example, model="gpt-image-1") and save b64_json results as described under Response Format.

Basic Configuration

Basic Editing Example

API Parameters

Request Parameters

Response Format

For GPT Image models, OpenAI’s official API returns only base64-encoded images (b64_json), never url. Through LaoZhang API, each item in data[] can contain either b64_json or url, so handle both when saving. For code that saves either format, see Save and check the image in the GPT Image 2.5 guide.

Creating Mask Images

Using Python PIL to Create Masks

Using Circular Mask

Complete Usage Examples

Complete Python Example

Node.js Example

Practical Application Scenarios

1. Background Replacement

2. Object Removal

3. Clothing Change

4. Image Restoration

Advanced Techniques

1. Feathered Mask

Create mask with feathered edges for more natural edits:

2. Multi-Region Editing

Edit multiple regions simultaneously:

3. Smart Prompt Building

Best Practices

1. Image Preparation

  • Format and Dimensions: The image and mask must share the same format and dimensions
  • Mask Requirement: The mask must include an alpha channel
  • File Size: Under 50MB
  • Resolution Recommendation: Use 1024x1024 for best results

2. Mask Design

  • Precise Masks: More precise masks yield better editing results
  • Edge Handling: Consider using feathered edges for more natural edits
  • Region Size: Avoid overly large edit regions, may affect results

3. Prompt Optimization

4. Error Handling

FAQ

Q: Why don’t edit results match expectations?

A: Check if mask is correct, ensuring transparent areas accurately cover parts to edit. Also optimize prompt for more specific descriptions.

Q: Which image formats are supported?

A: The image and mask must share the same format and dimensions and be under 50MB, and the mask needs an alpha channel. See the OpenAI image generation guide for details.

Q: How to achieve more natural edit results?

A: Use feathered masks and emphasize “natural blending”, “matching surrounding environment” in prompts.

Q: Can multiple regions be edited simultaneously?

A: Yes, simply mark multiple transparent areas in the mask.

Q: What limitations exist when editing large images?

A: Image files must be under 50MB; compress larger images before uploading.