> ## 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.

# 文生图

> 用一段中文或英文提示词生成图片：提示词写法、常用参数和请求示例。

文生图时 `input.messages` 只有一条 `user` 消息，`content` 中只放一个 `{"text": "..."}`。提示词支持中文和英文，建议不超过 4500 Token；其他语言可以尝试，但效果不作保证。

## 提示词写法

* **主体与场景**：写清楚画面里有什么、在哪里、在做什么，数量和位置越具体越准确。
* **风格与光线**：如写实摄影、水彩、3D 渲染，清晨逆光、柔和自然光、霓虹夜景。
* **构图与镜头**：特写、俯拍、广角、留白位置。
* **图中文字**：把要出现的文字放在引号里，并说明位置、字体、颜色或材质，例如“正中用烫金书法字体写着‘月满人团圆’”。
* **不想要的内容**：写在 `parameters.negative_prompt` 中，例如“低分辨率，文字错误，模糊”。

## 请求示例

生成一张 16:9 的中文海报。提示词已经写得很详细，所以关闭 `prompt_extend`，让模型严格按提示词出图并减少耗时。示例中的 `$DREAMTO_API_KEY` 为你的 API Key。

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/api/v1/services/aigc/multimodal-generation/generation" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0",
    "input": {
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "text": "一张中秋节海报，深蓝色夜空中一轮金色满月，下方是江南水乡的屋檐和石桥，画面正中用烫金书法字体写着“月满人团圆”，底部一行小字“2026 中秋”"
            }
          ]
        }
      ]
    },
    "parameters": {
      "negative_prompt": "低分辨率，文字错误，模糊，水印",
      "size": "1664*928",
      "prompt_extend": false
    }
  }'
```

```python Python theme={null}
import os

import requests

URL = "https://api.dreamto.ai/api/v1/services/aigc/multimodal-generation/generation"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "model": "qwen-image-3.0",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "text": "一张中秋节海报，深蓝色夜空中一轮金色满月，下方是江南水乡的屋檐和石桥，画面正中用烫金书法字体写着“月满人团圆”，底部一行小字“2026 中秋”"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "negative_prompt": "低分辨率，文字错误，模糊，水印",
        "size": "1664*928",
        "prompt_extend": False
    }
}

result = requests.post(URL, headers=HEADERS, json=payload, timeout=300).json()
if "output" not in result:
    raise SystemExit(result)
for item in result["output"]["choices"][0]["message"]["content"]:
    print(item["image"])
```

响应中的 `output.choices[0].message.content[].image` 为图片链接（PNG，24 小时内有效），`usage` 为本次的计费数量：

```json theme={null}
{
  "request_id": "req_7c1e9a4b2d3f5a6b8c9d0e1f",
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": [
            {
              "type": "image",
              "image": "https://dashscope-463f.oss-accelerate.aliyuncs.com/1d/bd/20261117/2299ae9b/qwen_image3_serving_output_0.png?Expires=1794997226&Signature=..."
            }
          ]
        }
      }
    ],
    "rewrite_status": "not_use"
  },
  "usage": {
    "output_width": 1024,
    "output_height": 1024,
    "input_image_count": 0,
    "input_image_type": "qima_input_1k",
    "output_image_count": 1,
    "output_image_type": "qima_output_1k"
  }
}
```

## 常用参数

| 参数 | 说明 |
| - | - |
| `size` | `宽*高`，如 `1328*1328`、`1664*928`；不传时由模型根据提示词决定。见 [尺寸与计费档位](https://docs.dreamto.ai/image/models/qwen-image-3-0/size-and-billing.md) |
| `n` | 一次生成的图片数，1 \~ 6，默认 1，按张计费 |
| `negative_prompt` | 反向提示词，描述不希望出现的内容 |
| `prompt_extend` | 提示词智能改写，默认 `true`；见 [提示词智能改写](https://docs.dreamto.ai/image/models/qwen-image-3-0/prompt-rewriting.md) |
| `seed` | 随机种子 `0` \~ `2147483647`，相同参数和种子的结果更稳定 |
| `watermark` | 是否添加水印，默认 `false` |

完整字段说明见 [生成图片](https://docs.dreamto.ai/api-reference/qwen-image-3-0/create-image.md)。


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