POST
/
images
/
generations
curl --request POST \
  --url https://api.electronhub.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "dall-e-3",
  "prompt": "<string>",
  "n": 1,
  "quality": "standard",
  "size": "1024x1024",
  "response_format": "url",
  "public": false
}'
{
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "b64_json": "<string>",
      "revised_prompt": "<string>"
    }
  ]
}

Create original images using AI models like DALL-E.

Generate Images

POST /images/generations

Generate images from text descriptions.

Request Body

prompt
string
required

A text description of the desired image(s)

model
string

The model to use for image generation (e.g., “dall-e-3”, “dall-e-2”)

n
integer

Number of images to generate (1-10 for dall-e-2, 1 for dall-e-3)

size
string

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

quality
string

Quality of the image (“standard” or “hd”)

style
string

Style of the generated images (“vivid” or “natural”)

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 response = await fetch('https://api.electronhub.ai/v1/images/generations', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    prompt: 'A futuristic cityscape at sunset',
    model: 'dall-e-3',
    n: 1,
    size: '1024x1024',
    quality: 'hd'
  })
});

const data = await response.json();
console.log(data);

Authorizations

Authorization
string
header
required

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

Body

application/json

Response

200 - application/json

Success

The response is of type object.