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

# Recraft V4.1 文生图

> Recraft V4.1 文生图 API 把最多 10,000 个字符的提示词生成一张图片，支持 5 种宽高比、最多 10 个配色和背景色。

> [!TIP]
>
> 1. 提交后会返回 `task_id`。如果提供了 `callback_url`，当任务状态变为 `finished` 或 `failed` 时，系统会向 `callback_url` 发送 POST 请求。
> 2. 无论是否提供 `callback_url`，都可以通过统一的[查询任务状态](https://docs.vidgo.ai/zh/api-manual/task-management/status.md)接口获取结果。

Recraft V4.1 文生图根据文本提示词每次生成一张图片。Recraft 称 V4.1 是“主力模型，也是表现力最强的模型”。适合插画、编辑配图、产品视觉和需要固定配色的品牌素材。

Recraft V4.1 是 Recraft 于 2026 年 5 月 14 日发布的图像模型系列。Vidgo 提供 5 个输入字段相同的模型 ID：[V4.1 Flash 文生图](https://docs.vidgo.ai/zh/api-manual/image-series/recraft-v4-1-flash-text-to-image.md)、[V4.1 文生图](https://docs.vidgo.ai/zh/api-manual/image-series/recraft-v4-1-text-to-image.md)、[V4.1 Pro 文生图](https://docs.vidgo.ai/zh/api-manual/image-series/recraft-v4-1-pro-text-to-image.md)、[V4.1 文生矢量图](https://docs.vidgo.ai/zh/api-manual/image-series/recraft-v4-1-text-to-vector.md)和[V4.1 Pro 文生矢量图](https://docs.vidgo.ai/zh/api-manual/image-series/recraft-v4-1-pro-text-to-vector.md)。

## 模型

* **recraft/v4.1/text-to-image** — Recraft V4.1 文生图，每次一张图片。

## 功能

* 根据最多 10,000 个字符的提示词生成图片。
* Recraft V4.1 的主力模型，表现力最强。
* 5 种宽高比：`1:1`、`4:3`、`3:4`、`16:9`、`9:16`。
* 最多 10 个 RGB 颜色的首选配色，以及首选背景色。
* 每次请求一张图片，按次固定计费。

## 必填参数

* `prompt` (string)：描述所需图片。1–10,000 个字符，至少包含一个非空白字符。

## 可选参数

* `size` (string)：宽高比，`1:1`、`4:3`、`3:4`、`16:9` 或 `9:16`。默认 `1:1`。
* `colors` (object\[])：首选配色，最多 10 个颜色。每个颜色是一个对象，例如 `{"r": 18, "g": 52, "b": 86}`，取值为 0–255 的整数。
* `background_color` (object)：首选背景色，一个包含 0–255 整数 `r`、`g`、`b` 的 RGB 对象。

## 输出

任务完成后，[查询任务状态](https://docs.vidgo.ai/zh/api-manual/task-management/status.md)和回调内容的 `files` 数组中返回一张图片。

## 示例

* **编辑风人像**：瓦哈卡的日出场景，`3:4`。
* **品牌配色并设置回调**：方形等距插画，3 个 `colors`、`background_color`，并设置 `callback_url`。

## 注意事项

* 每次请求只返回一张图片。`input` 接收上文列出的字段，其他字段返回 400。`model` 和 `callback_url` 放在请求根级，与 `input` 并列。
* 每个 RGB 对象只包含 `r`、`g`、`b` 三个键，取值均为 0–255 的整数。其他颜色值或 `colors` 超过 10 项会返回 400。
* 每次请求按该模型 ID 的固定费率计费，`size`、`colors` 和 `background_color` 不影响价格。提交时预扣积分，任务失败会全额退还。当前费率见[定价页](https://vidgo.ai/apis/api-pricing)。


## OpenAPI

````yaml zh/api-manual/image-series/recraft-v4-1-text-to-image.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Vidgo API - Recraft V4.1 文生图
  description: Recraft V4.1 文生图 API 把最多 10,000 个字符的提示词生成一张图片，支持 5 种宽高比、最多 10 个配色和背景色。
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境服务器
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - Recraft V4.1 Text to Image
      summary: 提交 Recraft V4.1 文生图 任务
      operationId: submitRecraftV41TextToImageTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              basic:
                summary: 3:4 编辑风人像
                value:
                  model: recraft/v4.1/text-to-image
                  input:
                    prompt: >-
                      Editorial photo of a grandmother in Oaxaca braiding dried
                      chili garlands at sunrise, warm natural light, shallow
                      depth of field
                    size: '3:4'
              palette:
                summary: 品牌配色并设置回调
                value:
                  model: recraft/v4.1/text-to-image
                  callback_url: https://your-domain.com/callback
                  input:
                    prompt: >-
                      Isometric illustration of a tiny rooftop greenhouse cafe
                      with string lights and potted lemon trees
                    size: '1:1'
                    colors:
                      - r: 46
                        g: 125
                        b: 50
                      - r: 255
                        g: 193
                        b: 7
                      - r: 250
                        g: 250
                        b: 245
                    background_color:
                      r: 250
                      g: 250
                      b: 245
      responses:
        '200':
          description: 任务提交结果。任务 ID 标识一项异步任务；生成可能仍在进行中。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: 请求参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: false
      properties:
        model:
          type: string
          example: recraft/v4.1/text-to-image
        callback_url:
          type: string
          format: uri
          description: 可选的 Webhook URL，用于接收完成或失败通知。
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - prompt
          additionalProperties: false
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 10000
              description: 描述所需图片的提示词。1–10,000 个字符，至少包含一个非空白字符。
            size:
              type: string
              enum:
                - '1:1'
                - '4:3'
                - '3:4'
                - '16:9'
                - '9:16'
              default: '1:1'
              description: 输出的宽高比。
            colors:
              type: array
              maxItems: 10
              items:
                $ref: '#/components/schemas/RGBColor'
              description: >-
                首选配色，最多 10 个 RGB 颜色，用于引导结果的用色。每个颜色是一个对象，包含 0–255 的整数
                `r`、`g`、`b`。
            background_color:
              allOf:
                - $ref: '#/components/schemas/RGBColor'
              description: 首选背景色，一个包含 0–255 整数 `r`、`g`、`b` 的 RGB 对象。
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-example-001
            status:
              type: string
              example: not_started
            created_time:
              type: string
              format: date-time
              example: '2026-11-25T10:30:00'
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: 错误信息。参见[错误码](/zh/api-manual/error-codes)。
          example: prompt is required
    RGBColor:
      type: object
      required:
        - r
        - g
        - b
      additionalProperties: false
      description: RGB 颜色。
      properties:
        r:
          type: integer
          minimum: 0
          maximum: 255
          description: 红色分量，0–255。
        g:
          type: integer
          minimum: 0
          maximum: 255
          description: 绿色分量，0–255。
        b:
          type: integer
          minimum: 0
          maximum: 255
          description: 蓝色分量，0–255。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '使用 `Authorization: Bearer VIDGO_API_KEY`。'

````

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