curl --request POST \
--url 'https://api.elkapi.com/v1/images/edits' \
--header 'Authorization: Bearer <token>' \
--form 'image=@https://example.com/image.png' \
--form 'mask=@file.bin' \
--form 'prompt=A small kitten running through a sunny garden, cinematic, highly detailed' \
--form 'n=1' \
--form 'size=1024x1024' \
--form 'response_format=json' \
--form 'user=' \
--form 'model=gpt-image-1.5'
import requests
url = "https://api.elkapi.com/v1/images/edits"
headers = {
"Authorization": "Bearer <token>"
}
files = {
"image": open("https://example.com/image.png", "rb"),
"mask": open("file.bin", "rb"),
}
data = {
"prompt": "A small kitten running through a sunny garden, cinematic, highly detailed",
"n": "1",
"size": "1024x1024",
"response_format": "json",
"user": "",
"model": "gpt-image-1.5",
}
response = requests.request("POST", url, headers=headers, data=data, files=files)
print(response.text)
const url = "https://api.elkapi.com/v1/images/edits";
const headers = {
"Authorization": "Bearer <token>"
};
const form = new FormData();
form.append("image", fileInput.files[0]);
form.append("mask", fileInput.files[0]);
form.append("prompt", "A small kitten running through a sunny garden, cinematic, highly detailed");
form.append("n", "1");
form.append("size", "1024x1024");
form.append("response_format", "json");
form.append("user", "");
form.append("model", "gpt-image-1.5");
const response = await fetch(url, {
method: "POST",
headers,
body: form
});
console.log(await response.text());
{}
Native OpenAI Format
Edit Image
- Create an edited or extended image from a source image and prompt.
POST
/
v1
/
images
/
edits
curl --request POST \
--url 'https://api.elkapi.com/v1/images/edits' \
--header 'Authorization: Bearer <token>' \
--form 'image=@https://example.com/image.png' \
--form 'mask=@file.bin' \
--form 'prompt=A small kitten running through a sunny garden, cinematic, highly detailed' \
--form 'n=1' \
--form 'size=1024x1024' \
--form 'response_format=json' \
--form 'user=' \
--form 'model=gpt-image-1.5'
import requests
url = "https://api.elkapi.com/v1/images/edits"
headers = {
"Authorization": "Bearer <token>"
}
files = {
"image": open("https://example.com/image.png", "rb"),
"mask": open("file.bin", "rb"),
}
data = {
"prompt": "A small kitten running through a sunny garden, cinematic, highly detailed",
"n": "1",
"size": "1024x1024",
"response_format": "json",
"user": "",
"model": "gpt-image-1.5",
}
response = requests.request("POST", url, headers=headers, data=data, files=files)
print(response.text)
const url = "https://api.elkapi.com/v1/images/edits";
const headers = {
"Authorization": "Bearer <token>"
};
const form = new FormData();
form.append("image", fileInput.files[0]);
form.append("mask", fileInput.files[0]);
form.append("prompt", "A small kitten running through a sunny garden, cinematic, highly detailed");
form.append("n", "1");
form.append("size", "1024x1024");
form.append("response_format", "json");
form.append("user", "");
form.append("model", "gpt-image-1.5");
const response = await fetch(url, {
method: "POST",
headers,
body: form
});
console.log(await response.text());
{}
curl --request POST \
--url 'https://api.elkapi.com/v1/images/edits' \
--header 'Authorization: Bearer <token>' \
--form 'image=@https://example.com/image.png' \
--form 'mask=@file.bin' \
--form 'prompt=A small kitten running through a sunny garden, cinematic, highly detailed' \
--form 'n=1' \
--form 'size=1024x1024' \
--form 'response_format=json' \
--form 'user=' \
--form 'model=gpt-image-1.5'
import requests
url = "https://api.elkapi.com/v1/images/edits"
headers = {
"Authorization": "Bearer <token>"
}
files = {
"image": open("https://example.com/image.png", "rb"),
"mask": open("file.bin", "rb"),
}
data = {
"prompt": "A small kitten running through a sunny garden, cinematic, highly detailed",
"n": "1",
"size": "1024x1024",
"response_format": "json",
"user": "",
"model": "gpt-image-1.5",
}
response = requests.request("POST", url, headers=headers, data=data, files=files)
print(response.text)
const url = "https://api.elkapi.com/v1/images/edits";
const headers = {
"Authorization": "Bearer <token>"
};
const form = new FormData();
form.append("image", fileInput.files[0]);
form.append("mask", fileInput.files[0]);
form.append("prompt", "A small kitten running through a sunny garden, cinematic, highly detailed");
form.append("n", "1");
form.append("size", "1024x1024");
form.append("response_format", "json");
form.append("user", "");
form.append("model", "gpt-image-1.5");
const response = await fetch(url, {
method: "POST",
headers,
body: form
});
console.log(await response.text());
{}
Authorizations
string
required
All endpoints require Bearer Token authentication.Add it to the request headers:
Authorization: Bearer YOUR_API_KEY
Body
file
required
Image to edit. Must be a valid PNG file, under 4 MB, and square. If no mask is provided, the image must include transparency, which will be used as the mask.Example:
cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.pngfile
Additional image whose fully transparent areas (for example, areas with alpha zero) indicate where the image should be edited. Must be a valid PNG file, under 4 MB, and the same dimensions as the original image.Example: “
string
required
Text description of the desired image. Maximum length: 1000 characters.Example:
A cute baby sea otter wearing a beret.string
Number of images to generate. Must be between 1 and 10.Example:
1string
Size of the generated image. Must be one of
256x256, 512x512, or 1024x1024.Example: 1024x1024string
Format returned for the generated image. Must be
url or b64_json.Example: urlstring
A unique identifier for your end user, which can help OpenAI monitor and detect abuse. Learn more.Example: “
string
default:"gpt-image-1.5"
Example:
gpt-image-1.5