> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Midjourney V8.2

POST https://api.beatapi.io/v1/images/tasks
Content-Type: application/json

Midjourney V8.2 through one model ID. Generate four images from text and image prompts, then vary or upscale one of them or reroll the set, or retexture, edit, blend and describe images.- One model ID for every Midjourney operation. `action` picks it and defaults to `generate`; the buttons Midjourney shows under a result are actions too.
- Asynchronous: the create call returns a task ID at once. A `fast` generate usually finishes in 1 to 3 minutes; poll for up to 10 minutes.
- A generate returns four images. A follow-up names your earlier task in `source_task_id` and, where it picks an image, its position in `index` (1 to 4).
- Midjourney parameters such as `--ar`, `--s`, `--sref` and `--no` go in `prompt`. Version, speed, quality and draft are fields.
- Priced per call by `speed` and `quality`; `upscale` and `describe` have one low flat price. A refused request and a failed task cost nothing.
- Results are deleted after 7 days. Download the images you want to keep.POST/v1/images/tasksTry itOpens this model in the API Explorer. Enter your BeatAPI API key to create a task: the call is real and is billed to your own balance.## Endpoint and authentication`POST https://api.beatapi.io/v1/images/tasks`### `Authorization``string` · RequiredYour BeatAPI API key, sent as `Bearer <BEATAPI_API_KEY>`. Create keys in the [Dashboard](https://beatapi.io/dashboard). Keep keys on your server; never ship them in a browser or mobile app.Send the body as JSON with `Content-Type: application/json`. `Idempotency-Key` is optional: send a unique value (at most 255 characters) per logical request and reuse it only to retry that exact body. Within 24 hours a retry with the same key and body returns the first response again with `Idempotent-Replayed: true`; the same key with a different body returns `409 idempotency_conflict`. Responses other than 2xx are not stored, so a retry after a 400 or 402 runs again.## How a request works1) **Create the task** `POST` the parameters below to the endpoint. A `201` means the task was accepted and its price reserved from your balance; the work runs in the background. Save `data.id`.
2) **Wait for it to finish** Call `GET /v1/tasks/{task_id}` and wait `data.poll_after_seconds` between calls (5 s for images, 8 s for videos) until `status` is `succeeded` or `failed`. Or register a [webhook](/webhooks) for `task.succeeded` and `task.failed`; keep polling as the fallback, because a task stopped by the processing timeout sends no event.
3) **Save the result** On `succeeded`, download every `data.output.media[].url` and store the files you need; BeatAPI does not promise how long result URLs stay available. On `failed`, read `data.error_code` and `data.error_message`: the reserved amount was returned to your balance, and `data.retryable` says whether sending the same request again can succeed.## Input modes| Mode        | Required inputs                              | Notes                                                                                                                                                                                                |
| ----------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Generate    | `model`, `prompt`                            | The default action. Optional `images` (1 to 5 image prompts), `aspect_ratio`, `quality`, `speed`, `draft`. Returns four images. `prompt` may be left out only when `images` holds two or more links. |
| Variation   | `model`, `action`, `source_task_id`, `index` | The V button for one image of a four-image result. Returns four new images.                                                                                                                          |
| Upscale     | `model`, `action`, `source_task_id`, `index` | Picks one image of a four-image result and returns it alone, at the same pixel size. It takes no follow-up.                                                                                          |
| Reroll      | `model`, `action`, `source_task_id`          | Redraws the whole prompt of a four-image result as four new images. No `index`.                                                                                                                      |
| Retexture   | `model`, `action`, `images`, `prompt`        | Exactly one image. Keeps its composition and restyles it. Returns four images, which take no follow-up.                                                                                              |
| Edit (beta) | `model`, `action`, `images`, `prompt`        | Exactly one PNG with transparent areas; only those are redrawn. Returns four images, which take no follow-up.                                                                                        |
| Blend       | `model`, `action`, `images`                  | 2 to 5 images merged into one picture; `aspect_ratio` `1:1`, `3:2` or `2:3`. Rendered with Midjourney V7.                                                                                            |
| Describe    | `model`, `action`, `images`                  | Exactly one image. Returns four prompts in `output.data.prompts` and no image.                                                                                                                       |## Request parameters### `model``string` · RequiredThe model to run.**Value**: `mj-v8.2`**If the value is wrong**- Missing: `"model" is required`
- Unknown model ID: `"model" mj-v7 is not catalogued`
- A video model sent to this endpoint: `"model" seedance-2.5 is served by POST /v1/videos/tasks, not this endpoint`### `prompt``string` · OptionalWhat to draw, as on midjourney.com: the description first, then any Midjourney parameters such as `--ar 3:2 --s 250`. For `retexture` and `edit` it describes the new look.**Length**: 1–2048 characters- Required for `generate` unless `images` holds two or more links, and for `retexture` and `edit`. Other actions do not take it.
- For `generate`, the text without links and `--` parameters is at most 1024 characters.
- Parameters that the API sets by field, and those it does not support, are refused; see the parameter table further down.**If the value is wrong**- Left out on a generate with fewer than two images: `generate needs "prompt"; only two or more images may go without one`
- Left out on retexture or edit: `"prompt" is required for action retexture`
- Sent with an action that does not take it: `prompt is not used by action upscale; leave it out`
- Empty or longer than the limit: `"prompt" has an unsupported length`
- The text without links and parameters is too long: `the prompt's text (without links and --parameters) is at most 1024 characters`
- A version parameter: `remove --v from the prompt: the version is fixed at 8.2; leave it out`
- A speed parameter: `remove --fast from the prompt: set the speed field to fast instead`
- A decimal ratio: `--ar takes whole numbers, like 139:100 instead of 1.39:1`
- `--q` outside 1 to 4: `--q takes 1, 2, 3 or 4 (detail; 4 is the most detailed); for a bigger picture set quality hd`### `action``string` · Optional · Default: `generate`The operation to run. Each action takes only its own fields (see the input modes above); any other field is refused, so you never pay for a setting that had no effect.**Allowed values**: `generate`, `variation`, `upscale`, `reroll`, `retexture`, `edit`, `blend`, `describe`  \
**Default**: `generate`- `generate` starts afresh. `variation`, `upscale` and `reroll` work on a four-image result; an upscaled image takes no follow-up.
- `retexture`, `edit`, `blend` and `describe` start from your own images in `images`.
- Input is not case-sensitive; the documentation writes the lower-case form.**If the value is wrong**- A value not in the list: `"action" must be one of: [generate variation upscale reroll retexture edit blend describe]`
- A field the action does not take: `quality is not used by action retexture; leave it out`### `images``string[]` · OptionalYour own images as public HTTPS links. For `generate` they are image prompts (1 to 5); `retexture`, `edit` and `describe` take exactly one; `blend` takes 2 to 5.**Items**: 1–5  \
Each item is a public `https://` URL. For a local file, [upload it first](/quick-guide#upload-an-input-file) with `POST /v1/files` and pass the returned `data.url`.- Links must be public and download within a few seconds. Have a local file? Upload it with `POST /v1/files` and send the returned link.
- For `edit`, send a PNG and cut out (make transparent) the parts to change. An image without transparency, such as any JPEG, is still drawn and billed.
- Follow-ups (`variation`, `upscale`, `reroll`) work on `source_task_id` and do not take `images`.
- Positions in error messages are 0-based: `images[0]` is the first link.**If the value is wrong**- Missing on retexture, edit, blend or describe: `"images" is required for action describe`
- Fewer than blend needs: `action blend needs at least 2 image(s) in "images"`
- More than one for describe, retexture or edit: `action describe takes at most 1 image(s) in "images"`
- More than five: `"images" accepts at most 5 items`
- Not an https\:// link: `"images[0]" must be a public HTTPS URL`### `aspect_ratio``string` · OptionalShape of the image as width:height, for `generate` and `blend`.**Allowed values**: `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `16:9`, `9:16`, `21:9`, `9:21`, `5:4`, `4:5`, `2:1`, `1:2`- A generate without it is drawn `1:1`.
- `blend` takes only `1:1` (its default), `3:2` or `2:3`.
- For any other shape write `--ar W:H` with whole numbers in `prompt`, for example `--ar 7:4`; it overrides this field.**If the value is wrong**- A value not in the list: `"aspect_ratio" must be one of: [1:1 4:3 3:4 3:2 2:3 16:9 9:16 21:9 9:21 5:4 4:5 2:1 1:2]`
- A blend with another shape: `"aspect_ratio" for blend is one of: 1:1, 3:2, 2:3`### `quality``string` · Optional · Default: `standard``hd` draws about 2K instead of the standard size. It is set when you generate and cannot be added later.**Allowed values**: `standard`, `hd`  \
**Default**: `standard`- At `fast`, `hd` costs more; at `relax` it costs the same.
- `upscale` returns the image at the pixel size it was drawn at; it does not enlarge it. Ask for `hd` on the first call when you want a bigger picture.
- A follow-up runs at its source task’s quality. Leave the field out on a follow-up, or send the same value.
- `retexture`, `edit`, `blend` and `describe` do not take it.**If the value is wrong**- A value not in the list: `"quality" must be one of: [standard hd]`
- Together with draft: `draft cannot be combined with quality hd`
- A follow-up asking for another quality than its source task: `source_task_id was made at quality hd and a follow-up runs the same; leave quality out`### `speed``string` · Optional · Default: `fast``fast` (the default) usually finishes a generate in 1 to 3 minutes; `relax` takes 2 to 5 minutes and costs less.**Allowed values**: `fast`, `relax`  \
**Default**: `fast`- A follow-up runs at its source task’s speed and is billed at it. Leave the field out on a follow-up, or send the same value.
- `describe` does not take it.**If the value is wrong**- A value not in the list: `"speed" must be one of: [fast relax]`
- A follow-up asking for another speed than its source task: `source_task_id was made at speed relax and a follow-up runs the same; leave speed out`### `draft``boolean` · OptionalFor `generate` only. `true` returns 24 quick 512 px drafts at a generate’s price, to explore a prompt before rendering it in full.- Works at either `speed`; cannot be combined with `quality` `hd`.
- A draft takes no follow-up and its images cannot be picked. To render a prompt in full, send it again without `draft`; write `--seed N` in the draft’s prompt for a similar, not identical, composition.**If the value is wrong**- Not a boolean: `"draft" must be a boolean`
- A follow-up on a draft: `source_task_id is a draft, which takes no follow-up; send the prompt again without draft (add --seed N to keep a similar composition)`### `source_task_id``string` · OptionalFor a follow-up: the `id` of your own earlier Midjourney task that it works on. The task must have succeeded.- Read `output.data.follow_ups` of that task first: it lists the actions the result accepts. Any other follow-up is refused at no charge.
- An upscaled image takes no follow-up. To vary it, send `variation` with the `source_task_id` of its four-image result and the same `index`.
- Results of `upscale`, `retexture`, `edit`, `describe` and drafts take no follow-up.**If the value is wrong**- Not a task id: `"source_task_id" must be the id of one of your earlier tasks: "task_" followed by 32 letters or digits`
- Missing on a follow-up: `"source_task_id" is required for action upscale: the id of your own Midjourney task it works on`
- The source task is still running or failed: `source_task_id has not finished successfully; wait for it to succeed and try again`
- A task of another model: `source_task_id was made by seedream-5.5, not Midjourney; name one of your Midjourney tasks`
- A follow-up on an upscaled image: `an upscaled image takes no follow-up; to vary it, send action variation with source_task_id of its four-image result and the same index`
- A result of retexture, edit or describe: `source_task_id is the result of retexture, which takes no follow-up`
- The same image of the same result upscaled again: `that image of source_task_id was already upscaled in task_Up4Rk9Ns2Wq7Zx5Mc8Hv1Lb6Tj3Fd0Gy; use that task's result`
- An action that result does not list in follow\_ups: `this result does not support action upscale; generate the image again and continue from the new result`### `index``integer` · OptionalWhich image of a four-image result to work on, 1 to 4. It is 1-based and counts `output.media` of the source task.**Range**: 1–4- Required for `upscale` and `variation`.
- Not used by `reroll` or by actions without `source_task_id`.**If the value is wrong**- Missing on upscale or variation: `"index" is required for action upscale`
- Not a whole number from 1 to 4: `"index" is outside its supported range`### `callback_url``string` · OptionalAn address to notify when this task succeeds or fails: a public HTTPS URL on the same scheme, host and port as one of your enabled [webhook endpoints](/webhooks), which signs the delivery with its `secret`.**Length**: ≤ 2048 characters- Register the endpoint first with `POST /v1/webhooks`. BeatAPI sends `task.succeeded` or `task.failed` with the same body, headers and retries as an account webhook; an account endpoint subscribed to the event receives it too, and an address identical to that endpoint’s is notified once.
- The callback stops when the signing endpoint is deleted, disabled or moved to another host.**If the value is wrong**- The value is not a string: `"callback_url" must be a string.`
- The address is longer than 2048 characters: `"callback_url" must be at most 2048 characters.`
- It is not a URL, or has no host or no `http` or `https` scheme: `"callback_url" must be a valid https URL.`
- It uses `http`, or points to a private or otherwise non-public address: `"callback_url" must be a public HTTPS URL.`
- No enabled webhook endpoint has the same scheme, host and port: `"callback_url" must be on the host of one of your active webhook endpoints, whose secret signs it; register one with POST /v1/webhooks.`The gateway also checks these combinations before creating the task:- action picks the operation and defaults to generate; each action takes only the fields listed for it here, and any other field is refused
- a refused request (HTTP 400) and a failed task are not charged
- generate: prompt (required unless images holds 2 or more links), optional images (1-5 public image links used as image prompts), aspect\_ratio (1:1 when left out), quality, speed, draft; returns four images
- quality hd draws about 2K at generate time; it cannot be added later, so set it on the first call when you want a bigger picture
- variation: source\_task\_id of a four-image result and index (1-4); Midjourney's V button for that image, returning four new images
- upscale: source\_task\_id of a four-image result and index (1-4); it picks that image and returns it alone at the same pixel size (it does not enlarge), and an upscaled image takes no follow-up
- reroll: source\_task\_id of a four-image result, no index; redraws the whole prompt as four new images
- retexture and edit: images (exactly 1) and prompt; retexture keeps the composition and restyles it by prompt; edit (beta) redraws the transparent areas of a PNG, so cut out the parts to change: an image without transparency (any JPEG) is still drawn and billed; both return four images, which take no follow-up
- blend: images (2-5) and optional aspect\_ratio 1:1 (default), 3:2 or 2:3; it renders with Midjourney V7, so its look can differ from V8.2 images; describe: images (exactly 1), returns four prompts in output.data.prompts and no image
- index is 1-based and counts output.media of the source task; output.data.kind (grid, single or text) and output.data.follow\_ups list what a finished task accepts (occasionally fewer, or none, when the task was served by an overflow route), and any other follow-up is refused at no charge; read it before planning a chain
- a follow-up runs at the source task's speed and quality (leave both out, or send the same values) and is billed as a new image at those settings, except upscale and describe, which have one flat price
- a draft result takes no follow-up and its images cannot be selected: to render a prompt in full, send it again without draft (write --seed N in the draft's prompt for a similar, not identical, composition)
- Midjourney parameters go in prompt as on midjourney.com: --ar W:H with whole numbers (overrides aspect\_ratio), --s 0-1000, --c 0-100, --seed 0-4294967295, --exp 0-100, --q 1-4, --raw, --no, --tile, --weird 0-3000, --iw 0-3, --sref (links or codes) and --sw; for generate the text without links and parameters is at most 1024 characters
- set the version (8.2), speed, quality and draft by fields only: a prompt with --v, --niji, --fast, --relax, --turbo, --hd or --draft is refused, as are --oref, --cref, --stop, --p, --bs, --repeat, --edit, --stealth and --public, which this API does not support
- speed fast (default) usually takes 1-3 minutes, relax 2-5 minutes at a lower price, edit and retexture up to 5 minutes, upscale and describe seconds; poll for up to 10 minutes; quality hd costs more at fast and the same at relax; draft works at either speed, returns 24 quick 512 px images at a generate's price and cannot be hd
- image links must be public and download within a few seconds; upload a local file with POST /v1/files and send its link; save the results you want to keep: images are deleted after 7 days## Actions at a glanceEvery action is a new task on the same endpoint. `output.data.kind` of the result says what it is: `grid` (four images), `single` (one upscaled image) or `text`.| Action        | Works on               | Fields besides `model` and `action`                             | Returns                   |
| ------------- | ---------------------- | --------------------------------------------------------------- | ------------------------- |
| `generate`    | Text and image prompts | `prompt`, `images`, `aspect_ratio`, `quality`, `speed`, `draft` | Four images               |
| `variation`   | A four-image result    | `source_task_id`, `index`, `speed`, `quality`                   | Four images               |
| `upscale`     | A four-image result    | `source_task_id`, `index`, `speed`, `quality`                   | One image, no follow-up   |
| `reroll`      | A four-image result    | `source_task_id`, `speed`, `quality`                            | Four images               |
| `retexture`   | One image of yours     | `images`, `prompt`, `speed`                                     | Four images, no follow-up |
| `edit` (beta) | One PNG of yours       | `images`, `prompt`, `speed`                                     | Four images, no follow-up |
| `blend`       | 2 to 5 images of yours | `images`, `aspect_ratio`, `speed`                               | Four images               |
| `describe`    | One image of yours     | `images`                                                        | Four prompts, no image    |- A field the action does not take is refused, not ignored: a stray `index` on a generate would otherwise be paid for and have no effect.
- `blend` renders with Midjourney V7, so its look can differ from V8.2 images.## Chaining follow-upsA follow-up names one of your own finished Midjourney tasks in `source_task_id`. It works on a four-image result, and `index` picks one of its images: 1 is the first item of that task’s `output.media`, 4 the last.- `variation` with `index`: the V button, four new images close to that one.
- `upscale` with `index`: the U button, that image alone. Upscaling the same image of the same result again is refused and names the task that already holds it.
- `reroll`: four new images from the same prompt.An upscaled image takes no follow-up; to vary it, send `variation` with its four-image result and the same `index`. Results of `retexture`, `edit`, `describe` and drafts take no follow-up either.Before you plan a chain, read `output.data.follow_ups` of the task you want to continue: it lists exactly the actions that result accepts. A result can list fewer, or none, when it was made on a fallback line; any other follow-up is refused at no charge, and you can generate the image again and continue from the new result.A follow-up runs at the speed and quality of its source task, and is billed at them. Leave `speed` and `quality` out, or send the same values; a different value is refused.## Speed, quality and drafts| Setting                  | What it does                                                        | Price                                 |
| ------------------------ | ------------------------------------------------------------------- | ------------------------------------- |
| `speed` `fast` (default) | A generate usually takes 1 to 3 minutes.                            | Higher rate                           |
| `speed` `relax`          | Usually 2 to 5 minutes.                                             | Lower rate                            |
| `quality` `hd`           | Draws about 2K. Set it when you generate; it cannot be added later. | Higher at `fast`, the same at `relax` |
| `draft` `true`           | 24 quick 512 px images to explore a prompt; no follow-up, no `hd`.  | A generate’s price at that speed      |- `edit` and `retexture` can take up to 5 minutes; `upscale` and `describe` take seconds. Poll for up to 10 minutes before you give up on a task.
- `upscale` picks an image; it does not enlarge it. The upscaled image has the pixel size it was drawn at.## Midjourney parameters in the promptWrite Midjourney’s own parameters at the end of `prompt`, as on midjourney.com. They are passed on as written.| Parameter           | Values                             | Notes                                                                             |
| ------------------- | ---------------------------------- | --------------------------------------------------------------------------------- |
| `--ar W:H`          | Whole numbers, such as `7:4`       | Overrides `aspect_ratio`. Decimals such as `1.39:1` are refused; write `139:100`. |
| `--s`               | 0 to 1000                          | Stylize.                                                                          |
| `--c`               | 0 to 100                           | Chaos: how different the four images are.                                         |
| `--seed`            | 0 to 4294967295                    | Repeatable starting noise.                                                        |
| `--q`               | 1 to 4                             | Detail; 4 is the most detailed. For a bigger picture use `quality` `hd`.          |
| `--sref` and `--sw` | Image links or style codes; weight | Style reference and its weight.                                                   |
| `--iw`              | 0 to 3                             | Weight of the image prompts in `images`.                                          |
| `--exp`             | 0 to 100                           | Experimental aesthetics.                                                          |
| `--weird`           | 0 to 3000                          | Unconventional results.                                                           |
| `--no`              | Words                              | What to leave out.                                                                |
| `--raw`, `--tile`   | No value                           | Less default styling; a seamless tile.                                            |- Set the version (8.2), speed, quality and draft by fields: a prompt with `--v`, `--niji`, `--fast`, `--relax`, `--turbo`, `--hd` or `--draft` is refused.
- Not supported by this API, and refused: `--oref`, `--cref`, `--stop`, `--p`, `--bs`, `--repeat`, `--edit`, `--stealth`, `--public`.
- For `generate`, the text without links and parameters is at most 1024 characters.## Results and retentionImages are stored for 7 days and then deleted; download the ones you want to keep. `describe` stores no file: its four prompts are in `output.data.prompts`.Image links you send must be public and download within a few seconds. A link that cannot be fetched fails the task, which is not charged.## Request examples```bash title="cURL"
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
  "aspect_ratio": "16:9"
}'
``````python title="Python"
import os
import requests

response = requests.post(
    "https://api.beatapi.io/v1/images/tasks",
    headers={"Authorization": f"Bearer {os.environ['BEATAPI_API_KEY']}"},
    json={
      "model": "mj-v8.2",
      "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
      "aspect_ratio": "16:9"
    },
    timeout=60,
)
body = response.json()
if not response.ok:
    raise RuntimeError(f"{response.status_code} {body['error']['code']}: {body['error']['message']}")
task = body["data"]
print(task["id"], task["status"])
``````javascript title="JavaScript"
const response = await fetch('https://api.beatapi.io/v1/images/tasks', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BEATAPI_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "model": "mj-v8.2",
    "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
    "aspect_ratio": "16:9"
  }),
});
const body = await response.json();
if (!response.ok) throw new Error(`${response.status} ${body.error.code}: ${body.error.message}`);
console.log(body.data.id, body.data.status);
```### Generate four imagesThe default action. Midjourney parameters go at the end of the prompt.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
  "aspect_ratio": "16:9"
}'
```### Vary image 3The V3 button: four new images close to the third image of the generate above.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "action": "variation",
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
  "index": 3
}'
```### Upscale image 2The U2 button on the variation result: the second image alone, at the pixel size it was drawn at. It takes no follow-up.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "action": "upscale",
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E",
  "index": 2
}'
```### Describe an imageFour prompts that would draw an image like yours, in `output.data.prompts`.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "action": "describe",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ]
}'
```### Image prompt and style reference at relax, in HDA product image as image prompt, a style reference in the prompt; `relax` costs less and `hd` costs nothing extra there.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "aspect_ratio": "4:5",
  "speed": "relax",
  "quality": "hd"
}'
```### Blend two imagesMerges the images into one picture, rendered with Midjourney V7. No prompt.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "action": "blend",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "aspect_ratio": "3:2"
}'
```## Responses### Create a task (201)The task object. `output` is `null` until the task succeeds. Fields marked “while running” disappear once the task finishes.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "media_type": "image",
    "model": "mj-v8.2",
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "poll_after_seconds": 5,
    "output": null,
    "usage": {
      "credits_reserved": 0.08,
      "credits_settled": 0,
      "credits_refunded": 0,
      "credits_charged": 0.08
    },
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null
  }
}
```| Field                                  | Type              | Description                                                                                                                              |
| -------------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `data.id`                              | `string`          | Task ID: `task_` followed by 32 letters and digits. Use it to poll and to match webhook events.                                          |
| `data.object`                          | `string`          | Always `task`.                                                                                                                           |
| `data.task_kind`                       | `string`          | `image` or `video`.                                                                                                                      |
| `data.capability_id`                   | `string`          | The model ID you sent.                                                                                                                   |
| `data.capability_version`              | `integer`         | Contract version of the model, currently `1`.                                                                                            |
| `data.media_type`                      | `string`          | `image` or `video`.                                                                                                                      |
| `data.model`                           | `string`          | The model ID you sent (same as `capability_id`).                                                                                         |
| `data.status`                          | `string`          | `queued`, `processing`, `succeeded` or `failed`. Only the last two are final.                                                            |
| `data.stage`                           | `string`          | Repeats `status`; kept for older clients.                                                                                                |
| `data.created_at`                      | `integer`         | When the task was created, Unix seconds.                                                                                                 |
| `data.updated_at`                      | `integer`         | Last change, Unix seconds.                                                                                                               |
| `data.completed_at`                    | `integer \| null` | When the task finished, Unix seconds; `null` while it runs.                                                                              |
| `data.poll_after_seconds`              | `integer`         | While running: how long to wait before the next poll (5 for images, 8 for videos).                                                       |
| `data.typical_seconds`                 | `object`          | While running, when enough recent tasks exist: `p50` and `p90` completion times in seconds over the last `window`, from `samples` tasks. |
| `data.output`                          | `object \| null`  | The result; `null` until `status` is `succeeded`. See the output fields below.                                                           |
| `data.usage.credits_reserved`          | `number`          | USD held from your balance when the task was created.                                                                                    |
| `data.usage.credits_charged`           | `number`          | USD this task costs; `0` on a failed task.                                                                                               |
| `data.usage.credits_settled`           | `number`          | USD finally taken; set when the task succeeds, otherwise `0`.                                                                            |
| `data.usage.credits_refunded`          | `number`          | USD returned to your balance; equals the reservation on a failed task once the refund is recorded.                                       |
| `data.usage.billable_duration_seconds` | `integer`         | Video only: the seconds the price is based on. Absent when the model reports no duration.                                                |
| `data.request_id`                      | `string`          | Request ID. Include it when you contact support.                                                                                         |
| `data.error_code`                      | `string \| null`  | Failure code; `null` unless the task failed.                                                                                             |
| `data.error_message`                   | `string \| null`  | What went wrong and what to change; `null` unless the task failed.                                                                       |### Finished task`GET /v1/tasks/{task_id}` returns HTTP 200 with `status: "succeeded"` and the result in `data.output`.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "media_type": "image",
    "model": "mj-v8.2",
    "status": "succeeded",
    "stage": "succeeded",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": {
      "media": [
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.png",
          "mime_type": "image/png"
        },
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/1.png",
          "mime_type": "image/png"
        },
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/2.png",
          "mime_type": "image/png"
        },
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/3.png",
          "mime_type": "image/png"
        }
      ],
      "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.png",
      "r2_url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.png",
      "data": {
        "kind": "grid",
        "follow_ups": [
          "variation",
          "upscale",
          "reroll"
        ]
      }
    },
    "usage": {
      "credits_reserved": 0.08,
      "credits_settled": 0.08,
      "credits_refunded": 0,
      "credits_charged": 0.08
    },
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null
  }
}
```#### Output fields| Field                      | Type       | Description                                                                                      |
| -------------------------- | ---------- | ------------------------------------------------------------------------------------------------ |
| `output.media`             | `object[]` | The images: four for a grid, one for an upscale, none for describe. `index` counts these from 1. |
| `output.media[].type`      | `string`   | Always `image`.                                                                                  |
| `output.media[].url`       | `string`   | HTTPS link to the stored image. It is deleted after 7 days; download what you want to keep.      |
| `output.media[].mime_type` | `string`   | The stored file type, `image/png`.                                                               |
| `output.url`               | `string`   | The primary asset: the first image link. Empty for describe.                                     |
| `output.r2_url`            | `string`   | The old name of `output.url`, with the same value; `output.url` is the one to read.              |
| `output.data.kind`         | `string`   | `grid` (four images), `single` (one upscaled image) or `text` (describe).                        |
| `output.data.follow_ups`   | `string[]` | The actions this result accepts as `source_task_id`. Empty when it takes none.                   |
| `output.data.prompts`      | `string[]` | Describe only: the four prompts.                                                                 |### Failed taskA failed task is still HTTP 200 on `GET /v1/tasks/{task_id}`: the failure is in the body. The reservation is returned in full, so nothing is charged.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "media_type": "image",
    "model": "mj-v8.2",
    "status": "failed",
    "stage": "failed",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": null,
    "usage": {
      "credits_reserved": 0.08,
      "credits_settled": 0,
      "credits_refunded": 0.08,
      "credits_charged": 0
    },
    "retryable": true,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": "processing_failed",
    "error_message": "The task failed during processing on our side. Retry; a failed task is refunded.",
    "error": {
      "code": "processing_failed",
      "message": "The task failed during processing on our side. Retry; a failed task is refunded.",
      "retryable": true
    }
  }
}
```| Field                | Type      | Description                                                                                                                                                                                                            |
| -------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data.error_code`    | `string`  | One of `bad_request` and `content_policy_violation` (change the request) or `processing_unavailable`, `processing_timeout`, `processing_failed` and `result_transfer_failed` (try again later). See [Errors](/errors). |
| `data.error_message` | `string`  | A sentence that names the problem and the fix.                                                                                                                                                                         |
| `data.retryable`     | `boolean` | Present only on a failed task: `true` when the same request can succeed if you send it again.                                                                                                                          |
| `data.error`         | `object`  | Present only on a failed task: `code`, `message` and `retryable` in one object, the same values as `data.error_code`, `data.error_message` and `data.retryable`.                                                       |
| `data.usage`         | `object`  | Once the refund is recorded (normally at the moment the task fails): `credits_charged` and `credits_settled` are `0`, and `credits_refunded` equals `credits_reserved`.                                                |## Complete exampleCreate a task, wait for it with the server’s polling hint, and print the result URLs. Set `BEATAPI_API_KEY` in your environment and install `requests`.```python
import os
import time
import uuid

import requests

API = "https://api.beatapi.io"
HEADERS = {"Authorization": f"Bearer {os.environ['BEATAPI_API_KEY']}"}


def create_task(body: dict) -> dict:
    # One Idempotency-Key per logical request: a retry with the same key cannot create a second task.
    headers = {**HEADERS, "Idempotency-Key": str(uuid.uuid4())}
    for attempt in range(3):
        response = requests.post(f"{API}/v1/images/tasks", headers=headers, json=body, timeout=60)
        if response.status_code in (429, 503) and attempt < 2:
            time.sleep(int(response.headers.get("Retry-After", 10)))
            continue
        break
    try:
        payload = response.json()
    except ValueError:  # an edge error page is not JSON
        response.raise_for_status()
        raise
    if not response.ok:
        error = payload["error"]
        raise RuntimeError(f"{response.status_code} {error['code']}: {error['message']} (request_id={error.get('request_id')})")
    return payload["data"]


def wait_for_task(task_id: str, timeout_seconds: int = 1800) -> dict:
    deadline = time.monotonic() + timeout_seconds
    while time.monotonic() < deadline:
        response = requests.get(f"{API}/v1/tasks/{task_id}", headers=HEADERS, timeout=30)
        if response.status_code == 429 or response.status_code >= 500:
            time.sleep(int(response.headers.get("Retry-After", 10)))
            continue
        response.raise_for_status()
        task = response.json()["data"]
        if task["status"] in ("succeeded", "failed"):
            return task
        time.sleep(task.get("poll_after_seconds", 5))
    raise TimeoutError(f"task {task_id} is still running; keep polling later")


task = create_task({
  "model": "mj-v8.2",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
  "aspect_ratio": "16:9"
})
print("created", task["id"])
task = wait_for_task(task["id"])
if task["status"] == "failed":
    raise SystemExit(f"{task['error_code']}: {task['error_message']}")
for item in task["output"]["media"]:
    print(item["url"])
```## Billing- Each call is one task with one price, set by `speed` and `quality` (table below). A generate, variation, reroll, retexture, edit, blend or draft costs one call at those settings, whatever the number of images it returns.
- A follow-up is billed at its source task’s speed and quality. `upscale` and `describe` have one flat price at any speed.
- The price is reserved when the task is created. A request refused with HTTP 400 costs nothing, and a failed task returns the reservation in full: `credits_refunded` then equals `credits_reserved`.
- An `edit` with an image that has no transparency is still drawn and billed.Current list prices, the same as on [Pricing](https://beatapi.io/pricing). An account with a negotiated discount pays less; `data.usage` on the task always shows the amount actually charged.| Option              | List price (USD) |
| ------------------- | ---------------- |
| 1 image · fast\_hd  | \$0.11           |
| 1 image · relax     | \$0.055          |
| 1 image · relax\_hd | \$0.055          |
| 1 image · upscale   | \$0.02           |
| 1 image · describe  | \$0.02           |
| 1 image · fast      | \$0.08           |## Common errors| Error or symptom                                                                                                                              | Cause                                                                                                         | Fix                                                                                      |
| --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| 400 `"index" is required for action upscale`                                                                                                  | An upscale without the image to pick.                                                                         | Send `index` 1 to 4, the position in the source task’s `output.media`.                   |
| 400 `an upscaled image takes no follow-up; to vary it, send action variation with source_task_id of its four-image result and the same index` | A follow-up sent on an upscale result.                                                                        | Send `variation` with the four-image task’s `id` and the same `index`.                   |
| 400 `that image of source_task_id was already upscaled in task_Up4Rk9Ns2Wq7Zx5Mc8Hv1Lb6Tj3Fd0Gy; use that task's result`                      | The same image of the same result was upscaled before.                                                        | Read the result of the task the message names. The refused request costs nothing.        |
| 400 `prompt is not used by action upscale; leave it out`                                                                                      | A field the action does not take.                                                                             | Send only the fields listed for that action.                                             |
| 400 `remove --v from the prompt: the version is fixed at 8.2; leave it out`                                                                   | A prompt copied from midjourney.com with `--v`, `--fast`, `--hd` or another parameter this API sets by field. | Remove it and use the field (`speed`, `quality`, `draft`).                               |
| 400 `source_task_id is a draft, which takes no follow-up; send the prompt again without draft (add --seed N to keep a similar composition)`   | A follow-up on a draft result.                                                                                | Send the prompt again without `draft`.                                                   |
| 400 `source_task_id was made at speed relax and a follow-up runs the same; leave speed out`                                                   | A follow-up with another `speed` or `quality` than its source task.                                           | Leave both fields out on follow-ups.                                                     |
| Four images that look unchanged after `edit`                                                                                                  | The image had no transparent areas, so nothing was cut out to redraw. It was still billed.                    | Send a PNG with the parts to change made transparent.                                    |
| Task `failed` after images were sent                                                                                                          | A link opened a web page, a login page or an expired URL, or did not download within a few seconds.           | Link directly to the image file, or upload it with `POST /v1/files`. Nothing is charged. |
| Task `failed` with `content_policy_violation`                                                                                                 | The prompt or an image was refused by moderation.                                                             | Change the prompt or the image. Retrying unchanged fails again; nothing is charged.      |
| An image link no longer opens                                                                                                                 | Results are deleted after 7 days.                                                                             | Download results soon after the task succeeds.                                           |## HTTP errors at a glanceErrors before a task exists arrive as a non-2xx response, and nothing is charged. Branch on `error.code` or `error.retryable`; `message` names the problem. The full list and retry policy are on [Errors](/errors).```json
{
  "error": {
    "code": "bad_request",
    "message": "\"prompt\" is required",
    "retryable": false,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV"
  }
}
```| HTTP status | `error.code`                                                                                  | What to do                                                                                                            |
| ----------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| 400         | `bad_request`, `content_policy_violation`                                                     | Fix the request; the message names the field. Do not retry unchanged.                                                 |
| 401         | `missing_api_key`, `invalid_api_key` (older clients may see `unauthorized`)                   | Send a valid key as `Authorization: Bearer <key>`.                                                                    |
| 402         | `insufficient_credits`                                                                        | Top up, or raise the key’s quota, then send it again.                                                                 |
| 403         | `forbidden`                                                                                   | The key or account may not use this model (for example, free credit only covers some models). Do not retry unchanged. |
| 404         | `not_found`                                                                                   | On `GET /v1/tasks/{task_id}`: the task does not exist for this key’s account. Check the ID.                           |
| 409         | `idempotency_conflict`                                                                        | Use a new `Idempotency-Key`, or wait for the first request with this key to finish.                                   |
| 429         | `rate_limit_exceeded`                                                                         | Wait `Retry-After` seconds (also `error.retry_after_seconds`), then retry.                                            |
| 500         | `internal_error`                                                                              | Retry with backoff; contact support with `request_id` if it continues.                                                |
| 503         | `processing_unavailable`, `processing_timeout`, `processing_failed`, `result_transfer_failed` | Nothing was charged. Retry with exponential backoff.                                                                  |

Reference: https://docs.beatapi.io/api-reference/image-api/mj-v8-2

## Authentication

- `Authorization` header (bearer token, required) — Send your API key as `Authorization: Bearer <BEATAPI_API_KEY>`.

## Servers

- `https://api.beatapi.io` (Direct, default)
- `https://api.beatapi.io` (API)

## Request

### Headers

- `Idempotency-Key` (string, optional) — Send the body as JSON with `Content-Type: application/json`. `Idempotency-Key` is optional: send a unique value (at most 255 characters) per logical request and reuse it only to retry that exact body. Within 24 hours a retry with the same key and body returns the first response again with `Idempotent-Replayed: true`; the same key with a different body returns `409 idempotency_conflict`. Responses other than 2xx are not stored, so a retry after a 400 or 402 runs again.

### Body (application/json)

This endpoint expects a MjV82ImageRequest.

- `model` (enum, required) — The model to run. **Value**: `mj-v8.2` **If the value is wrong** - Missing: `"model" is required` - Unknown model ID: `"model" mj-v7 is not catalogued` - A video model sent to this endpoint: `"model" seedance-2.5 is served by POST /v1/videos/tasks, not this endpoint`
  - Allowed values: `mj-v8.2`
- `action` (enum, optional, default: generate) — The operation to run. Each action takes only its own fields (see the input modes above); any other field is refused, so you never pay for a setting that had no effect. **Allowed values**: `generate`, `variation`, `upscale`, `reroll`, `retexture`, `edit`, `blend`, `describe` **Default**: `generate` - `generate` starts afresh. `variation`, `upscale` and `reroll` work on a four-image result; an upscaled image takes no follow-up. - `retexture`, `edit`, `blend` and `describe` start from your own images in `images`. - Input is not case-sensitive; the documentation writes the lower-case form. **If the value is wrong** - A value not in the list: `"action" must be one of: [generate variation upscale reroll retexture edit blend describe]` - A field the action does not take: `quality is not used by action retexture; leave it out`
  - Allowed values: `generate`, `variation`, `upscale`, `reroll`, `retexture`, `edit`, `blend`, `describe`
- `aspect_ratio` (enum, optional) — Shape of the image as width:height, for `generate` and `blend`. **Allowed values**: `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `16:9`, `9:16`, `21:9`, `9:21`, `5:4`, `4:5`, `2:1`, `1:2` - A generate without it is drawn `1:1`. - `blend` takes only `1:1` (its default), `3:2` or `2:3`. - For any other shape write `--ar W:H` with whole numbers in `prompt`, for example `--ar 7:4`; it overrides this field. **If the value is wrong** - A value not in the list: `"aspect_ratio" must be one of: [1:1 4:3 3:4 3:2 2:3 16:9 9:16 21:9 9:21 5:4 4:5 2:1 1:2]` - A blend with another shape: `"aspect_ratio" for blend is one of: 1:1, 3:2, 2:3`
  - Allowed values: `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `16:9`, `9:16`, `21:9`, `9:21`, `5:4`, `4:5`, `2:1`, `1:2`
- `draft` (boolean, optional) — For `generate` only. `true` returns 24 quick 512 px drafts at a generate’s price, to explore a prompt before rendering it in full. - Works at either `speed`; cannot be combined with `quality` `hd`. - A draft takes no follow-up and its images cannot be picked. To render a prompt in full, send it again without `draft`; write `--seed N` in the draft’s prompt for a similar, not identical, composition. **If the value is wrong** - Not a boolean: `"draft" must be a boolean` - A follow-up on a draft: `source_task_id is a draft, which takes no follow-up; send the prompt again without draft (add --seed N to keep a similar composition)`
- `images` (list of string, optional) — Your own images as public HTTPS links. For `generate` they are image prompts (1 to 5); `retexture`, `edit` and `describe` take exactly one; `blend` takes 2 to 5. **Items**: 1–5 Each item is a public `https://` URL. For a local file, [upload it first](/quick-guide#upload-an-input-file) with `POST /v1/files` and pass the returned `data.url`. - Links must be public and download within a few seconds. Have a local file? Upload it with `POST /v1/files` and send the returned link. - For `edit`, send a PNG and cut out (make transparent) the parts to change. An image without transparency, such as any JPEG, is still drawn and billed. - Follow-ups (`variation`, `upscale`, `reroll`) work on `source_task_id` and do not take `images`. - Positions in error messages are 0-based: `images[0]` is the first link. **If the value is wrong** - Missing on retexture, edit, blend or describe: `"images" is required for action describe` - Fewer than blend needs: `action blend needs at least 2 image(s) in "images"` - More than one for describe, retexture or edit: `action describe takes at most 1 image(s) in "images"` - More than five: `"images" accepts at most 5 items` - Not an https:// link: `"images[0]" must be a public HTTPS URL`
- `index` (integer, optional) — Which image of a four-image result to work on, 1 to 4. It is 1-based and counts `output.media` of the source task. **Range**: 1–4 - Required for `upscale` and `variation`. - Not used by `reroll` or by actions without `source_task_id`. **If the value is wrong** - Missing on upscale or variation: `"index" is required for action upscale` - Not a whole number from 1 to 4: `"index" is outside its supported range`
- `prompt` (string, optional) — What to draw, as on midjourney.com: the description first, then any Midjourney parameters such as `--ar 3:2 --s 250`. For `retexture` and `edit` it describes the new look. **Length**: 1–2048 characters - Required for `generate` unless `images` holds two or more links, and for `retexture` and `edit`. Other actions do not take it. - For `generate`, the text without links and `--` parameters is at most 1024 characters. - Parameters that the API sets by field, and those it does not support, are refused; see the parameter table further down. **If the value is wrong** - Left out on a generate with fewer than two images: `generate needs "prompt"; only two or more images may go without one` - Left out on retexture or edit: `"prompt" is required for action retexture` - Sent with an action that does not take it: `prompt is not used by action upscale; leave it out` - Empty or longer than the limit: `"prompt" has an unsupported length` - The text without links and parameters is too long: `the prompt's text (without links and --parameters) is at most 1024 characters` - A version parameter: `remove --v from the prompt: the version is fixed at 8.2; leave it out` - A speed parameter: `remove --fast from the prompt: set the speed field to fast instead` - A decimal ratio: `--ar takes whole numbers, like 139:100 instead of 1.39:1` - `--q` outside 1 to 4: `--q takes 1, 2, 3 or 4 (detail; 4 is the most detailed); for a bigger picture set quality hd`
- `quality` (enum, optional, default: standard) — `hd` draws about 2K instead of the standard size. It is set when you generate and cannot be added later. **Allowed values**: `standard`, `hd` **Default**: `standard` - At `fast`, `hd` costs more; at `relax` it costs the same. - `upscale` returns the image at the pixel size it was drawn at; it does not enlarge it. Ask for `hd` on the first call when you want a bigger picture. - A follow-up runs at its source task’s quality. Leave the field out on a follow-up, or send the same value. - `retexture`, `edit`, `blend` and `describe` do not take it. **If the value is wrong** - A value not in the list: `"quality" must be one of: [standard hd]` - Together with draft: `draft cannot be combined with quality hd` - A follow-up asking for another quality than its source task: `source_task_id was made at quality hd and a follow-up runs the same; leave quality out`
  - Allowed values: `standard`, `hd`
- `source_task_id` (string, optional) — For a follow-up: the `id` of your own earlier Midjourney task that it works on. The task must have succeeded. - Read `output.data.follow_ups` of that task first: it lists the actions the result accepts. Any other follow-up is refused at no charge. - An upscaled image takes no follow-up. To vary it, send `variation` with the `source_task_id` of its four-image result and the same `index`. - Results of `upscale`, `retexture`, `edit`, `describe` and drafts take no follow-up. **If the value is wrong** - Not a task id: `"source_task_id" must be the id of one of your earlier tasks: "task_" followed by 32 letters or digits` - Missing on a follow-up: `"source_task_id" is required for action upscale: the id of your own Midjourney task it works on` - The source task is still running or failed: `source_task_id has not finished successfully; wait for it to succeed and try again` - A task of another model: `source_task_id was made by seedream-5.5, not Midjourney; name one of your Midjourney tasks` - A follow-up on an upscaled image: `an upscaled image takes no follow-up; to vary it, send action variation with source_task_id of its four-image result and the same index` - A result of retexture, edit or describe: `source_task_id is the result of retexture, which takes no follow-up` - The same image of the same result upscaled again: `that image of source_task_id was already upscaled in task_Up4Rk9Ns2Wq7Zx5Mc8Hv1Lb6Tj3Fd0Gy; use that task's result` - An action that result does not list in follow_ups: `this result does not support action upscale; generate the image again and continue from the new result`
- `speed` (enum, optional, default: fast) — `fast` (the default) usually finishes a generate in 1 to 3 minutes; `relax` takes 2 to 5 minutes and costs less. **Allowed values**: `fast`, `relax` **Default**: `fast` - A follow-up runs at its source task’s speed and is billed at it. Leave the field out on a follow-up, or send the same value. - `describe` does not take it. **If the value is wrong** - A value not in the list: `"speed" must be one of: [fast relax]` - A follow-up asking for another speed than its source task: `source_task_id was made at speed relax and a follow-up runs the same; leave speed out`
  - Allowed values: `fast`, `relax`
- `callback_url` (string, optional) — An address to notify when this task succeeds or fails: a public HTTPS URL on the same scheme, host and port as one of your enabled [webhook endpoints](/webhooks), which signs the delivery with its `secret`. **Length**: ≤ 2048 characters - Register the endpoint first with `POST /v1/webhooks`. BeatAPI sends `task.succeeded` or `task.failed` with the same body, headers and retries as an account webhook; an account endpoint subscribed to the event receives it too, and an address identical to that endpoint’s is notified once. - The callback stops when the signing endpoint is deleted, disabled or moved to another host. **If the value is wrong** - The value is not a string: `"callback_url" must be a string.` - The address is longer than 2048 characters: `"callback_url" must be at most 2048 characters.` - It is not a URL, or has no host or no `http` or `https` scheme: `"callback_url" must be a valid https URL.` - It uses `http`, or points to a private or otherwise non-public address: `"callback_url" must be a public HTTPS URL.` - No enabled webhook endpoint has the same scheme, host and port: `"callback_url" must be on the host of one of your active webhook endpoints, whose secret signs it; register one with POST /v1/webhooks.`

## Response

### 201

The task object. `output` is `null` until the task succeeds. Fields marked “while running” disappear once the task finishes.

- `data` (QueuedTask, required) — Accepted or current BeatAPI task state.

## Errors

### 400 Bad Request Error

`bad_request`, `content_policy_violation` Fix the request; the message names the field. Do not retry unchanged.

- `map from string to any`

### 401 Unauthorized Error

`missing_api_key`, `invalid_api_key` (older clients may see `unauthorized`) Send a valid key as `Authorization: Bearer <key>`.

- `map from string to any`

### 402 Payment Required Error

`insufficient_credits` Top up, or raise the key’s quota, then send it again.

- `map from string to any`

### 403 Forbidden Error

`forbidden` The key or account may not use this model (for example, free credit only covers some models). Do not retry unchanged.

- `map from string to any`

### 409 Conflict Error

`idempotency_conflict` Use a new `Idempotency-Key`, or wait for the first request with this key to finish.

- `map from string to any`

### 429 Too Many Requests Error

`rate_limit_exceeded` Wait `Retry-After` seconds (also `error.retry_after_seconds`), then retry.

- `map from string to any`

### 500 Internal Server Error

`internal_error` Retry with backoff; contact support with `request_id` if it continues.

- `map from string to any`

### 503 Service Unavailable Error

`processing_unavailable`, `processing_timeout`, `processing_failed`, `result_transfer_failed` Nothing was charged. Retry with exponential backoff.

- `map from string to any`

## Types

### QueuedTask

- `id` (string, required) — Stable BeatAPI task ID used for polling and support.
- `object` (enum, required) — Object discriminator; always `task`.
  - Allowed values: `task`
- `task_kind` (enum, required) — Public task family that determines which capability fields are present. `data` is a data capability run as a task (`data:web.research`), polled through `POST /v1/capabilities/run`.
  - Allowed values: `workflow`, `effect`, `image`, `video`, `audio`, `data`
- `capability_id` (string, required) — Stable BeatAPI workflow, Effect, generation model, or data capability ID (such as `web.research`) selected when the task was accepted.
- `capability_version` (integer, required) — Always `1`.
- `status` (enum, required) — Current task lifecycle status. Stop polling at `succeeded` or `failed`; Music Video can also require manual action.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `stage` (enum, required) — Always repeats `status`. Kept for compatibility; read `status`.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — Unix timestamp when BeatAPI accepted the task.
- `updated_at` (integer, required) — Unix timestamp of the latest task update.
- `completed_at` (integer, required, nullable) — Terminal Unix timestamp, or null while work is in progress.
- `output` (QueuedTaskOutput, required, nullable) — Output is null until the task succeeds.
- `request_id` (string, required) — Correlation ID to retain for logs and BeatAPI support.
- `error_code` (string, required, nullable) — Machine-readable terminal failure code, or null when no task failure is recorded. `task_cancelled` marks a task you cancelled while it waited in its model's queue.
- `error_message` (string, required, nullable) — Human-readable terminal failure detail, or null when no task failure is recorded.
- `workflow` (enum, optional) — Present for workflow tasks; identifies the selected BeatAPI workflow.
  - Allowed values: `music-video`, `ecommerce-video`, `video-analysis`
- `effect_id` (string, optional) — Present for Effect tasks; stable selected Effect ID.
- `effect_version` (integer, optional) — Present for Effect tasks; immutable Effect version used for processing.
- `media_type` (enum, optional) — Present when task_kind is image or video.
  - Allowed values: `image`, `video`, `audio`
- `model` (string, optional) — Stable BeatAPI model alias. It is independent from internal execution routing.
- `storyboard` (Storyboard, optional) — Music Video storyboard metadata when available.
- `poll_after_seconds` (integer, optional) — Present while the task is running: how long to wait before the next status call (5 for images, 8 for video and Effects, 10 for workflows and data tasks). Follow it instead of a fixed interval. Absent on a terminal task.
- `typical_seconds` (QueuedTaskTypicalSeconds, optional) — Present while the task is running, when enough recent finishes exist: how long this task's model recently took from accepted to succeeded, measured on this gateway. Past `p90` with no change the task is running long; there is no ETA beyond that.
- `queue` (QueuedTaskQueue, optional) — Present only while the task waits for its model's capacity (read by id, not in the task list). A task still waiting at `deadline` fails with `processing_unavailable` and is refunded. Cancel it with `POST /v1/tasks/{task_id}/cancel`.
- `usage` (TaskUsage, optional) — USD reservation, settlement, refund, and optional billable duration for this task.
- `error` (QueuedTaskError, optional) — Present on a failed task: the terminal failure as one object. Its values are the same as the flat `error_code`, `error_message` and `retryable`, which stay.
- `retryable` (boolean, optional) — Present on a failed task: whether resubmitting could succeed. True when the task failed on our side or timed out (a failed task is not charged); false when it was refused for content or bad input. Same code-to-retryable rule as the error envelope.

### QueuedTaskOutput

Output is null until the task succeeds.

- QueuedTaskOutput0
- QueuedTaskOutput1
- QueuedTaskOutput2

### Storyboard

- `shots` (list of StoryboardShot, required) — Ordered Music Video storyboard shots. The array may be empty before storyboard generation completes.

### QueuedTaskTypicalSeconds

Present while the task is running, when enough recent finishes exist: how long this task's model recently took from accepted to succeeded, measured on this gateway. Past `p90` with no change the task is running long; there is no ETA beyond that.

- `p50` (integer, required) — Median seconds.
- `p90` (integer, required) — Ninetieth-percentile seconds.
- `samples` (integer, required) — Finished tasks the figures rest on.
- `window` (string, required) — The window measured, such as `7d`.

### QueuedTaskQueue

Present only while the task waits for its model's capacity (read by id, not in the task list). A task still waiting at `deadline` fails with `processing_unavailable` and is refunded. Cancel it with `POST /v1/tasks/{task_id}/cancel`.

- `position` (integer, required) — Place in the queue; 1 is next.
- `ahead` (integer, required) — Tasks of the same model ahead of this one.
- `queued_at` (integer, required) — Unix seconds when the task was queued.
- `deadline` (integer, required) — Unix seconds after which the task stops waiting.

### TaskUsage

- `credits_reserved` (double, required) — USD amount reserved for this task. The compatibility field name is retained; 1 Credit equals $1 USD.
- `credits_charged` (double, required) — USD amount charged. `0` on a failed task, because the reserved amount was returned.
- `credits_settled` (double, required) — USD amount settled after successful work.
- `credits_refunded` (double, required) — USD amount returned after a failed task. On a failed task `credits_reserved` is the amount held at create, `credits_charged` and `credits_settled` are `0`, and `credits_refunded` is the amount returned.
- `billable_duration_seconds` (integer, optional) — Server-detected or request-declared billable duration used for USD calculation.

### QueuedTaskError

Present on a failed task: the terminal failure as one object. Its values are the same as the flat `error_code`, `error_message` and `retryable`, which stay.

- `code` (string, required) — Machine-readable failure code, the same value as `error_code`.
- `message` (string, required) — English sentence that states the cause, the same value as `error_message`.
- `retryable` (boolean, optional) — Whether resubmitting could succeed, the same value as `retryable`. Absent when `retryable` is absent.

### QueuedTaskOutput0

- `media` (list of QueuedTaskOutputOneOf0MediaItems, required) — BeatAPI-hosted result assets.
- `url` (string, required) — The primary asset's URL, the one to read when you want a single file (the first video, else the first image). The same value as `r2_url`.
- `r2_url` (string, required, deprecated) — Deprecated — read `url`. The same value as `url`, kept only for clients that already read it.
- `tracks` (list of QueuedTaskOutputOneOf0TracksItems, optional) — Audio tasks only. One entry for each song or stem the call made, beside the files in `media`.
- `data` (any, optional) — Audio tasks only. What an action returns that is not a file, such as lyrics, aligned lyrics, a boosted style, a persona id or MIDI notes.

### QueuedTaskOutput1

- `text` (string, required) — Completed video analysis text.
- `usage` (QueuedTaskOutputOneOf1Usage, required) — Measured token usage used for final USD settlement.
- `finish_reason` (string, required, nullable) — Why the model stopped generating.

### QueuedTaskOutput2

A data task's result: the capability's own result object, such as `web.research` with `research_notes` and `sources` (in a view: `items`).

- `object` (string, required) — The result type, such as `web.research`.
- `request_id` (string, optional) — The ID of the task that produced the result.
- `query` (string, optional) — The question that was researched.
- `status` (enum, optional) — `partial` when part of the research could not be finished; `partial_reasons` says why.
  - Allowed values: `complete`, `partial`
- `research_notes` (string, optional) — The research notes.
- `sources` (list of map from string to any, optional) — The sources behind the notes.
- `partial_reasons` (list of string, optional) — Present when `status` is `partial`.
- `x_search` (map from string to any, optional) — How much X was searched, when the run searched X at all.

### StoryboardShot

- `id` (string, required) — BeatAPI shot id. Use this id for media retrieval, edit, and compose operations.
- `index` (integer, required) — Zero-based shot order in the storyboard.
- `status` (enum, required) — Current lifecycle state for this storyboard shot.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — Unix timestamp when the shot record was created.
- `updated_at` (integer, required) — Unix timestamp when the shot record last changed.
- `duration_seconds` (integer, optional) — Planned or generated shot duration in seconds.
- `prompt` (string, optional) — Creative instruction used to generate this shot.
- `lyric_text` (string, optional) — Lyric segment aligned with this shot when available.
- `media` (StoryboardShotMedia, optional) — Present only after the shot media has been materialized or after a shot edit finishes.

### QueuedTaskOutputOneOf0MediaItems

- `type` (enum, required) — Result asset type.
  - Allowed values: `image`, `video`, `audio`
- `url` (string, required) — BeatAPI-hosted HTTPS result URL.
- `mime_type` (string, required) — Result asset MIME type.

### QueuedTaskOutputOneOf0TracksItems

- `id` (string, required) — The id a follow-up sends as `audio_id`.
- `title` (string, optional) — Song title.
- `name` (string, optional) — Stem name on a split result.
- `tags` (string, optional) — Style tags.
- `lyrics` (string, optional) — Lyrics of the song.
- `duration` (double, optional) — Length in seconds.
- `audio_url` (string, optional) — The song or stem file.
- `image_url` (string, optional) — Cover art.

### QueuedTaskOutputOneOf1Usage

Measured token usage used for final USD settlement.

- `input_tokens` (integer, required) — Tokens consumed by the prompt and video input.
- `output_tokens` (integer, required) — Tokens consumed by visible output and model reasoning.
- `total_tokens` (integer, required) — Total measured input and output tokens.

### StoryboardShotMedia

Present only after the shot media has been materialized or after a shot edit finishes.

- `type` (string, optional) — Hosted media type for the materialized shot.
- `url` (string, optional) — BeatAPI-hosted HTTPS URL for the materialized shot.
- `mime_type` (string, optional) — MIME type of the hosted shot media.

## Examples

### Generate four images

**Request**

```json
{
  "model": "mj-v8.2",
  "aspect_ratio": "16:9",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5,
    "usage": {
      "credits_reserved": 0.08,
      "credits_charged": 0.08,
      "credits_settled": 0,
      "credits_refunded": 0
    }
  }
}
```

**SDK Code**

```python Generate four images
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "mj-v8.2",
    "aspect_ratio": "16:9",
    "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Generate four images
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","aspect_ratio":"16:9","prompt":"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Generate four images
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Generate four images
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\n}"

response = http.request(request)
puts response.read_body
```

```java Generate four images
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\n}")
  .asString();
```

```php Generate four images
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "aspect_ratio": "16:9",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Generate four images
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Generate four images
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "aspect_ratio": "16:9",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Vary image 3

**Request**

```json
{
  "model": "mj-v8.2",
  "action": "variation",
  "index": 3,
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python Vary image 3
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "mj-v8.2",
    "action": "variation",
    "index": 3,
    "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Vary image 3
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","action":"variation","index":3,"source_task_id":"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Vary image 3
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Vary image 3
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\n}"

response = http.request(request)
puts response.read_body
```

```java Vary image 3
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\n}")
  .asString();
```

```php Vary image 3
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "action": "variation",
  "index": 3,
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Vary image 3
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Vary image 3
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "variation",
  "index": 3,
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Upscale image 2

**Request**

```json
{
  "model": "mj-v8.2",
  "action": "upscale",
  "index": 2,
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python Upscale image 2
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "mj-v8.2",
    "action": "upscale",
    "index": 2,
    "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Upscale image 2
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","action":"upscale","index":2,"source_task_id":"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Upscale image 2
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Upscale image 2
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\n}"

response = http.request(request)
puts response.read_body
```

```java Upscale image 2
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\n}")
  .asString();
```

```php Upscale image 2
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "action": "upscale",
  "index": 2,
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Upscale image 2
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Upscale image 2
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "upscale",
  "index": 2,
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Describe an image

**Request**

```json
{
  "model": "mj-v8.2",
  "action": "describe",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ]
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python Describe an image
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "mj-v8.2",
    "action": "describe",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Describe an image
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","action":"describe","images":["https://cdn.beatapi.io/samples/smart-bottle.png"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Describe an image
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Describe an image
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Describe an image
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\n}")
  .asString();
```

```php Describe an image
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "action": "describe",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Describe an image
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Describe an image
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "describe",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Image prompt and style reference at relax, in HD

**Request**

```json
{
  "model": "mj-v8.2",
  "aspect_ratio": "4:5",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "quality": "hd",
  "speed": "relax"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python Image prompt and style reference at relax, in HD
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "mj-v8.2",
    "aspect_ratio": "4:5",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"],
    "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
    "quality": "hd",
    "speed": "relax"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Image prompt and style reference at relax, in HD
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","aspect_ratio":"4:5","images":["https://cdn.beatapi.io/samples/smart-bottle.png"],"prompt":"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200","quality":"hd","speed":"relax"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Image prompt and style reference at relax, in HD
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Image prompt and style reference at relax, in HD
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\n}"

response = http.request(request)
puts response.read_body
```

```java Image prompt and style reference at relax, in HD
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\n}")
  .asString();
```

```php Image prompt and style reference at relax, in HD
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "aspect_ratio": "4:5",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "quality": "hd",
  "speed": "relax"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Image prompt and style reference at relax, in HD
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Image prompt and style reference at relax, in HD
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "aspect_ratio": "4:5",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"],
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "quality": "hd",
  "speed": "relax"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Blend two images

**Request**

```json
{
  "model": "mj-v8.2",
  "action": "blend",
  "aspect_ratio": "3:2",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ]
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python Blend two images
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "mj-v8.2",
    "action": "blend",
    "aspect_ratio": "3:2",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Blend two images
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","action":"blend","aspect_ratio":"3:2","images":["https://cdn.beatapi.io/samples/smart-bottle.png","https://cdn.beatapi.io/samples/neon-singer.png"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Blend two images
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Blend two images
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Blend two images
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\n}")
  .asString();
```

```php Blend two images
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "action": "blend",
  "aspect_ratio": "3:2",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Blend two images
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Blend two images
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "blend",
  "aspect_ratio": "3:2",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```