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

# Create Video Agent Task

> Use this API to create video Agent tasks.



## OpenAPI

````yaml POST /v1/video_template_generation
openapi: 3.1.0
info:
  title: MiniMax API
  description: MiniMax video template generation API
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.minimax.io
security:
  - bearerAuth: []
paths:
  /v1/video_template_generation:
    post:
      tags:
        - Video
      summary: Video Template Generation
      operationId: videoTemplateGeneration
      parameters:
        - name: Content-Type
          in: header
          required: true
          description: >-
            The media type of the request body. Must be set to
            `application/json` to ensure the data is sent in JSON format.
          schema:
            type: string
            enum:
              - application/json
            default: application/json
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoTemplateGenerationReq'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoTemplateGenerationResp'
components:
  schemas:
    VideoTemplateGenerationReq:
      type: object
      required:
        - template_id
      properties:
        template_id:
          type: string
          description: >-
            The ID of the video template. For details on available IDs and
            required inputs, see [Video Agent Template
            List](/faq/video-agent-templates).
        text_inputs:
          type: array
          description: >-
            An array of text inputs used to fill the text fields in the
            template. The requirements vary by template.
          items:
            $ref: '#/components/schemas/TextInput'
        media_inputs:
          type: array
          description: >-
            An array of media inputs (e.g., images) used to fill the media
            fields in the template. The requirements vary by template.
          items:
            $ref: '#/components/schemas/MediaInput'
        callback_url:
          type: string
          description: >-
            A callback URL to receive task status updates. You can configure
            this parameter to receive asynchronous notifications when the task
            status changes.


            **1. URL Verification:** Once configured, the MiniMax server will
            send a `POST` request to the `callback_url` containing a `challenge`
            field. Your server must return the same `challenge` value within 3
            seconds to complete verification.


            **2. Status Updates:** After verification, MiniMax will push the
            latest task status to the callback URL whenever the task state
            changes. The pushed data structure is identical to the response body
            of the task query API.


            The `status` field in the callback includes the following states:

            - `processing` - In progress

            - `success` - Completed successfully

            - `failed` - Failed


            Callback Service Example:

            ```python dark

            from fastapi import FastAPI, HTTPException, Request

            from fastapi.middleware.cors import CORSMiddleware

            import json


            app = FastAPI()


            @app.post("/get_callback")

            async def get_callback(request: Request):
                try:
                    json_data = await request.json()
                    challenge = json_data.get("challenge")
                    if challenge is not None:
                        # Verification request, return challenge as is
                        return {"challenge": challenge}
                    else:
                        # Callback request, handle your own logic here
                        # Example payload:
                        # {
                        #     "task_id": "115334141465231360",
                        #     "status": "Success",
                        #     "file_id": "205258526306433",
                        #     "base_resp": {
                        #         "status_code": 0,
                        #         "status_msg": "success"
                        #     }
                        # }
                        return {"status": "success"}
                except Exception as e:
                    raise HTTPException(status_code=500, detail=str(e))

            if __name__ == "__main__":
                import uvicorn
                uvicorn.run(
                    app,  # required
                    host="0.0.0.0",  # required
                    port=8000,  # required, can be customized
                    # ssl_keyfile="yourname.yourDomainName.com.key", # optional, enable SSL if needed
                    # ssl_certfile="yourname.yourDomainName.com.crt", # optional, enable SSL if needed
                )
            ```
      example:
        template_id: '393769180141805569'
        media_inputs:
          - value: >-
              https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg
        text_inputs:
          - value: Lion
    VideoTemplateGenerationResp:
      type: object
      properties:
        task_id:
          type: string
          description: The unique ID of the task, used to query task status later.
        base_resp:
          $ref: '#/components/schemas/BaseResp'
      example:
        task_id: '401047179385389059'
        base_resp:
          status_code: 0
          status_msg: success
    TextInput:
      type: object
      required:
        - value
      properties:
        value:
          type: string
          description: The text content to be filled in.
    MediaInput:
      type: object
      required:
        - value
      properties:
        value:
          type: string
          description: >-
            The image file. Supports both public URLs and Base64-encoded Data
            URLs (`data:image/jpeg;base64,...`).


            Image requirements:

            - Format: JPG, JPEG, PNG, WebP

            - Size: less than 20MB

            - Dimensions: shorter side must be greater than 300px

            - Aspect ratio: between 2:5 and 5:2
    BaseResp:
      type: object
      description: Contains the status code and message.
      properties:
        status_code:
          type: integer
          format: int32
          description: >-
            Status code and meanings:


            `0`: Request successful

            `1002`: Rate limit triggered, please try again later

            `1004`: Authentication failed, check if the API Key is correct

            `1008`: Insufficient account balance

            `1026`: Text contains sensitive content, please adjust

            `2013`: Invalid parameters, check if inputs meet requirements

            `2049`: Invalid API Key, please verify


            For more information, please refer to the [Error Code
            Reference](/api-reference/errorcode).
        status_msg:
          type: string
          description: Detailed error description.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        `HTTP: Bearer Auth`

        - Security Scheme Type: http

        - HTTP Authorization Scheme: `Bearer API_key`, can be found in [Account
        Management>API
        Keys](https://platform.minimax.io/user-center/basic-information/interface-key).

````