> ## Documentation Index
> Fetch the complete documentation index at: https://docs.electronhub.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Generations

> Generate images using AI models

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

```javascript Node.js theme={null}
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);
```

```python Python theme={null}
import requests

response = requests.post(
    'https://api.electronhub.ai/v1/images/generations',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'prompt': 'A futuristic cityscape at sunset',
        'model': 'dall-e-3',
        'n': 1,
        'size': '1024x1024',
        'quality': 'hd'
    }
)

print(response.json())
```

```bash cURL theme={null}
curl -X POST "https://api.electronhub.ai/v1/images/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic cityscape at sunset",
    "model": "dall-e-3",
    "n": 1,
    "size": "1024x1024",
    "quality": "hd"
  }'
```


## OpenAPI

````yaml POST /images/generations
openapi: 3.0.1
info:
  title: Electron Hub API
  description: >-
    Unified API platform integrating 200+ AI models for chat, image generation,
    speech-to-text, embeddings, and more.
  version: 1.0.0
  contact:
    name: Electron Hub Support
    email: support@electronhub.ai
    url: https://discord.com/invite/electronhub
  license:
    name: MIT
servers:
  - url: https://api.electronhub.ai/v1
    description: Production API v1
security:
  - bearerAuth: []
paths:
  /images/generations:
    post:
      summary: Generate Images
      description: Generate images from text prompts
      operationId: generateImages
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
components:
  schemas:
    ImageGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          example: dall-e-3
        prompt:
          type: string
          description: Text description of the desired image
        'n':
          type: integer
          minimum: 1
          maximum: 10
          default: 1
          description: Number of images to generate
        quality:
          type: string
          enum:
            - standard
            - hd
          default: standard
        size:
          type: string
          enum:
            - 256x256
            - 512x512
            - 1024x1024
            - 1792x1024
            - 1024x1792
          default: 1024x1024
        response_format:
          type: string
          enum:
            - url
            - b64_json
          default: url
        public:
          type: boolean
          default: false
          description: Whether to make the image publicly accessible
    ImageResponse:
      type: object
      required:
        - created
        - data
      properties:
        created:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImageData'
    ImageData:
      type: object
      properties:
        url:
          type: string
          format: uri
        b64_json:
          type: string
        revised_prompt:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your API key (starts with 'ek-')

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.