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

# Cost estimation

> Estimate request costs before executing

Use dry run mode to estimate the cost of a request without executing it. This validates your request parameters and returns pricing information so you can make informed decisions before generating.

## Making a dry run request

Add `?dryRun=true` as a query parameter to any request (chat completions, image generation, or image editing):

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://api.lumenfall.ai/openai/v1/images/generations?dryRun=true" \
    -H "Authorization: Bearer $LUMENFALL_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gemini-3-pro-image",
      "prompt": "A capybara relaxing in a hot spring",
      "size": "1024x1024",
      "n": 2
    }'
  ```

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

  response = requests.post(
      "https://api.lumenfall.ai/openai/v1/images/generations?dryRun=true",
      headers={"Authorization": f"Bearer {api_key}"},
      json={
          "model": "gemini-3-pro-image",
          "prompt": "A capybara relaxing in a hot spring",
          "size": "1024x1024",
          "n": 2
      }
  )

  estimate = response.json()
  cost_dollars = estimate["total_cost_micros"] / 1_000_000
  print(f"Estimated cost: ${cost_dollars:.4f}")
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch(
    "https://api.lumenfall.ai/openai/v1/images/generations?dryRun=true",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${apiKey}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        model: "gemini-3-pro-image",
        prompt: "A capybara relaxing in a hot spring",
        size: "1024x1024",
        n: 2,
      }),
    }
  );

  const estimate = await response.json();
  const costDollars = estimate.total_cost_micros / 1_000_000;
  console.log(`Estimated cost: $${costDollars.toFixed(4)}`);
  ```
</CodeGroup>

Dry run mode works with [chat completions](/api-reference/chat/completions), [image generation](/api-reference/images/generate), and [image editing](/api-reference/images/edit) endpoints.

## Response format

Dry run requests return a cost estimate instead of generated images:

```json theme={null}
{
  "estimated": true,
  "model": "gemini-3-pro-image",
  "provider": "vertex",
  "total_cost_micros": 80000,
  "currency": "USD",
  "components": [
    {
      "type": "output",
      "metric": "image",
      "quantity": 2,
      "billable_quantity": 2,
      "unit_price": 0.04,
      "total_cost": 80000
    }
  ]
}
```

### Response fields

| Field               | Type    | Description                                                                                          |
| ------------------- | ------- | ---------------------------------------------------------------------------------------------------- |
| `estimated`         | boolean | Always `true` for dry run responses                                                                  |
| `model`             | string  | The model that would be used                                                                         |
| `provider`          | string  | The provider that would handle the request (may differ on actual request as routing is re-evaluated) |
| `total_cost_micros` | integer | Total estimated cost in micros (1/1,000,000 USD)                                                     |
| `currency`          | string  | Currency code (always `USD`)                                                                         |
| `components`        | array   | Breakdown of cost components                                                                         |

### Cost components

Each component in the `components` array contains:

| Field               | Type    | Description                                     |
| ------------------- | ------- | ----------------------------------------------- |
| `type`              | string  | Component type (e.g., `output`, `input`)        |
| `metric`            | string  | What is being measured (e.g., `image`, `token`) |
| `quantity`          | integer | Number of units requested                       |
| `billable_quantity` | integer | Number of units that will be billed             |
| `unit_price`        | number  | Price per unit in USD                           |
| `total_cost`        | integer | Component cost in micros                        |

## Converting micros to dollars

Costs are returned in micros (millionths of a dollar) for precision. To convert to dollars:

```python theme={null}
cost_dollars = total_cost_micros / 1_000_000
```

For example, `80000` micros equals `$0.08`.

## Notes

<Note>
  Cost estimates are approximate. Effective pricing is calculated after the request runs, because final costs may depend on outputs (such as token counts or the number of images generated).
</Note>

Dry run requests:

* Validate your request parameters
* Do not execute the request (no text generation or image creation)
* Do not affect your account balance
* Return quickly since no generation occurs
