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

# Create task

> Creates a MAGI-2 video generation task: `model` picks the model, the generation parameters go in `input`, and the optional `callBackUrl` receives a completion callback. On success `data.taskId` is returned and the task runs asynchronously; poll the query endpoint for the result. Every response has HTTP status 200; check `code`.



## OpenAPI

````yaml /openapi/en/magi-2-reference-to-video.json post /api/v1/jobs/createTask
openapi: 3.1.0
info:
  description: >-
    MAGI-2 reference-to-video: a 4–30 second 1080p video with sound guided by
    reference images, videos and audio, keeping the look, motion and voice of
    the references.
  title: MAGI-2 Reference to Video
  version: v1
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: MAGI-2 Reference to Video
paths:
  /api/v1/jobs/createTask:
    post:
      tags:
        - MAGI-2 Reference to Video
      summary: Create task
      description: >-
        Creates a MAGI-2 video generation task: `model` picks the model, the
        generation parameters go in `input`, and the optional `callBackUrl`
        receives a completion callback. On success `data.taskId` is returned and
        the task runs asynchronously; poll the query endpoint for the result.
        Every response has HTTP status 200; check `code`.
      operationId: magi2CreateTask
      requestBody:
        content:
          application/json:
            examples:
              Character and voice reference:
                description: >-
                  `reference_image_urls` gives the character's look and
                  `reference_audio_urls` the voice; 16:9, 5 seconds.
                summary: Character and voice reference
                value:
                  model: magi-2/reference-to-video
                  input:
                    prompt: >-
                      Use the woman in the reference image as the lead. She
                      stands on a rooftop after the rain, turns to the camera
                      and says: "We finally made it." Her voice follows the
                      reference audio
                    reference_image_urls:
                      - https://cdn.example.com/lead.jpg
                    reference_audio_urls:
                      - https://cdn.example.com/voice.wav
                    duration: 5
                    aspect_ratio: '16:9'
                    resolution: 1080p
                    generate_audio: true
              Motion reference video:
                description: >-
                  Only `reference_video_urls`: new footage that follows the
                  motion and camera work of the reference video; 9:16, 10
                  seconds, with a completion callback.
                summary: Motion reference video
                value:
                  model: magi-2/reference-to-video
                  callBackUrl: https://your-domain.com/api/callback
                  input:
                    prompt: >-
                      A shiba inu in a spacesuit performs the dance from the
                      reference video on the lunar surface, matching its moves
                      and camera work, with Earth hanging in the distant sky
                    reference_video_urls:
                      - https://cdn.example.com/dance.mp4
                    duration: 10
                    aspect_ratio: '9:16'
              Several reference images:
                description: >-
                  A character, a product and a scene from three reference images
                  in one shot, each keeping its look; 1:1, 6 seconds.
                summary: Several reference images
                value:
                  model: magi-2/reference-to-video
                  input:
                    prompt: >-
                      The young man from the first image sits by the window of
                      the café in the third image, puts on the headphones from
                      the second image and closes his eyes with a smile. Sound:
                      soft jazz and café ambience
                    reference_image_urls:
                      - https://cdn.example.com/man.jpg
                      - https://cdn.example.com/headphones.png
                      - https://cdn.example.com/cafe.webp
                    duration: 6
                    aspect_ratio: '1:1'
            schema:
              $ref: >-
                #/components/schemas/Magi2CreateTaskRequestMagi2ReferenceToVideoInput
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                Created:
                  description: '`data.taskId` is the task ID.'
                  summary: Created
                  value:
                    code: 200
                    msg: success
                    data:
                      taskId: 4b9e2d7a0c1f48e6a3d5b7c9e1f20a84
                Invalid request (422):
                  description: The request is invalid; no task is created or charged.
                  summary: Invalid request (422)
                  value:
                    code: 422
                    msg: input.duration must be an integer between 4 and 30.
                    data: null
                Unauthorized (401):
                  description: Missing or invalid API Key.
                  summary: Unauthorized (401)
                  value:
                    code: 401
                    msg: >-
                      Unauthorized - Authentication credentials are missing or
                      invalid
                    data: null
                Insufficient balance (402):
                  description: The balance does not cover the task.
                  summary: Insufficient balance (402)
                  value:
                    code: 402
                    msg: >-
                      Insufficient Credits - Account does not have enough
                      credits to perform the operation
                    data: null
                Rate limited (429):
                  description: Rate limit exceeded; retry later.
                  summary: Rate limited (429)
                  value:
                    code: 429
                    msg: >-
                      Rate Limited - Request limit has been exceeded for this
                      resource
                    data: null
                Server error (500):
                  description: >-
                    The service is temporarily unavailable; retry later. Not
                    charged.
                  summary: Server error (500)
                  value:
                    code: 500
                    msg: >-
                      Server Error - An unexpected error occurred while
                      processing the request
                    data: null
              schema:
                $ref: '#/components/schemas/Magi2CreateTaskResponse'
          description: >-
            Always HTTP 200. With `code` `200` the task was created and
            `data.taskId` is its ID; any other `code` is an error with the
            reason in `msg` and `data` `null`.
          headers:
            X-Request-Id:
              description: ID of this request; include it when reporting issues.
              schema:
                type: string
components:
  schemas:
    Magi2CreateTaskRequestMagi2ReferenceToVideoInput:
      additionalProperties: false
      description: Request body of createTask.
      properties:
        model:
          default: magi-2/reference-to-video
          description: >-
            Model name; it decides the fields of `input`.


            **Allowed values:**

            - `magi-2/reference-to-video`: MAGI-2 reference-to-video (reference
            images, videos and audio)
          enum:
            - magi-2/reference-to-video
          type: string
        callBackUrl:
          description: >-
            Optional URL that receives a callback when the task finishes
            (success or failure); it must be a public `http` / `https` URL.
            Recommended in production; you can also just poll the query
            endpoint. See Task callback for the body and signature.
          type: string
        input:
          $ref: '#/components/schemas/Magi2ReferenceToVideoInput'
          description: Generation parameters; the fields depend on `model`.
      required:
        - model
        - input
      type: object
    Magi2CreateTaskResponse:
      additionalProperties: false
      description: Response of createTask; always HTTP 200.
      properties:
        code:
          description: >-
            Result code:

            - `200`: success

            - `401`: missing or invalid API Key

            - `402`: insufficient balance

            - `404`: the model does not exist or is not enabled

            - `405`: wrong HTTP method

            - `422`: invalid request, with the reason in `msg`; no task is
            created or charged

            - `429`: too many requests; retry later

            - `455`: service under maintenance

            - `500`: server error; retry later

            - `501`: generation failed

            - `505`: feature disabled
          format: int64
          type: integer
        msg:
          description: 'Message: `success`, or the English reason of an error.'
          type: string
        data:
          $ref: '#/components/schemas/Magi2CreateTaskData'
          description: The task on success; `null` on error.
      required:
        - code
        - msg
        - data
      type: object
    Magi2ReferenceToVideoInput:
      additionalProperties: false
      description: >-
        Generation parameters of `magi-2/reference-to-video`. Provide at least
        one of `reference_image_urls`, `reference_video_urls` and
        `reference_audio_urls`.
      properties:
        prompt:
          description: >-
            Prompt, required, 1–15,000 characters. Describe the subject, action,
            camera movement and sound and say what each reference is for (e.g.
            "use the person in the first image as the lead"), with dialogue in
            quotes.
          maxLength: 15000
          minLength: 1
          type: string
        reference_image_urls:
          description: >-
            Reference image URLs, up to 10, JPG, PNG or WEBP at public `http` /
            `https` URLs. They keep the look of people, products and scenes.
          items:
            type: string
          maxItems: 10
          type: array
        reference_video_urls:
          description: >-
            Reference video URLs, up to 5, MP4 or MOV, 2–30 seconds each and 30
            seconds in total, at public `http` / `https` URLs. They guide motion
            and camera work.
          items:
            type: string
          maxItems: 5
          type: array
        reference_audio_urls:
          description: >-
            Reference audio URLs, up to 5, MP3 or WAV, 2–30 seconds each and 30
            seconds in total, at public `http` / `https` URLs. They guide the
            voice or sound.
          items:
            type: string
          maxItems: 5
          type: array
        duration:
          default: 5
          description: >-
            Video duration in seconds, an integer from `4` to `30`; default `5`.
            Billed per second.
          format: int64
          maximum: 30
          minimum: 4
          type: integer
        aspect_ratio:
          default: '16:9'
          description: >-
            Aspect ratio of the output video; default `16:9`.


            **Allowed values:**

            - `21:9`: Ultra-wide cinema

            - `16:9`: Landscape widescreen (default), for film and horizontal
            video

            - `4:3`: Classic landscape

            - `1:1`: Square

            - `3:4`: Classic portrait

            - `9:16`: Full-screen portrait, for mobile short video
          enum:
            - '21:9'
            - '16:9'
            - '4:3'
            - '1:1'
            - '3:4'
            - '9:16'
          type: string
        resolution:
          default: 1080p
          description: |-
            Output resolution; only `1080p` (the default) is available.

            **Allowed values:**
            - `1080p`: 1080p Full HD (default)
          enum:
            - 1080p
          type: string
        generate_audio:
          default: true
          description: >-
            Whether to generate sound with the picture (dialogue, sound effects
            and ambience); default `true`. With `false` the video is silent; the
            price is the same.
          type: boolean
        seed:
          description: >-
            Random seed, `0`–`2147483647`; random when omitted. The same
            parameters and seed help reproduce a result.
          format: int64
          maximum: 2147483647
          minimum: 0
          type: integer
      required:
        - prompt
      type: object
    Magi2CreateTaskData:
      additionalProperties: false
      description: The created task.
      properties:
        taskId:
          description: Task ID (32 hex digits), used to query the task.
          type: string
      required:
        - taskId
      type: object
  securitySchemes:
    bearerAuth:
      description: >-
        API Key created in the DreamTo console, sent as `Authorization: Bearer
        <API Key>`.
      scheme: bearer
      type: http

````

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