# Estimate cost

> Prices a request without running it. Takes the same body as generate, validates it the same way, and charges nothing. With `model: "auto"` the figure is an upper bound, because the model is not chosen until the task runs.

The same body as [generate](https://mynth.io/docs/api-reference/endpoints/image/generate.md),
validated the same way, priced rather than run. Nothing is created or held.
Use it to show a cost before a user commits, or to reject a request that would
break a budget.

With an explicit model the figure is exact. With `model: "auto"` it is the flat
$0.20 per image that `auto` holds, marked `upper_bound`.
[Estimate cost](https://mynth.io/docs/guides/estimate-cost.md) has the patterns.

`POST /image/generate/estimate`

**Auth:** API key or OAuth token

## Request body

- `model` (string) — Default `"auto"`. One of: `"alibaba/qwen-image-2.0"`, `"alibaba/qwen-image-2.0-pro"`, `"alibaba/qwen-image-2.1-pro"`, `"alibaba/qwen-image-3.0"`, `"alibaba/qwen-image-3.0-pro"`, `"bytedance/seedream-5.0-lite"`, `"bytedance/seedream-pro"`, `"bytedance/seedream-v5-flash"`, `"black-forest-labs/flux-1-schnell"`, `"black-forest-labs/flux.1-dev"`, `"black-forest-labs/flux.2-dev"`, `"black-forest-labs/flux.2-pro"`, `"black-forest-labs/flux.2-flex"`, `"black-forest-labs/flux.2-max"`, `"black-forest-labs/flux.2-klein-4b"`, `"black-forest-labs/flux-3"`, `"bria/fibo-edit-1.5"`, `"bria/fibo-generate-1.5"`, `"circlestone-labs/anima"`, `"goofy-ai/prefect-pony-xl-lora"`, `"google/gemini-3.1-flash-lite-image"`, `"google/gemini-3.1-flash-image"`, `"google/gemini-nano-banana-2.1"`, `"google/gemini-3-pro-image-preview"`, `"ideogram/ideogram-4.5"`, `"imagineart/imagineart-1.5-pro"`, `"imagineart/imagineart-2.0"`, `"john6666/bismuth-illustrious-mix"`, `"klingai/kling-image-3.0"`, `"klingai/kling-image-o3"`, `"krea/krea-2-turbo"`, `"krea/krea-2-medium"`, `"krea/krea-2-large"`, `"luma/uni-1"`, `"luma/uni-1-max"`, `"maxfeifei8/one-obsession"`, `"meta/muse-image"`, `"microsoft/mai-image-2.6"`, `"microsoft/mai-image-2.6-flash"`, `"minimax/h3"`, `"openai/gpt-image-2"`, `"openai/gpt-image-2.5-flare"`, `"openai/gpt-image-2.5-sunburst"`, `"purplesmartai/pony-diffusion-v6-xl"`, `"recraft/recraft-v4"`, `"recraft/recraft-v4.1-flash"`, `"recraft/recraft-v4-pro"`, `"reve/reve"`, `"reve/reve-remix"`, `"sourceful/riverflow-2.0-pro"`, `"tongyi-mai/z-image"`, `"tongyi-mai/z-image-turbo"`, `"wan/wan2.6-image"`, `"wan/wan2.7-image"`, `"wan/wan2.7-image-pro"`, `"xai/grok-imagine-image"`, `"xai/grok-imagine-image-2.0"`, `"xai/grok-imagine-image-quality"`, `"auto"`. Example `"black-forest-labs/flux.2-pro"`.
- `prompt` (required, string) — Positive prompt. ≥ 1 characters, ≤ 8192 characters. Example `"Cute Cat"`.
- `negative_prompt` (string) — ≤ 8192 characters.
- `magic_prompt` (boolean)
- `count` (integer) — Default `1`. ≥ 1, ≤ 20.
- `size` (object | string) — One of: `"auto"`, `"square"`, `"portrait"`, `"landscape"`, `"portrait_tall"`, `"landscape_wide"`, `"1:1"`, `"2:3"`, `"3:2"`, `"3:4"`, `"4:3"`, `"4:5"`, `"5:4"`, `"9:16"`, `"16:9"`, `"21:9"`, `"2:1"`, `"1:2"`, `"1:1_4k"`, `"2:3_4k"`, `"3:2_4k"`, `"3:4_4k"`, `"4:3_4k"`, `"4:5_4k"`, `"5:4_4k"`, `"9:16_4k"`, `"16:9_4k"`, `"21:9_4k"`, `"2:1_4k"`, `"1:2_4k"`.
  - **auto**
    - `type` (required, "auto")
  - **aspect_ratio**
    - `type` (required, "aspect_ratio")
    - `aspect_ratio` (required, string) — One of: `"1:1"`, `"2:3"`, `"3:2"`, `"3:4"`, `"4:3"`, `"4:5"`, `"5:4"`, `"9:16"`, `"16:9"`, `"21:9"`, `"2:1"`, `"1:2"`.
    - `scale` (string) — Default `"base"`. One of: `"base"`, `"4k"`.
- `inputs` ((string | object)[]) — ≤ 20 items.
  - **type + source**
    - `type` (required, "image")
    - `as` (string) — One of: `"auto"`, `"source"`, `"reference"`.
    - `source` (required, object)
      - `type` (required, "url")
      - `url` (required, string) — format: uri.
- `rating` (object | boolean) — One of: `true`.
  - **nsfw_sfw**
    - `mode` ("nsfw_sfw") — Default `"nsfw_sfw"`.
  - **custom**
    - `mode` (required, "custom")
    - `levels` (required, object[]) — ≥ 2 items, ≤ 7 items.
      - `value` (required, string) — ≥ 1 characters, ≤ 24 characters.
      - `description` (required, string) — ≥ 1 characters, ≤ 150 characters.
- `output` (object)
  - `format` (string) — One of: `"png"`, `"jpg"`, `"webp"`.
- `generate_public_access_token` (boolean) — Return a short-lived public access token as `public_access_token`, for polling this task from browser code without your API key. Defaults to false.
- `webhook` (object)
  - `registered` (boolean) — Set to false to skip the webhooks registered on the account for this task. Custom webhooks in `custom` are still sent.
  - `custom` (object[]) — ≥ 1 items, ≤ 5 items.
    - `url` (required, string) — Receives this task's events, unsigned. Use https and a public host, and put a secret token in the query string to verify deliveries: only `scheme://host` is ever shown back. Example `"https://example.com/hooks/mynth?token=your-secret-token"`.
- `destination` (string) — ≥ 1 characters, ≤ 64 characters. Example `"bunny-prod"`.
- `metadata` (object)

## Response

### 200 — Image generation request validated and cost estimated

- `data` (required, object)
  - `estimated_cost` (required, string) — Estimated cost in USD for the request. Nothing is generated or charged. Example `"0.03"`.
  - `currency` (required, "usd")
  - `estimate_kind` (required, string) — "exact" when the model is pinned; "upper_bound" for `model: "auto"`, which reserves a flat per-image ceiling until a concrete model is selected. One of: `"exact"`, `"upper_bound"`.

```json
{
  "data": {
    "estimated_cost": "0.03",
    "currency": "usd",
    "estimate_kind": "exact"
  }
}
```

### 400 — The request was rejected before anything was queued. `error.message` says what to change. A field that failed the schema, or one the endpoint does not take, is also listed in `error.issues`.

- `error` (required, object)
  - `code` (required, string) — `validation_error` for a body that failed validation, `invalid_json` for one that is not JSON. One of: `"validation_error"`, `"invalid_json"`.
  - `message` (required, string) — Every problem, in one sentence each, led by the field it is about.
  - `issues` (object[]) — One entry per field that failed the schema, and one per field the endpoint does not take.
    - `path` (required, (string | integer)[]) — Where the problem is, e.g. `["inputs", 0, "source"]`. Empty for the body as a whole.
    - `message` (required, string)

```json
{
  "error": {
    "code": "validation_error",
    "message": "count: Too big: expected number to be <=20. colour: Unknown field.",
    "issues": [
      {
        "path": [
          "count"
        ],
        "message": "Too big: expected number to be <=20"
      },
      {
        "path": [
          "colour"
        ],
        "message": "Unknown field."
      }
    ]
  }
}
```

## Request samples

### cURL

```bash
curl -X POST https://api.mynth.io/image/generate/estimate \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "black-forest-labs/flux.2-pro",
    "prompt": "Cute Cat",
    "destination": "bunny-prod"
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/image/generate/estimate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "black-forest-labs/flux.2-pro",
    "prompt": "Cute Cat",
    "destination": "bunny-prod"
  }),
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
