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

# Image-to-Video API Reference - Magic Hour Docs

> **What this API does**

Create the same Image To Video you can make in the browser, but programmatically, so you can automate it, run it at scale, or connect it to your own app or workflow.
    
**Good for**
- Automation and batch processing  
- Adding image to video into apps, pipelines, or tools  

**How it works (3 steps)**
1) Upload your inputs (video, image, or audio) with [Generate Upload URLs](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls) and copy the `file_path`.  
2) Send a request to create a image to video job with the basic fields.  
3) Check the job status until it's `complete`, then download the result from `downloads`.

**Key options**
- Inputs: usually a file, sometimes a YouTube link, depending on project type  
- Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes  
- Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt  

**Cost**  
Credits are only charged for the frames that actually render. You'll see an estimate when the job is queued, and the final total after it's done.

For detailed examples, see the [product page](https://magichour.ai/products/image-to-video).



## OpenAPI

````yaml post /v1/image-to-video
openapi: 3.0.2
info:
  title: Magic Hour API
  version: beta
  description: >

    Magic Hour provides an API (beta) that can be integrated into your own
    application to generate videos and images using AI. 


    Webhook documentation can be found
    [here](https://magichour.ai/docs/webhook).


    If you have any questions, please reach out to us via
    [discord](https://discord.gg/JX5rgsZaJp).


    # Authentication


    Every request requires an API key.


    To get started, first generate your API key
    [here](https://magichour.ai/settings/developer).


    Then, add the `Authorization` header to the request.


    | Key | Value |

    |-|-|

    | Authorization | Bearer mhk_live_apikey |


    > **Warning**: any API call that renders a video will utilize credits in
    your account.
  termsOfService: https://magichour.ai/terms-of-service
servers:
  - url: https://api.magichour.ai
security: []
tags:
  - name: Files
    description: API related to uploading assets used for video generation
  - name: Image Projects
    description: API related to image projects
  - name: Video Projects
    description: API related to video projects
  - name: Audio Projects
    description: API related to audio projects
paths:
  /v1/image-to-video:
    post:
      tags:
        - Video Projects
      summary: Image-to-Video
      description: >-
        **What this API does**


        Create the same Image To Video you can make in the browser, but
        programmatically, so you can automate it, run it at scale, or connect it
        to your own app or workflow.
            
        **Good for**

        - Automation and batch processing  

        - Adding image to video into apps, pipelines, or tools  


        **How it works (3 steps)**

        1) Upload your inputs (video, image, or audio) with [Generate Upload
        URLs](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls)
        and copy the `file_path`.  

        2) Send a request to create a image to video job with the basic
        fields.  

        3) Check the job status until it's `complete`, then download the result
        from `downloads`.


        **Key options**

        - Inputs: usually a file, sometimes a YouTube link, depending on project
        type  

        - Resolution: free users are limited to 576px; higher plans unlock HD
        and larger sizes  

        - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or
        a text prompt  


        **Cost**  

        Credits are only charged for the frames that actually render. You'll see
        an estimate when the job is queued, and the final total after it's done.


        For detailed examples, see the [product
        page](https://magichour.ai/products/image-to-video).
      operationId: imageToVideo.createVideo
      parameters: []
      requestBody:
        required: true
        description: Body
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Give your video a custom name for easy identification.
                  example: My Image To Video video
                  default: Image To Video - dateTime
                end_seconds:
                  type: number
                  minimum: 1
                  maximum: 60
                  description: >
                    The total duration of the output video in seconds. Supported
                    durations depend on the chosen model:


                    * **`ltx-2.3`**: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25,
                    30

                    * **`wan-2.2`**: 3, 4, 5, 6, 7, 8, 9, 10, 15

                    * **`kling-2.5`**: 5, 10

                    * **`kling-3.0`**: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                    15

                    * **`veo3.1-lite`**: 8, 16, 24, 32, 40, 48, 56

                    * **`veo3.1`**: 4, 6, 8, 16, 24, 32, 40, 48, 56

                    * **`seedance`**: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

                    * **`seedance-2.0`**: 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                    15

                    * **`sora-2`**: 4, 8, 12, 24, 36, 48, 60
                  format: float
                  example: 5
                model:
                  default: default
                  type: string
                  enum:
                    - default
                    - ltx-2
                    - ltx-2.3
                    - wan-2.2
                    - seedance
                    - seedance-2.0
                    - kling-2.5
                    - kling-3.0
                    - veo3.1
                    - veo3.1-lite
                    - sora-2
                    - kling-1.6
                    - kling-2.5-audio
                    - veo3.1-audio
                  description: >-
                    The AI model to use for video generation.


                    * `default`: uses our currently recommended model for
                    general use. For paid tiers, defaults to `kling-3.0`. For
                    free tiers, it defaults to `ltx-2.3`.

                    * `ltx-2.3`: Fast iteration with audio, lip-sync, and end
                    frame

                    * `wan-2.2`: Fast, strong visuals with effects

                    * `kling-2.5`: Motion, action, and camera control

                    * `kling-3.0`: Cinematic, multi-scene storytelling

                    * `veo3.1-lite`: Fast, affordable, high-quality

                    * `veo3.1`: Realistic visuals and prompt adherence

                    * `seedance`: Fast iteration and start/end frames

                    * `seedance-2.0`: State-of-the-art quality and consistency

                    * `sora-2`: Story-first concepts and creativity


                    If you specify the deprecated model value that includes the
                    `-audio` suffix, this will be the same as included `audio`
                    as `true`.
                  example: kling-3.0
                resolution:
                  type: string
                  enum:
                    - 480p
                    - 720p
                    - 1080p
                    - 4k
                  example: 720p
                  description: >
                    Controls the output video resolution. Defaults to `720p` on
                    paid tiers and `480p` on free tiers.


                    * **`ltx-2.3`**: Supports 480p, 720p, 1080p.

                    * **`wan-2.2`**: Supports 480p, 720p, 1080p.

                    * **`kling-2.5`**: Supports 720p, 1080p.

                    * **`kling-3.0`**: Supports 720p, 1080p, 4k.

                    * **`veo3.1-lite`**: Supports 720p, 1080p.

                    * **`veo3.1`**: Supports 720p, 1080p.

                    * **`seedance`**: Supports 480p, 720p, 1080p.

                    * **`seedance-2.0`**: Supports 480p, 720p.

                    * **`sora-2`**: Supports 720p.
                audio:
                  type: boolean
                  description: >
                    Whether to include audio in the video. Defaults to `false`
                    if not specified.


                    Audio support varies by model:

                    * **`ltx-2.3`**: Toggle-able: no additional credits for
                    audio

                    * **`wan-2.2`**: Not supported

                    * **`kling-2.5`**: Toggle-able: no additional credits for
                    audio

                    * **`kling-3.0`**: Toggle-able: audio adds extra credits
                    when enabled

                    * **`veo3.1-lite`**: Toggle-able: audio adds extra credits
                    when enabled

                    * **`veo3.1`**: Toggle-able: audio adds extra credits when
                    enabled

                    * **`seedance`**: Not supported

                    * **`seedance-2.0`**: Toggle-able: no additional credits for
                    audio

                    * **`sora-2`**: Toggle-able: no additional credits for audio
                  example: true
                style:
                  type: object
                  properties:
                    prompt:
                      type: string
                      example: a dog running
                      description: The prompt used for the video.
                  description: Attributed used to dictate the style of the output
                assets:
                  type: object
                  properties:
                    image_file_path:
                      type: string
                      minLength: 1
                      description: >
                        The path of the image file. This value is either

                        - a direct URL to the video file

                        - `file_path` field from the response of the [upload
                        urls
                        API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls).


                        See the [file upload
                        guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file)
                        for details.
                      example: api-assets/id/1234.png
                    end_image_file_path:
                      type: string
                      minLength: 1
                      description: |
                        The image to use as the last frame of the video.

                        * **`ltx-2.3`**: Supports 480p, 720p, 1080p.
                        * **`wan-2.2`**: Not supported
                        * **`kling-2.5`**: Supports 1080p.
                        * **`kling-3.0`**: Supports 720p, 1080p, 4k.
                        * **`veo3.1-lite`**: Not supported
                        * **`veo3.1`**: Not supported
                        * **`seedance`**: Supports 480p, 720p, 1080p.
                        * **`seedance-2.0`**: Supports 480p, 720p.
                        * **`sora-2`**: Not supported
                      example: api-assets/id/1234.png
                  required:
                    - image_file_path
                  description: >-
                    Provide the assets for image-to-video. Sora 2 only supports
                    images with an aspect ratio of `9:16` or `16:9`.
              required:
                - end_seconds
                - assets
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: cuid-example
                    description: >-
                      Unique ID of the video. Use it with the [Get video Project
                      API](https://docs.magichour.ai/api-reference/video-projects/get-video-details)
                      to fetch status and downloads.
                  credits_charged:
                    type: integer
                    description: >-
                      The amount of credits deducted from your account to
                      generate the video. If the status is not 'complete', this
                      value is an estimate and may be adjusted upon completion
                      based on the actual FPS of the output video. 


                      If video generation fails, credits will be refunded, and
                      this field will be updated to include the refund.
                    example: 450
                required:
                  - id
                  - estimated_frame_cost
                  - credits_charged
                description: Success
        '400':
          description: Invalid Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
                description: The request is invalid
                example:
                  message: Missing request body
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    enum:
                      - Unauthorized
                required:
                  - message
                description: The request is not properly authenticated
                example:
                  message: Unauthorized
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
                description: The request requires payment
                example:
                  message: Payment required
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    enum:
                      - Not Found
                required:
                  - message
                description: Requested resource is not found
                example:
                  message: Not Found
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Unable to create video
                required:
                  - message
                description: Unprocessable Entity
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: python
          source: |-
            from magic_hour import Client
            from os import getenv

            client = Client(token=getenv("API_TOKEN"))
            res = client.v1.image_to_video.generate(
                assets={"image_file_path": "/path/to/1234.png"},
                end_seconds=5.0,
                name="Image To Video video",
                resolution="720p",
                wait_for_completion=True,
                download_outputs=True,
                download_directory="."
            )
        - lang: javascript
          source: |-
            import { Client } from "magic-hour";

            const client = new Client({ token: process.env["API_TOKEN"]!! });
            const res = await client.v1.imageToVideo.generate(
              {
                assets: { imageFilePath: "/path/to/1234.png" },
                endSeconds: 5.0,
                name: "Image To Video video",
                resolution: "720p",
              },
              {
                waitForCompletion: true,
                downloadOutputs: true,
                downloadDirectory: ".",
              },
            );
        - lang: go
          source: "package main\n\nimport (\n\tos \"os\"\n\n\tsdk \"github.com/magichourhq/magic-hour-go/client\"\n\tnullable \"github.com/magichourhq/magic-hour-go/nullable\"\n\timage_to_video \"github.com/magichourhq/magic-hour-go/resources/v1/image_to_video\"\n\ttypes \"github.com/magichourhq/magic-hour-go/types\"\n)\n\nfunc main() {\n\tclient := sdk.NewClient(\n\t\tsdk.WithBearerAuth(os.Getenv(\"API_TOKEN\")),\n\t)\n\tres, err := client.V1.ImageToVideo.Create(image_to_video.CreateRequest{\n\t\tAssets: types.V1ImageToVideoCreateBodyAssets{\n\t\t\tEndImageFilePath: nullable.NewValue(\"api-assets/id/1234.png\"),\n\t\t\tImageFilePath:    \"api-assets/id/1234.png\",\n\t\t},\n\t\tAudio:      nullable.NewValue(true),\n\t\tEndSeconds: 5.0,\n\t\tModel:      nullable.NewValue(types.V1ImageToVideoCreateBodyModelEnumKling30),\n\t\tName:       nullable.NewValue(\"My Image To Video video\"),\n\t\tResolution: nullable.NewValue(types.V1ImageToVideoCreateBodyResolutionEnum720p),\n\t})\n}"
        - lang: rust
          source: |-
            let client = magic_hour::Client::default()
                .with_bearer_auth(&std::env::var("API_TOKEN").unwrap());
            let res = client
                .v1()
                .image_to_video()
                .create(magic_hour::resources::v1::image_to_video::CreateRequest {
                    assets: magic_hour::models::V1ImageToVideoCreateBodyAssets {
                        end_image_file_path: Some("api-assets/id/1234.png".to_string()),
                        image_file_path: "api-assets/id/1234.png".to_string(),
                    },
                    audio: Some(true),
                    end_seconds: 5.0,
                    model: Some(magic_hour::models::V1ImageToVideoCreateBodyModelEnum::Kling30),
                    name: Some("My Image To Video video".to_string()),
                    resolution: Some(
                        magic_hour::models::V1ImageToVideoCreateBodyResolutionEnum::Enum720p,
                    ),
                    ..Default::default()
                })
                .await;
        - lang: curl
          source: |-
            curl --request POST \
                 --url https://api.magichour.ai/v1/image-to-video \
                 --header 'accept: application/json' \
                 --header 'authorization: Bearer <token>' \
                 --header 'content-type: application/json' \
                 --data '
            {
              "name": "My Image To Video video",
              "end_seconds": 5,
              "model": "kling-3.0",
              "resolution": "720p",
              "audio": true,
              "style": {
                "prompt": "a dog running"
              },
              "assets": {
                "image_file_path": "api-assets/id/1234.png",
                "end_image_file_path": "api-assets/id/1234.png"
              }
            }
            '
        - lang: php
          source: |-
            <?php

            $curl = curl_init();

            curl_setopt_array($curl, [
              CURLOPT_URL => "https://api.magichour.ai/v1/image-to-video",
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => "",
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 30,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => "POST",
              CURLOPT_POSTFIELDS => json_encode([
                'name' => 'My Image To Video video',
                'end_seconds' => 5,
                'model' => 'kling-3.0',
                'resolution' => '720p',
                'audio' => true,
                'style' => [
                    'prompt' => 'a dog running'
                ],
                'assets' => [
                    'image_file_path' => 'api-assets/id/1234.png',
                    'end_image_file_path' => 'api-assets/id/1234.png'
                ]
              ]),
              CURLOPT_HTTPHEADER => [
                "accept: application/json",
                "authorization: Bearer <token>",
                "content-type: application/json"
              ],
            ]);

            $response = curl_exec($curl);
            $err = curl_error($curl);

            curl_close($curl);

            if ($err) {
              echo "cURL Error #:" . $err;
            } else {
              echo $response;
            }
        - lang: java
          source: >-
            HttpResponse<String> response =
            Unirest.post("https://api.magichour.ai/v1/image-to-video")
              .header("accept", "application/json")
              .header("content-type", "application/json")
              .header("authorization", "Bearer <token>")
              .body("{\"name\":\"My Image To Video video\",\"end_seconds\":5,\"model\":\"kling-3.0\",\"resolution\":\"720p\",\"audio\":true,\"style\":{\"prompt\":\"a dog running\"},\"assets\":{\"image_file_path\":\"api-assets/id/1234.png\",\"end_image_file_path\":\"api-assets/id/1234.png\"}}")
              .asString();
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <api_key>`, where
        `<api_key>` is your API key. To get your API key, go to [Developer
        Hub](https://magichour.ai/developer?tab=api-keys) and click "Create new
        API Key".

````