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

# Enhance prompt

> Expand a short prompt into a richer description with visual context, style cues, and composition details for $0.01 per request.

Enhance prompt expands a short prompt into a richer, more detailed description with added visual context, style cues, and composition details. Use the result as the `prompt` of any image generation endpoint.

<CardGroup cols={3}>
  <Card title="$0.01" icon="https://mintcdn.com/recraft/dlnQgLElJIYDw2GO/icons/credits-fill.svg?fit=max&auto=format&n=dlnQgLElJIYDw2GO&q=85&s=411698b1ce815a1634dd83c0b7332cff" width="16" height="16" data-path="icons/credits-fill.svg">per request</Card>
  <Card title="Prompt → enhanced prompt" icon="https://mintcdn.com/recraft/dlnQgLElJIYDw2GO/icons/enhance-prompt.svg?fit=max&auto=format&n=dlnQgLElJIYDw2GO&q=85&s=81634c78286b1cd112c930db1fd0df74" width="16" height="16" data-path="icons/enhance-prompt.svg">up to 2,000 characters</Card>
  <Card title="POST /v1/prompts/enhance" icon="https://mintcdn.com/recraft/dlnQgLElJIYDw2GO/icons/api.svg?fit=max&auto=format&n=dlnQgLElJIYDw2GO&q=85&s=eace772046907259477c5fa36adeb139" width="16" height="16" data-path="icons/api.svg">endpoint</Card>
</CardGroup>

## Try it

Get an API token on your [profile page](https://app.recraft.ai/profile/api) (it needs a positive API units balance) and set it once per terminal session:

```bash theme={null}
export RECRAFT_API_TOKEN=your_token
```

Then run. The request enhances a short prompt:

<CodeGroup>
  ```bash cURL theme={null}
  curl https://external.api.recraft.ai/v1/prompts/enhance \
    -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "race car on a track"
    }'
  ```

  ```python Python theme={null}
  # pip install requests
  import os

  import requests

  response = requests.post(
      'https://external.api.recraft.ai/v1/prompts/enhance',
      headers={'Authorization': f"Bearer {os.environ['RECRAFT_API_TOKEN']}"},
      json={
          'prompt': 'race car on a track',
      },
  )
  if not response.ok:
      raise SystemExit(f'{response.status_code}: {response.text}')
  print(response.json()['enhanced_prompt'])
  ```

  ```javascript JavaScript theme={null}
  // Node.js 18+, run as an ES module (file.mjs)
  const response = await fetch('https://external.api.recraft.ai/v1/prompts/enhance', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.RECRAFT_API_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      prompt: 'race car on a track',
    }),
  });
  if (!response.ok) throw new Error(await response.text());
  const result = await response.json();
  console.log(result.enhanced_prompt);
  ```

  ```python Python (OpenAI SDK) theme={null}
  # pip install openai
  import os

  from openai import OpenAI

  client = OpenAI(
      base_url='https://external.api.recraft.ai/v1',
      api_key=os.environ['RECRAFT_API_TOKEN'],
  )

  response = client.post(
      path='/prompts/enhance',
      cast_to=object,
      body={
          'prompt': 'race car on a track',
      },
  )
  print(response['enhanced_prompt'])
  ```
</CodeGroup>

## Response

```json theme={null}
{
  "enhanced_prompt": "..."
}
```

* The result is a single `enhanced_prompt` string. It is not an image, so there is no `data` array.
* The enhanced prompt is more detailed than the original. Models have different prompt length limits, see [Prompt length](/docs/api-reference/appendix#prompt-length).

## Parameters

| Parameter | Type, default | Description |
| - | - | - |
| `prompt` | string, **required** | The prompt to enhance. It must not be empty and must not exceed 2,000 characters. See [Prompt length](/docs/api-reference/appendix#prompt-length). |

## Examples

<AccordionGroup>
  <Accordion title="Enhance a prompt, then generate an image">
    Enhance a short prompt, then pass the result as `prompt` to `/v1/images/generations` with `recraftv4_1`. The two requests cost \$0.01 and the price of the generated image. See [Pricing](/docs/api-reference/pricing).

    <CodeGroup>
      ```bash cURL theme={null}
      ENHANCED=$(curl -s https://external.api.recraft.ai/v1/prompts/enhance \
        -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{"prompt": "race car on a track"}' \
        | python3 -c 'import json, sys; print(json.load(sys.stdin)["enhanced_prompt"])')

      curl https://external.api.recraft.ai/v1/images/generations \
        -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
        -H "Content-Type: application/json" \
        -d "$(python3 -c 'import json, sys; print(json.dumps({"prompt": sys.argv[1], "model": "recraftv4_1"}))' "$ENHANCED")"
      ```

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

      import requests

      headers = {'Authorization': f"Bearer {os.environ['RECRAFT_API_TOKEN']}"}

      response = requests.post(
          'https://external.api.recraft.ai/v1/prompts/enhance',
          headers=headers,
          json={'prompt': 'race car on a track'},
      )
      if not response.ok:
          raise SystemExit(f'{response.status_code}: {response.text}')
      enhanced_prompt = response.json()['enhanced_prompt']
      print(enhanced_prompt)

      response = requests.post(
          'https://external.api.recraft.ai/v1/images/generations',
          headers=headers,
          json={'prompt': enhanced_prompt, 'model': 'recraftv4_1'},
      )
      if not response.ok:
          raise SystemExit(f'{response.status_code}: {response.text}')
      print(response.json()['data'][0]['url'])
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Recraft V4.1" href="/docs/api-reference/models/recraft-v4-1">
    The default model for image generation.
  </Card>

  <Card title="Pricing" href="/docs/api-reference/pricing">
    Prices of every model and tool.
  </Card>
</CardGroup>


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