---
title: "The asynchronous order model"
url: https://lumean.app/tr/developers/docs/guide/async
locale: tr
description: "POST /orders responds right away, and the result arrives later. Order types, statuses, chunks, and how to find out an order is ready."
updated: 2026-11-06
source_locale: en
sources: [post-orders, get-orders, get-orders-order, get-orders-order-items, post-orders-order-cancel]
errors: [invalid-order-status, policy-flagged, service-not-found, storage-expired]
spec_version: 1.0.0
---

# The asynchronous order model

`POST /orders` does not generate anything by itself. It validates the request, holds funds and
the key's token quota, queues the task, and responds with `201` and status `created`. The
result arrives later, usually within minutes.

## The creation response

| Field | Value in the `201` response |
| --- | --- |
| `id` | The order UUID. Every later call goes to `/orders/{order}/…` |
| `status` | `created` |
| `result` | `null`. The response has no `files[]` or `service_files[]` |
| `total_chunks` | The number of chunks the server split the text into. `0` means the text has not been split yet |
| `completed_chunks`, `progress_percent` | `0` |
| `eta_seconds`, `eta_at` | `null`. An estimate exists only while the order is `in_progress` |
| `price_units` | The amount held, in LMC minor units. On a chunk, the field with the same name holds tokens |

Store the `id`. Without it, the only way to find the order is through the list.

### POST /orders

Create Order

Справочник: https://lumean.app/tr/developers/docs/api/post-orders

## Order types

`POST /orders` takes either `template_id` or `task_type`, and one of them is required. A
template sets the service and all its settings, so text-to-speech orders are created only from
a template. An order without a template works where the service code matches the task type.

| `task_type` | How it is created | Where the parameters go | Files in `result.files[]` |
| --- | --- | --- | --- |
| `tts` | only with `template_id` | `input_text` at the request root | 1 merged track; subtitles go to `service_files[]` |
| `sfx` | without a template | `task_data.text`, plus `duration_seconds`, `prompt_influence`, `loop`, `output_format` | 1 |
| `music` | without a template | `task_data.prompt`, plus `n_variants` (1..4), `music_length_ms`, `lyrics_text`, `force_instrumental` | one file per variant, not merged |
| `voice_search` | without a template | audio in `input_files`, `task_data.top` (1..50) | none: the result is a list of similar voices |

```bash
curl -s -X POST "$BASE/orders" -H "X-API-KEY: $KEY" -H "Content-Type: application/json" -d '{
  "task_type": "music",
  "task_data": { "prompt": "Lo-fi hip hop, calm, rainy night", "n_variants": 3,
                 "music_length_ms": 30000, "force_instrumental": true }
}'
```

The sound description goes in `text` for SFX and in `prompt` for Music. Put the keys at the
root of `task_data`. `GET /templates/config-options` shows the same parameters inside
`sfx_settings` and `music_settings` sections, but those wrappers do not belong in a request.
With a wrapper, the required key ends up inside it, so a template or `task_data` gets a `422`
saying the field is required. In an order's `config_override`, the wrapper is dropped without
an error.

These orders are priced by the number of generations, not by length. `sfx` and `voice_search`
cost one rate per order, and `music` costs the rate times `n_variants`. A thirty-second track
costs the same as a ten-second one.

The server fills in missing keys from the service's `default_config` and keeps the values you
sent. That is why an order's saved `task_data` can contain keys that were not in the request.
Set `skip_service_defaults: true` to turn this off.

An API key can create only the four types in the table. The other `TaskType` values — `image`,
`txt2img`, `remix`, `image_edit`, and `voice_clone` — pass validation, but the order gets a
`422` with `reason: service_not_found`. `cartesia_dub` and `elevenlabs_dub` are dubs of a finished
order: `POST /orders` doesn't create them either, only `POST /orders/{order}/dub` does (see
[Dubbing](/developers/docs/guide/dubbing)). The `GET /orders?task_type[]=…` filter accepts all
eleven values.

### 422 · `service_not_found` — service_not_found — service not found

| Что произошло | Что делать |
| --- | --- |
| The order was not created. The response is a 422 with `reason: "service_not_found"` and no `errors`. The request passed field validation, but no service was found for it. | Send only the types that an API key can create. |

`Retry-After`: нет. Разбор: https://lumean.app/tr/developers/docs/errors/service-not-found

## Order statuses

Значения `OrderStatus` — в справочнике объектов: https://lumean.app/tr/developers/docs/objects#o-OrderStatus

Terminal statuses: `completed`, `result_delivered`, `failed`, `compensated`, `cancelled`. An
order in one of them no longer changes, so there is no need to keep polling it. File retention,
7 days by default, starts when the order reaches a terminal status.

Non-terminal statuses: `created`, `pending`, `in_progress`, `partially_completed`.

```text
Девять статусов заказа. Опрашивать дальше имеет смысл только в НЕтерминальных.

АКТИВНЫЕ (не терминальные)
  created  →  pending  →  in_progress
                              │
                              ├─→ completed             ТЕРМИНАЛЬНЫЙ
                              │      └─→ result_delivered   ТЕРМИНАЛЬНЫЙ
                              │
                              ├─→ partially_completed   НЕ ТЕРМИНАЛЬНЫЙ ← ловушка:
                              │      часть чанков готова, сбойные ждут
                              │      POST /orders/{order}/items/retry-failed
                              │
                              ├─→ failed                ТЕРМИНАЛЬНЫЙ
                              │      └─→ compensated        ТЕРМИНАЛЬНЫЙ
                              │
                              └─→ cancelled             ТЕРМИНАЛЬНЫЙ

Отменить (cancelled) можно из любого активного статуса, а не только из in_progress.
Терминальные: completed, result_delivered, failed, compensated, cancelled.
```

| Status | Terminal | What to do |
| --- | --- | --- |
| `created`, `pending` | no | Wait. The order can still be cancelled in these statuses |
| `in_progress` | no | Wait and watch `completed_chunks` and `progress_percent`. It cannot be cancelled |
| `partially_completed` | no | Processing has ended and some chunks failed. Finished files can be downloaded. Retry the failed chunks or cancel the order |
| `completed` | yes | Get links for `result.files[]` with `POST /storage/url` |
| `result_delivered` | yes | Same as `completed`: the files are available until retention ends |
| `failed`, `compensated` | yes | No files. `result` may contain only `user_message`, a human-readable reason for the failure. Create a new order |
| `cancelled` | yes | The order was cancelled with `POST /orders/{order}/cancel`. From `created` or `pending`, funds and quota are returned in full. From `partially_completed`, finished chunks stay paid and the funds for failed ones are returned |

`failed` and `compensated` both mean the order ended with an error. An ordinary execution
failure ends in `compensated`, and by then the charge has already been returned. `user_message`
is translated for display to a person, so do not branch on it in code.

Cancellation is accepted in `created`, `pending`, and `partially_completed`. In any other
status, `POST /orders/{order}/cancel` returns `400`.

## Partially completed orders

An order moves to `partially_completed` when some of its chunks fail. The finished chunks are
kept, and the failed ones wait for a decision: a retry or a cancellation. This status is not
terminal. A handler that treats everything except `created`, `pending`, and `in_progress` as
final will leave such an order unfinished, even though it can still reach `completed`.

### 202 · `policy_flagged` — policy_flagged — chunk rejected by the content policy

| Что произошло | Что делать |
| --- | --- |
| This is not an HTTP error. The code comes as the value of `OrderItem.status` and as the `reason` in the `skipped[]` array of the 202 response to `POST /orders/{order}/items/retry-failed`. The order then moves to `partially_completed`. This status is not final: finished chunks stay in place, and rejected ones wait for action. | Fetch the current chunk text, rephrase the disputed fragment, and retry that chunk on its own with the new text. The API does not report the rejection reason, so edit at your discretion. Retry limits: no more than 5 attempts, and chunk retry is not available for `sfx` and `music`. `GET /orders/{order}/items/{item}/text` returns the length limits: within `free_length` a retry is free, up to `max_billable_length` it comes with a surcharge. `POST /orders/{order}/retry` does not fit here: it does not accept orders in `partially_completed`. |

`Retry-After`: нет. Разбор: https://lumean.app/tr/developers/docs/errors/policy-flagged

[Retries and idempotency](/developers/docs/guide/retries) explains how to retry failed chunks.
`POST /orders/{order}/retry` does not help here: it does not accept `partially_completed` and
creates a new paid order.

## Chunks

Before generation, the server splits the text into chunks (`OrderItem`), and the work is done
chunk by chunk. In this documentation, "chunk" and "fragment" mean the same thing. The API
fields are `chunk_index`, `total_chunks`, and `completed_chunks`.

Chunk statuses differ from order statuses:

| Chunk status | Meaning |
| --- | --- |
| `pending` | Waiting to be processed |
| `processing` | Being processed |
| `completed` | Done |
| `failed` | Technical error |
| `policy_flagged` | Rejected by the content policy |

Chunks come in `items[]` on every order, both in `GET /orders/{order}` and in the
`GET /orders` list. `GET /orders/{order}/items` returns them on their own. Retries and
regenerations are stored as separate records with the same `chunk_index` and a `parent_item_id`
reference, so the length of `items[]` differs from `total_chunks`. Track progress with
`completed_chunks` and `total_chunks`: they count only the original chunks.

### GET /orders/{order}/items

List Order Items

Справочник: https://lumean.app/tr/developers/docs/api/get-orders-order-items

## Finding out an order is ready

**Правильно**

Subscribe to `private-order.task.{orderId}` (one order) or `private-orders.{userId}` (all
orders on the account) and listen for `status.changed`, `item.status.changed`, and `progress`.
Each event arrives at the moment of the transition, with no extra requests.

**Неправильно**

Poll `GET /orders/{order}` every second. That is dozens of extra requests per order, they use
up the key's request rate limit, and you still get up to a second of delay.

Polling works too, especially for short orders. Use an interval of 2–5 seconds, since every
request counts toward the key's rate limit. `eta_seconds` and `eta_at` help pick the pause. One
`GET /orders?status=in_progress` request checks several orders at once. Cap the number of
attempts: `failed` is an answer too.

A bulk chunk retry works the same way. A `202` response means the plan was accepted. The result
arrives later, as a `bulk_retry.completed` event or in `GET /orders/{order}/items`.

Three channels relate to orders: `private-orders.{userId}`, `private-order.task.{orderId}`,
and `private-chunks.preview.{userId}`. The other channels and the event format are described in
[Realtime](/developers/docs/guide/realtime).

## Result files

`result.files[]` holds file paths, not links. `POST /storage/url` returns a download link.
Request it soon after `completed`, because files are kept for a limited time.
[Files, links and storage](/developers/docs/guide/files) explains how to check that a file is
still available.

---

- Bu sayfa tarayıcıda: https://lumean.app/tr/developers/docs/guide/async
- Makine tarafından okunabilir tam başvuru: https://api.lumean.app/docs/llm.md
