Create variations or edits of existing images using AI models.
Edit Images
POST /images/edits
Create edited or extended versions of an existing image.
Request Body
The image to edit. Must be a valid PNG file, less than 4MB, and square.
Additional image whose fully transparent areas indicate where image should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.
A text description of the desired image(s)
The model to use for image editing (“flux-1-kontext-pro”, “flux-1-kontext-max”, etc)
Number of images to generate (1-10)
Size of the generated images (“256x256”, “512x512”, “1024x1024”)
Format of the generated images (“url” or “b64_json”)
Response
Returns an array of image objects with URLs or base64-encoded images.
Example
const formData = new FormData();
formData.append('image', imageFile);
formData.append('prompt', 'Add a blue sky to this image');
formData.append('n', '1');
formData.append('size', '1024x1024');
const response = await fetch('https://api.electronhub.ai/v1/images/edits', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: formData
});
const data = await response.json();
console.log(data);
Image Variations
POST /images/variations
Create variations of an existing image.
Request Body
The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
The model to use for generating variations (“flux-1-kontext-pro”, “flux-1-kontext-max”, etc)
Number of images to generate (1-10)
Size of the generated images (“256x256”, “512x512”, “1024x1024”)
Format of the generated images (“url” or “b64_json”)
Enter your API key (starts with 'ek-')
A text description of the desired image
Required range: 1 <= x <= 10
size
enum<string>
default:1024x1024
Available options:
256x256,
512x512,
1024x1024
Available options:
url,
b64_json