> ## 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.

# Video Generations

> Generate videos from text prompts via Server-Sent Events (SSE)

Create original short videos from text prompts. This endpoint streams results over SSE. Send `Accept: text/event-stream` to receive incremental updates until completion.

<Info>
  Video generation typically takes 3–6 minutes to complete. Set your HTTP client timeout to at least 600–900 seconds to avoid premature disconnects.
</Info>

### Examples

<CodeGroup>
  ```python Python theme={null}
  import httpx, orjson

  url = "https://api.electronhub.ai/v1/videos/generations"

  payload = {
      "model": "midjourney-video",
      "prompt": "a playful cat",
      # "size": "16:9",  # optional
  }
  headers = {
      "Accept": "text/event-stream",
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
  }

  with httpx.stream("POST", url, json=payload, headers=headers, timeout=900) as response:
      for line in response.iter_lines():
          if line:
              data = orjson.loads(line)
              if data:
                  if data.get("heartbeat"):
                      print("Pending...")
                  else:
                      print(line)
  ```

  ```bash cURL theme={null}
  curl -N -X POST "https://api.electronhub.ai/v1/videos/generations" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Accept: text/event-stream" \
    -H "Content-Type: application/json" \
    --max-time 900 \
    -d '{
      "model": "midjourney-video",
      "prompt": "a playful cat",
      "size": "16:9"
    }'
  ```
</CodeGroup>


## OpenAPI

````yaml POST /videos/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:
  /videos/generations:
    post:
      summary: Generate Videos
      description: Generate videos from text prompts (SSE streaming)
      operationId: generateVideos
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoGenerationRequest'
      responses:
        '200':
          description: SSE stream of video generation events
          content:
            text/event-stream:
              schema:
                type: string
components:
  schemas:
    VideoGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          example: midjourney-video
        prompt:
          type: string
          description: Text description of the desired video
        size:
          type: string
          description: Output aspect ratio (e.g., '16:9', '9:16', '1:1')
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
            - '4:3'
            - '3:4'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your API key (starts with 'ek-')

````