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

# Prompt rewriting

> `prompt_extend` optimizes the prompt automatically; how the direct and agent modes and thinking mode differ and combine.

`parameters.prompt_extend` defaults to `true`: the model first optimizes the prompt in the way `prompt_extend_mode` selects and then generates, so short descriptions still yield detailed images. Set it to `false` when the prompt is already detailed and must be followed literally, or when latency matters.

## Rewriting modes

| `prompt_extend_mode` | Description | Applies to |
| - | - | - |
| `direct` (default) | Direct Prompt Enhancement, fits most cases | Text-to-image and editing |
| `agent` | Agent Prompt Enhancement, more refined rewriting | Text-to-image only; returns 400 for editing |

## Thinking mode

`parameters.enable_thinking` defaults to `true`. It strengthens the model's reasoning for better images but takes longer, and it needs `prompt_extend: true`.

| Combination | Thinking mode |
| - | - |
| Direct + text-to-image | Supported |
| Direct + editing | Supported |
| Agent + text-to-image | Supported |
| Agent + editing | Not supported (agent cannot be used for editing) |

## Rewrite status

`output.rewrite_status` in the response reports the rewriting, e.g. `not_use` when rewriting was off and `success` when it succeeded.

## Agent mode with thinking

A short description, expanded in detail by agent mode:

```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": "A cafe in the middle of a forest"
            }
          ]
        }
      ]
    },
    "parameters": {
      "prompt_extend": true,
      "prompt_extend_mode": "agent",
      "enable_thinking": true
    }
  }'
```

```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": "A cafe in the middle of a forest"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "prompt_extend": True,
        "prompt_extend_mode": "agent",
        "enable_thinking": True
    }
}

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"])
```

## Rewriting off

When the prompt already describes the picture and its text precisely, turning rewriting off follows it literally and is faster (`enable_thinking` has no effect then):

```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": "A minimalist coffee brand poster: off-white background, a steaming white ceramic cup in the center, the words \"MORNING BREW\" in a dark brown sans-serif font above the cup and a small line \"Freshly ground daily\" at the bottom, soft natural light, generous white space"
            }
          ]
        }
      ]
    },
    "parameters": {
      "size": "1104*1472",
      "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": "A minimalist coffee brand poster: off-white background, a steaming white ceramic cup in the center, the words \"MORNING BREW\" in a dark brown sans-serif font above the cup and a small line \"Freshly ground daily\" at the bottom, soft natural light, generous white space"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "size": "1104*1472",
        "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"])
```


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