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

# Video Diffusion

> Generate videos from text or images

## Headers

| Header      | Type   | Required | Description  |
| ----------- | ------ | -------- | ------------ |
| `x-api-key` | string | Yes      | Your API key |

## Request Body

## Image-to-Video Mode

Choose one of two input methods:

**Option 1: Using existing generated image**

| Parameter   | Type    | Required | Description                                      |
| ----------- | ------- | -------- | ------------------------------------------------ |
| `jobId`     | string  | Yes      | ID of the source image generation task           |
| `imageNo`   | integer | Yes      | Image number to animate (0/1/2/3)                |
| `prompt`    | string  | No       | Video generation prompt text (1-8192 characters) |
| `videoType` | integer | No       | Video quality type (0: 480p, 1: 720p)            |
| `callback`  | string  | No       | Callback URL for task completion notifications   |

**Option 2: Using prompt with image URL**

| Parameter   | Type    | Required | Description                                                                                                        |
| ----------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------ |
| `prompt`    | string  | Yes      | Video generation prompt text with image URL included, format: "\[image\_url] your prompt text" (1-8192 characters) |
| `videoType` | integer | No       | Video quality type (0: 480p, 1: 720p)                                                                              |
| `callback`  | string  | No       | Callback URL for task completion notifications                                                                     |

## Video Types

| Value | Resolution | Description                   |
| ----- | ---------- | ----------------------------- |
| 0     | 480p       | Standard definition (default) |
| 1     | 720p       | High definition               |

## Advanced Parameters

You can add these parameters to your prompt for more control over video generation:

### Motion Intensity

Control the amount of movement in the generated video:

* **Low Motion** (default): Static scenes with subtle movements
  * Add `--motion low` to your prompt
* **High Motion**: Large camera movements and dramatic motion (may produce artistic effects)
  * Add `--motion high` to your prompt

**Example:**

```
"https://example.com/image.jpg A cinematic landscape --motion high"
```

### Raw Mode

Reduce automatic system enhancements for more precise control over the output:

* Add `--raw` to your prompt

**Example:**

```
"https://example.com/image.jpg A peaceful sunset scene --raw"
```

### End Frame Image

Specify the final frame of your video by providing an image URL:

* Add `--end [image_url]` to your prompt

**Example:**

```
"https://example.com/start.jpg A transformation sequence --end https://example.com/end.jpg"
```

### Video Loop

Generate a video where the last frame matches the first frame, creating a seamless loop:

* Add `--loop` to your prompt

**Example:**

```
"https://example.com/image.jpg Rotating product display --loop"
```

### Batch Size

Control the number of videos generated in a single task. This affects the cost accordingly:

* Add `--bs [1|2|4]` to your prompt
* Valid values: 1, 2, or 4
* Default: 4

**Example:**

```
"https://example.com/image.jpg A dynamic animation --bs 2"
```

### Combining Parameters

You can combine multiple parameters in a single prompt:

**Example:**

```
"https://example.com/image.jpg Epic camera movement through the scene --motion high --raw --loop --bs 1"
```

## Example Requests

### Image-to-Video (Using existing image)

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.legnext.ai/api/v1/video-diffusion" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "jobId": "c6821434-5e41-408f-b42b-2562306b109c",
      "imageNo": 0,
      "prompt": "Make this image move with gentle animation",
      "callback": "https://webhook.site/c98cb890-fb92-439f-8d60-42c8a51eb52d",
      "videoType": 0
    }'
  ```

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

  url = "https://api.legnext.ai/api/v1/video-diffusion"
  headers = {
      "x-api-key": "YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {
      "jobId": "c6821434-5e41-408f-b42b-2562306b109c",
      "imageNo": 0,
      "prompt": "Make this image move with gentle animation",
      "callback": "https://webhook.site/c98cb890-fb92-439f-8d60-42c8a51eb52d",
      "videoType": 0
  }

  response = requests.post(url, headers=headers, json=data)
  result = response.json()
  print(result)
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.legnext.ai/api/v1/video-diffusion', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      jobId: 'c6821434-5e41-408f-b42b-2562306b109c',
      imageNo: 0,
      prompt: 'Make this image move with gentle animation',
      callback: 'https://webhook.site/c98cb890-fb92-439f-8d60-42c8a51eb52d',
      videoType: 0
    })
  });

  const result = await response.json();
  console.log(result);
  ```
</CodeGroup>

### Image-to-Video (Using image URL)

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.legnext.ai/api/v1/video-diffusion" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "https://example.com/image.jpg A cinematic shot of ocean waves crashing against rocks",
      "videoType": 1,
      "callback": "https://webhook.site/d0ca59bc-35a6-4a1e-b1b1-aea7faeb7f67"
    }'
  ```

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

  url = "https://api.legnext.ai/api/v1/video-diffusion"
  headers = {
      "x-api-key": "YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {
      "prompt": "https://example.com/image.jpg A cinematic shot of ocean waves crashing against rocks",
      "videoType": 1,
      "callback": "https://webhook.site/d0ca59bc-35a6-4a1e-b1b1-aea7faeb7f67"
  }

  response = requests.post(url, headers=headers, json=data)
  result = response.json()
  print(result)
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.legnext.ai/api/v1/video-diffusion', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      prompt: 'https://example.com/image.jpg A cinematic shot of ocean waves crashing against rocks',
      videoType: 1,
      callback: 'https://webhook.site/d0ca59bc-35a6-4a1e-b1b1-aea7faeb7f67'
    })
  });

  const result = await response.json();
  console.log(result);
  ```
</CodeGroup>

## Response

Returns a task object containing the task information.

```json theme={null}
{
    "job_id": "d55cb628-3f71-4be8-bea1-4e01319b6589",
    "model": "midjourney",
    "task_type": "video_diffusion",
    "status": "pending",
    "config": {
        "service_mode": "public",
        "webhook_config": {
            "endpoint": "https://webhook.site/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "secret": ""
        }
    },
    "input": null,
    "output": {
        "video_urls": null,
        "seed": ""
    },
    "meta": {
        "created_at": "",
        "started_at": "",
        "ended_at": "",
        "usage": {
            "type": "point",
            "frozen": 480,
            "consume": 0
        }
    },
    "detail": null,
    "logs": [],
    "error": {
        "code": 0,
        "raw_message": "",
        "message": "",
        "detail": null
    }
}
```

<Note>
  This is the initial success response. Use the `job_id` to check the task status via the [Get Task](/api-reference/task-management/get-task) endpoint to retrieve the completed result with video URLs.
</Note>


## OpenAPI

````yaml POST /v1/video-diffusion
openapi: 3.0.3
info:
  title: Legnext AI API
  description: >
    Comprehensive API for professional image and video generation and
    manipulation using Midjourney AI models.


    ## Authentication

    All API requests require an API key passed in the `x-api-key` header.


    ## Base URL

    `https://api.legnext.ai/api`


    ## Rate Limiting

    API requests are rate limited based on your subscription plan.


    ## Webhook Support

    Most endpoints support optional callbacks. When a callback URL is provided,
    the API will POST the completed job result to that URL.
  version: 1.0.0
  contact:
    name: Legnext Support
    email: support@legnext.ai
    url: https://legnext.ai
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.legnext.ai/api
    description: Production server
security:
  - ApiKeyAuth: []
tags:
  - name: Image Generation
    description: Text to image, image editing, and manipulation endpoints
  - name: Video Generation
    description: Video creation and enhancement endpoints
  - name: Image Enhancement
    description: AI-powered image upscaling and enhancement using Topaz Labs
  - name: Task Management
    description: Job status tracking and retrieval
  - name: Account
    description: Account information and active tasks management
paths:
  /v1/video-diffusion:
    post:
      tags:
        - Video Generation
      summary: Video Diffusion
      description: Generate dynamic videos from text prompts or existing images
      operationId: generateVideo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoDiffusionRequest'
      responses:
        '200':
          description: Video generation task created successfully
          content:
            application/json:
              schema:
                $ref: 6d781e11-1d35-4b14-b58a-515c92e0dd0e
        '400':
          description: Bad Request - Invalid request parameters or malformed request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 400
                message: Invalid request parameters
                raw_message: Invalid request parameters
                detail: null
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 401
                message: Failed to verify api key
                raw_message: ''
                detail: null
        '402':
          description: >-
            Payment Required - Insufficient credits in user account or provider
            account issue
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 402
                message: insufficient quota
                raw_message: insufficient quota
                detail: null
        '403':
          description: Forbidden - Sensitive content detected or permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 403
                message: Forbidden - Sensitive content detected
                raw_message: Forbidden - Sensitive content detected
                detail: null
        '413':
          description: Payload Too Large - File size exceeds maximum limit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 413
                message: File size exceeds maximum limit
                raw_message: file too large
                detail: null
        '422':
          description: Unprocessable Entity - Invalid parameter values or validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 422
                message: Invalid parameter values
                raw_message: Invalid parameter values
                detail: null
        '429':
          description: Too Many Requests - Rate limit exceeded (automatically retried)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 429
                message: rate limit exceeded, please retry later
                raw_message: rate limit exceeded, please retry later
                detail: null
        '500':
          description: Internal Server Error - Server-side error (automatically retried)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: 500
                message: Internal server error
                raw_message: Internal server error
                detail: null
      security:
        - ApiKeyAuth: []
components:
  schemas:
    VideoDiffusionRequest:
      type: object
      properties:
        jobId:
          type: string
          format: uuid
          description: ID of the source image generation task (for existing image mode)
        imageNo:
          type: integer
          minimum: 0
          maximum: 3
          description: Image number to animate (0/1/2/3) (for existing image mode)
        prompt:
          type: string
          minLength: 1
          maxLength: 8192
          description: >-
            Video generation prompt text (required for prompt mode, optional for
            existing image mode)
        videoType:
          type: integer
          minimum: 0
          maximum: 1
          description: Video quality type (0=480p, 1=720p)
        callback:
          type: string
          format: uri
          description: Callback URL for task completion notifications
      anyOf:
        - required:
            - jobId
            - imageNo
        - required:
            - prompt
    Error:
      type: object
      properties:
        code:
          type: integer
          description: Error code
          example: 400
        message:
          type: string
          description: Human-readable error message
          example: Invalid request parameters
        raw_message:
          type: string
          description: Raw error message from service
          example: image_url must start with http:// or https://
        detail:
          type: object
          nullable: true
          description: Additional error details
          example: null
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````