Tạo chỉnh sửa hình ảnh
Sử dụng POST /v1/images/edits trong CometAPI để chỉnh sửa hình ảnh bằng tải lên multipart, mask, các model hình ảnh GPT và các tùy chọn điều khiển đầu ra hình ảnh được mã hóa.
Sử dụng route này khi
- Bạn đã có một hình ảnh nguồn và muốn chỉnh sửa theo Prompt
- Bạn có thể cần một mask để thay đổi có mục tiêu
- Bạn có thể xử lý tải tệp multipart thay vì một yêu cầu JSON thuần
Yêu cầu đầu tiên an toàn
- Bắt đầu với một tệp PNG hoặc JPG
- Bỏ qua mask cho đến khi luồng chỉnh sửa cơ bản hoạt động
- Sử dụng
model: "gpt-image-2"cho các yêu cầu chỉnh sửa hình ảnh GPT trên route này - Sử dụng một hướng dẫn ngắn yêu cầu một thay đổi dễ thấy
- Đọc kết quả đã chỉnh sửa từ
data[0].b64_json - Đặt
output_format: "jpeg"khi bạn muốn payload JPEG - Dự kiến độ trễ lâu hơn so với tạo hình ảnh thông thường
Hành vi của model
- Các model chỉnh sửa hình ảnh GPT trên route này trả về dữ liệu hình ảnh base64 inline
output_formatđiều khiển loại hình ảnh được mã hóa bên trongb64_jsonresponse_formatchỉ quan trọng khi một model hỗ trợ đầu ra URLqwen-image-edittuân theo hành vi chỉnh sửa đặc thù của nhà cung cấp phía sau cùng một route CometAPI
Ủy quyền
Bearer token authentication. Use your CometAPI key.
Nội dung
Source image file. Start with one PNG or JPG input for the simplest flow.
Edit instruction describing the change you want.
"Add a small red ribbon to the paper boat."
The image editing model to use. Choose a supported model from the Models page.
Optional PNG mask. Transparent areas mark the regions to edit. The mask dimensions must match the source image exactly.
Number of edited images to return.
Quality setting for models that support it.
high, medium, low Requested response container when supported by the selected model. GPT image edit models return data[].b64_json; use output_format to choose the encoded image type.
url, b64_json Encoded image type for GPT image edit results returned in data[].b64_json. For example, use jpeg for a JPEG payload.
"jpeg"
Requested output size when supported by the selected model.
Phản hồi
Edited image result.
Background mode returned by models that expose it.
Encoded image type returned by GPT image models.
Quality level returned by models that expose it.
Output size returned by models that expose it.