POST
/
images
/
edits
curl --request POST \
  --url https://api.electronhub.ai/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'prompt=<string>' \
  --form model=dall-e-2 \
  --form n=1 \
  --form size=1024x1024 \
  --form response_format=url
{
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "b64_json": "<string>",
      "revised_prompt": "<string>"
    }
  ]
}

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

image
file
required

The image to edit. Must be a valid PNG file, less than 4MB, and square.

mask
file

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.

prompt
string
required

A text description of the desired image(s)

model
string

The model to use for image editing (currently only “dall-e-2”)

n
integer

Number of images to generate (1-10)

size
string

Size of the generated images (“256x256”, “512x512”, “1024x1024”)

response_format
string

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

image
file
required

The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.

model
string

The model to use for generating variations (currently only “dall-e-2”)

n
integer

Number of images to generate (1-10)

size
string

Size of the generated images (“256x256”, “512x512”, “1024x1024”)

response_format
string

Format of the generated images (“url” or “b64_json”)

Authorizations

Authorization
string
header
required

Enter your API key (starts with 'ek-')

Body

multipart/form-data

Response

200 - application/json

Success

The response is of type object.