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

# Vidu Reference-to-Image

> Generate images using the Vidu model based on reference images.



## OpenAPI

````yaml api-reference/en/zmodelImage/vidu/vidu-reference-to-image.json POST /vidu/ent/v2/reference2image
openapi: 3.0.1
info:
  title: Vidu Reference-to-Image
  version: 1.0.0
servers:
  - url: https://api.powertokens.ai
security: []
paths:
  /vidu/ent/v2/reference2image:
    post:
      summary: Vidu Reference-to-Image
      description: Generate images using the Vidu model based on reference images.
      operationId: viduReferenceToImageEn
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReferenceToImageRequest'
            examples:
              text_to_image:
                summary: Pure text-to-image (viduq2)
                value:
                  model: viduq2
                  prompt: A cute kitten playing on grass under sunny weather
                  aspect_ratio: '16:9'
                  resolution: 4K
                  seed: 42
              reference_to_image:
                summary: Reference-to-image
                value:
                  model: viduq2
                  images:
                    - https://example.com/reference1.png
                    - https://example.com/reference2.png
                  prompt: Maintain character style and generate a new scene image
                  aspect_ratio: '1:1'
                  resolution: 2K
              image_editing:
                summary: Image editing
                value:
                  model: viduq2
                  images:
                    - data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAE...
                  prompt: Change the background to night sky with stars and add a moon
                  aspect_ratio: auto
                  resolution: 1080p
      responses:
        '200':
          description: Submission successful, returns an image task object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReferenceToImageResponse'
              examples:
                success:
                  summary: Submission successful
                  value:
                    task_id: your_task_id_here
                    state: created
                    model: viduq2
                    images:
                      - your_image_url1
                      - your_image_url2
                      - your_image_url3
                    prompt: your_prompt
                    seed: 0
                    aspect_ratio: '16:9'
                    resolution: 2K
                    payload: ''
                    credits: 2
                    created_at: '2025-09-08T09:53:22.083033428Z'
        '400':
          description: Invalid request parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_request:
                  summary: Invalid parameters
                  value:
                    code: bad_request_body
                    message: Request body format error or invalid field values
                    data: null
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Authentication failed
                  value:
                    code: authentication_failed
                    message: API key authentication failed
                    data: null
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                rate_limit:
                  summary: Rate limit exceeded
                  value:
                    code: rate_limit_exceeded
                    message: Too many requests, please try again later
                    data: null
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                server_error:
                  summary: Server error
                  value:
                    code: internal_server_error
                    message: An unexpected error occurred on the server
                    data: null
      security:
        - BearerAuth: []
components:
  schemas:
    ReferenceToImageRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          enum:
            - viduq2
          description: >-
            Image generation model name.

            - **viduq2**: Supports text-to-image, image editing, and
            reference-to-image with better results
        images:
          type: array
          minItems: 0
          maxItems: 7
          items:
            type: string
          description: >-
            Reference image list.

            - **viduq2**: Supports input of 0 to 7 images

            The model will generate an image with consistent subjects based on
            the input images.

            - Supports Base64 or URL format (URL must be accessible)

            - Supported formats: png, jpeg, jpg, webp

            - Image resolution must be no smaller than 128×128

            - Aspect ratio must be between 1:4 and 4:1

            - Single image size must not exceed 50MB

            - The post body of the HTTP request should not exceed 20MB, and
            encoding must include proper content type string

            - Base64 format example: `data:image/png;base64,{base64_encode}`
        prompt:
          type: string
          maxLength: 2000
          description: >-
            Text prompt for describing image generation content, with a maximum
            length of 2000 characters.

            Note: viduq2 supports generating images using only prompt (without
            reference images).
        seed:
          type: integer
          description: |-
            Random seed.
            - Defaults to a random seed number
            - Manually set values will override the default random seed
        aspect_ratio:
          type: string
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
            - '3:4'
            - '4:3'
            - '21:9'
            - '2:3'
            - '3:2'
            - auto
          default: '16:9'
          description: >-
            Image aspect ratio.

            - **viduq2**: Default 16:9, optional values: 16:9, 9:16, 1:1, 3:4,
            4:3, 21:9, 2:3, 3:2

            - **auto**: Generated image aspect ratio is consistent with the
            first input image
        resolution:
          type: string
          enum:
            - 1080p
            - 2K
            - 4K
          default: 1080p
          description: |-
            Image resolution.
            - **viduq2**: Default 1080p, optional values: 1080p, 2K, 4K
        payload:
          type: string
          maxLength: 1048576
          description: >-
            Transparent transmission parameters.

            No processing, only data transmission, with a maximum length of
            1048576 characters.
        callback_url:
          type: string
          description: >-
            Callback

            When creating a task, you need to actively set the callback_url with
            a POST request. When the video generation task changes its status,
            Vidu will send a callback request to this URL, containing the latest
            status of the task. The structure of the callback request content
            will be the same as the return body of the Get Generation API.

            The "status" in the callback response includes the following states:

            - processing: Task is being processed.

            - success: Task is completed (if sending fails, it will retry the
            callback three times).

            - failed: Task failed (if sending fails, it will retry the callback
            three times).

            Vidu uses a callback signature algorithm for verification, check out
            the details here: Callback Signature
    ReferenceToImageResponse:
      type: object
      properties:
        task_id:
          type: string
          description: Task ID.
        state:
          type: string
          enum:
            - created
            - queueing
            - processing
            - success
            - failed
          description: |-
            Task processing state:
            - **created**: Task created successfully
            - **queueing**: Task in queue
            - **processing**: Task processing
            - **success**: Generation successful
            - **failed**: Task failed
        model:
          type: string
          description: Model parameter used for this call.
        prompt:
          type: string
          description: Text prompt used for this call.
        images:
          type: array
          items:
            type: string
          description: Images used for this call.
        seed:
          type: integer
          description: Random seed parameter used for this call.
        aspect_ratio:
          type: string
          description: Aspect ratio parameter used for this call.
        resolution:
          type: string
          description: Resolution parameter used for this call.
        credits:
          type: integer
          description: Credits consumed for this call.
        callback_url:
          type: string
          description: Callback URL parameter used for this call.
        payload:
          type: string
          description: Payload parameter used for this call.
        created_at:
          type: string
          format: date-time
          description: Task creation time.
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code.
        message:
          type: string
          description: Error message.
        data:
          type: object
          nullable: true
          description: Additional error data.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Pass `Authorization: Bearer <token>` in the request header.'

````