Image Edits
curl --request POST \
--url https://nano-gpt.com/api/v1/images/editsimport requests
url = "https://nano-gpt.com/api/v1/images/edits"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://nano-gpt.com/api/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://nano-gpt.com/api/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://nano-gpt.com/api/v1/images/edits"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://nano-gpt.com/api/v1/images/edits")
.asString();require 'uri'
require 'net/http'
url = URI("https://nano-gpt.com/api/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyEndpoint Examples
Image Edits
OpenAI-compatible image editing endpoint with multipart and JSON inputs
POST
/
api
/
v1
/
images
/
edits
Image Edits
curl --request POST \
--url https://nano-gpt.com/api/v1/images/editsimport requests
url = "https://nano-gpt.com/api/v1/images/edits"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://nano-gpt.com/api/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://nano-gpt.com/api/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://nano-gpt.com/api/v1/images/edits"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://nano-gpt.com/api/v1/images/edits")
.asString();require 'uri'
require 'net/http'
url = URI("https://nano-gpt.com/api/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyOverview
Use the image edits endpoint to modify one or more input images with a text prompt. This is an OpenAI-compatible image editing endpoint. GPT Image 2 remains the compatibility choice for requests that include a mask. For natural-language edits without a mask, useopenai/gpt-image-2.5/flare/edit for the current everyday recommendation.
For new JSON-only image-to-image generation flows, also consider the dedicated Image API, which uses input_references and POST /api/v1/images.
Both paths are supported aliases:
POST /api/v1/images/editPOST /api/v1/images/edits
Authentication
Use either header:Authorization: Bearer YOUR_API_KEYx-api-key: YOUR_API_KEY
Accountless x402 Payment
JSON image edit requests can be quoted without an account or API key on supported deployments when you explicitly opt in to the quote flow:curl -i https://nano-gpt.com/api/v1/images/edits \
-H "Content-Type: application/json" \
-H "x-x402: true" \
-d '{
"model": "gpt-image-2",
"prompt": "Remove the background",
"imageDataUrl": "data:image/png;base64,..."
}'
Authorization or x-api-key, and include x-x402: true. NanoGPT will return 402 Payment Required with available payment options. This endpoint supports accountless x402 payments where listed by GET /api/v1/x402/endpoints, including Lightning L402 when advertised. Multipart uploads require normal authentication before conversion. See Accountless x402 API Payments for the full flow.
If you receive 401 missing_api_key immediately, check that the initial quote request includes x-x402: true. Without that header, NanoGPT does not enter the x402 quote flow.
Multipart Request
Sendmultipart/form-data when uploading files.
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Edit instruction. |
image | file or string | Yes* | Input image file, image URL, or data URL. |
image[] | repeated file or string | Yes* | Repeated image inputs for multi-image editing. |
mask | file | No | Optional mask image for inpainting-capable models. |
model | string | No | Image-edit-capable model. Defaults to an image-edit-capable default when omitted. |
size | string | No | Requested output size, when supported by the model. |
n | integer | No | Number of outputs, when supported by the model. |
image or one or more image[] fields.
Other image-generation parameters may pass through when supported by the selected model.
curl -X POST https://nano-gpt.com/api/v1/images/edits \
-H "Authorization: Bearer $NANOGPT_API_KEY" \
-F model=gpt-image-2 \
-F prompt="Remove the background" \
-F image=@product.png \
-F size=1024x1024
Multi-image Multipart
curl -X POST https://nano-gpt.com/api/v1/images/edit \
-H "x-api-key: $NANOGPT_API_KEY" \
-F model=gpt-image-2 \
-F prompt="Combine these references into one product image" \
-F "image[]=@reference-1.png" \
-F "image[]=@reference-2.jpg"
JSON Request
Send JSON when you already have images as data URLs.{
"model": "gpt-image-2",
"prompt": "Remove the background",
"imageDataUrl": "data:image/png;base64,...",
"maskDataUrl": "data:image/png;base64,..."
}
Multi-image JSON
{
"model": "gpt-image-2",
"prompt": "Combine these references into one product image",
"imageDataUrls": [
"data:image/png;base64,...",
"data:image/jpeg;base64,..."
]
}
Response
Responses follow the same image response conventions as image generation. Depending on request parameters and model support, returned items may containurl or b64_json.
{
"created": 1778155200,
"data": [
{
"url": "https://..."
}
]
}
Common Errors
| Code | Description |
|---|---|
missing_image_input | image is required. |
image_input_too_large | Upload or input image is too large. |
invalid_multipart_body | Multipart body could not be parsed. |
rate_limit_exceeded | Too many image edit uploads. |
Notes
- Multipart uploads have strict size limits.
- Generated URLs are temporary unless another page explicitly guarantees longer retention.
- Use
GET /api/v1/image-modelsto discover image-edit-capable models and supported parameters.