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

# Prompt Enhancement

> Rewrite a short prompt into a better prompt for one model.

## Endpoint

```
POST https://api.eachlabs.ai/v1/models/{slug}/enhance-prompt
```

Send a short prompt and the slug of the model you plan to run.
each::labs rewrites the prompt with that model's [prompt instructions](https://docs.eachlabs.ai/api/models/get-model.md#prompt-instructions) and returns the rewrite.
It does not run the model.
To run it, send the rewrite as the prompt in [Create Prediction](https://docs.eachlabs.ai/api/predictions/create-prediction.md).
To rewrite and run in one request, set `input.enhance_prompt` to `true` in [Create Prediction](https://docs.eachlabs.ai/api/predictions/create-prediction.md#prompt-enhancement).

The rewrite keeps the language of your prompt.
It also keeps reference tokens such as `@Image1`, so they still point at the same inputs.

A model supports prompt enhancement when [`GET /v1/models/{slug}`](https://docs.eachlabs.ai/api/models/get-model) returns a `prompt_instructions` value.
For a model where `prompt_instructions` is `null`, this endpoint returns `422`.

## Authentication

Pass a standard API key as a Bearer token:

```http theme={"dark"}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `slug` | string | Yes | Slug of the model the prompt is for (e.g., `gpt-image-v2-5-flare-edit`) |

## Request Body

| Field | Type | Required | Description |
| - | - | - | - |
| `prompt` | string | Yes | The prompt to rewrite. At most 10,000 characters. |

## Code Example

```bash cURL theme={"dark"}
curl -X POST https://api.eachlabs.ai/v1/models/gpt-image-v2-5-flare-edit/enhance-prompt \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"prompt": "make the background a beach at sunset"}'
```

## Response

```json theme={"dark"}
{
  "execution_id": "3f6c2a1e-8b4d-4e7a-9c2f-5d1b0a7e6c48",
  "model": "gpt-image-v2-5-flare-edit",
  "prompt": "make the background a beach at sunset",
  "enhanced_prompt": "Replace only the background with a beach at sunset, warm golden-orange light over the horizon and gentle waves, while keeping the subject's identity, pose, composition, colors and any existing text unchanged. Preserve the original style, lighting on the subject and overall mood.",
  "cost": 0.01
}
```

### Response Fields

| Field | Type | Description |
| - | - | - |
| `execution_id` | string | ID of the run that made the rewrite |
| `model` | string | Slug of the model the prompt was rewritten for |
| `prompt` | string | The prompt you sent |
| `enhanced_prompt` | string | The rewritten prompt |
| `cost` | number | Price of the call in USD, always `0.01` |

## Pricing

Each call costs `$0.01`.
It appears in [Run History](https://www.eachlabs.ai/run-history) as the model `eachlabs-prompt-enhancer`.
A failed enhancement is not charged.
After a `504`, the run can still finish later. If it does, it is charged and shows in Run History.

## Error Responses

| Status | Description |
| - | - |
| `400` | The prompt is empty, the prompt is longer than 10,000 characters, or the body is not valid JSON |
| `401` | The API key is missing or invalid |
| `402` | Your balance is too low |
| `404` | No model has this slug |
| `422` | The model has no prompt instructions |
| `502` | The enhancement failed. Retry the request |
| `504` | The enhancement timed out. Retry the request |

A `502` or `504` response names the run in `details.execution_id`:

```json theme={"dark"}
{
  "status": 502,
  "error": "bad gateway",
  "details": {
    "message": "The prompt enhancement model failed. Please retry.",
    "execution_id": "3f6c2a1e-8b4d-4e7a-9c2f-5d1b0a7e6c48"
  }
}
```


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