> ## 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 图片生成

> 使用 Vidu 模型基于参考图片生成新图片。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/vidu/vidu-reference-to-image.json POST /vidu/ent/v2/reference2image
openapi: 3.0.1
info:
  title: 图片生成
  version: 1.0.0
servers:
  - url: https://api.powertokens.ai
security: []
paths:
  /vidu/ent/v2/reference2image:
    post:
      summary: 图片生成
      description: 使用 Vidu 模型基于参考图片生成新图片。
      operationId: viduReferenceToImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReferenceToImageRequest'
            examples:
              reference_to_image:
                value:
                  model: viduq2
                  images:
                    - your_image_url1
                    - your_image_url2
                    - your_image_url3
                  prompt: your_prompt
                  seed: 0
                  aspect_ratio: '16:9'
                  resolution: 2K
                  payload: ''
      responses:
        '200':
          description: 提交成功，返回图片任务对象。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReferenceToImageResponse'
              examples:
                success:
                  summary: 提交成功
                  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: 请求参数无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_request:
                  summary: 参数无效
                  value:
                    code: bad_request_body
                    message: 请求体格式错误或字段值无效
                    data: null
        '401':
          description: 认证失败。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: 认证失败
                  value:
                    code: authentication_failed
                    message: API密钥认证失败
                    data: null
        '429':
          description: 超过速率限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                rate_limit:
                  summary: 超过速率限制
                  value:
                    code: rate_limit_exceeded
                    message: 请求过多，请稍后重试
                    data: null
        '500':
          description: 服务器内部错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                server_error:
                  summary: 服务器错误
                  value:
                    code: internal_server_error
                    message: 服务器发生意外错误
                    data: null
      security:
        - BearerAuth: []
components:
  schemas:
    ReferenceToImageRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          enum:
            - viduq2
          description: |-
            模型名称
            - **viduq2**: 支持文生图、图片编辑、参考生图
        images:
          type: array
          minItems: 0
          maxItems: 7
          items:
            type: string
          description: |-
            图像参考

            - **viduq2**: 支持输入 0～7 张图片

            模型将以此参数中传入的图片中的主题为参考，生成与图片中主体一致的视频。

            - 注1：支持传入图片 Base64 编码或图片URL（确保可访问）
            - 注2：图片支持 png、jpeg、jpg、webp格式
            - 注3：图片像素不能小于 128*128，且比例需要小于1:4或者4:1
            - 注4: 且大小不超过50M
            - 注5：请注意，http请求的post body不超过20MB，且编码必须包含适当的内容类型字符串，例如：
            - data:image/png;base64,{base64_encode}
        prompt:
          type: string
          maxLength: 2000
          description: |-
            文本提示词，用于描述图片生成内容，最大长度 2000 字符。
            注意：viduq2 支持仅使用 prompt 生成图片（无需提供参考图片）。
        seed:
          type: integer
          description: |-
            随机种子参数 
            - 当默认不传或者传0时，会使用随机数替代
            - 手动设置则使用设置的种子
        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: |-
            图片宽高比。
            - **viduq2**: 默认 16:9
            - **auto**: 生成的图片宽高比与第一张输入图片保持一致
        resolution:
          type: string
          enum:
            - 1080p
            - 2K
            - 4K
          default: 1080p
          description: |-
            图片分辨率。
            - **viduq2**: 默认 1080p
        payload:
          type: string
          maxLength: 1048576
          description: |-
            透传参数。
            不做处理，仅做数据透传，最大长度 1048576 字符。
        callback_url:
          type: string
          description: >-
            Callback 协议

            需要您在创建任务时主动设置 callback_url，请求方法为 POST，当视频生成任务有状态变化时，Vidu
            将向此地址发送包含任务最新状态的回调请求。回调请求内容结构与查询任务API的返回体一致

            回调返回的"status"包括以下状态：

            - processing 任务处理中

            - success 任务完成（如发送失败，回调三次）

            - failed 任务失败（如发送失败，回调三次）

            Vidu采用回调签名算法进行认证，详情见：回调签名算法
    ReferenceToImageResponse:
      type: object
      properties:
        task_id:
          type: string
          description: 任务ID。
        state:
          type: string
          enum:
            - created
            - queueing
            - processing
            - success
            - failed
          description: |-
            任务处理状态：
            - **created**: 任务创建成功
            - **queueing**: 任务排队中
            - **processing**: 任务处理中
            - **success**: 生成成功
            - **failed**: 任务失败
        model:
          type: string
          description: 本次调用使用的模型参数。
        prompt:
          type: string
          description: 本次调用使用的文本提示词。
        images:
          type: array
          items:
            type: string
          description: 本次调用使用的图片。
        seed:
          type: integer
          description: 本次调用使用的随机种子参数。
        aspect_ratio:
          type: string
          description: 本次调用使用的宽高比参数。
        resolution:
          type: string
          description: 本次调用使用的分辨率参数。
        credits:
          type: integer
          description: 本次调用消耗的积分。
        callback_url:
          type: string
          description: 本次调用使用的回调URL参数。
        payload:
          type: string
          description: 本次调用使用的透传参数。
        created_at:
          type: string
          format: date-time
          description: 任务创建时间。
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: 错误代码。
        message:
          type: string
          description: 错误消息。
        data:
          type: object
          nullable: true
          description: 附加错误数据。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````