---
title: "Quickstart: from API key to mp3"
url: https://lumean.app/es/developers/docs/start
locale: es
description: "Text to speech in five requests — voice, template, order, wait, and a file link."
updated: 2026-11-09
source_locale: en
sources: [get-voices, post-templates, post-orders, get-orders-order, post-storage-url]
errors: ["403", "402", "422", "429"]
spec_version: 1.0.0
---

# Quickstart: from API key to mp3

Text to speech takes five requests. Each request uses an ID from the previous response.

```text
Конвейер публичного API

Один раз:
  Ключ        X-API-KEY            заголовок в каждом запросе
    ↓
  Права       orders.write         пресет ключа задаёт доступные операции
    ↓
  Голос       GET /voices          voice_id из каталога
    ↓
  Шаблон      POST /templates      voice_id хранится в config.tts_settings

Каждый заказ:
  Шаблон      template_id          готовый шаблон из настройки
    ↓
  Заказ       POST /orders         201, статус created, результата ещё нет
    ↓
  Ожидание    GET /orders/{order}  статус, пока заказ не завершится
    ↓
  Файлы       result.files[]       пути в хранилище, а не ссылки
    ↓
  Ссылка      POST /storage/url    путь → ссылка на скачивание
```

## What you need

An API key with the `voices.read`, `templates.write`, `orders.write`, `orders.read`, and
`orders.download` scopes. Create one in [My API keys](/developers). The `full` preset works. The
`automation` preset lacks `templates.write`, so step 2 returns `403`.

> [!WARNING]
> Step 3 creates a real order. It is paid from your subscription quota, and anything beyond the quota
> comes from your balance: see [Tokens, quotas, LMC and PAYG](/developers/docs/guide/billing). One
> short phrase is enough for a first run.

Рецепт «first-tts» пошагово: https://lumean.app/es/developers/docs/start#r-first-tts

## The whole flow as one script

You need `curl` and `jq`. Put your key in `KEY`.

```bash
#!/usr/bin/env bash
set -euo pipefail

BASE=https://api.lumean.app/api/public
KEY=<your_api_key>
AUTH=(-H "X-API-KEY: $KEY" -H "Content-Type: application/json")

# 1. Voice: the first voice_id from the ElevenLabs catalog.
VOICE_ID=$(curl -s "$BASE/voices?provider=elevenlabs&page=1&per_page=20" \
  -H "X-API-KEY: $KEY" | jq -r '.data.items[0].voice_id')

# 2. A template with that voice. model_id, voice_id, mode and voice_settings.stability are required.
TEMPLATE_UUID=$(curl -s -X POST "$BASE/templates" "${AUTH[@]}" -d '{
  "service_key": "elevenlabs",
  "name": "My TTS",
  "config": {
    "tts_settings": {
      "mode": "mode_v1",
      "model_id": "eleven_multilingual_v2",
      "voice_id": "'"$VOICE_ID"'",
      "advanced_voice_settings": true,
      "voice_settings": {
        "stability": 0.5, "similarity_boost": 0.75,
        "use_speaker_boost": true, "speed": 1.0
      }
    }
  }
}' | jq -r '.data.id')

# 3. An order from the template. The text goes in input_text.
#    Response: 201, status "created", no result yet.
ORDER_UUID=$(curl -s -X POST "$BASE/orders" "${AUTH[@]}" -d '{
  "template_id": "'"$TEMPLATE_UUID"'",
  "input_text": "Hello! This is a test voiceover through the Lumean API."
}' | jq -r '.data.id')

# 4. Wait for the order to finish.
while :; do
  STATUS=$(curl -s "$BASE/orders/$ORDER_UUID" -H "X-API-KEY: $KEY" | jq -r '.data.status')
  echo "status: $STATUS"
  case "$STATUS" in
    completed|result_delivered) break ;;
    partially_completed|failed|cancelled|compensated) echo "order not completed: $STATUS"; exit 1 ;;
  esac
  sleep 5
done

# 5. result.files[] holds a path. Exchange it for a link and download the file.
FILE_PATH=$(curl -s "$BASE/orders/$ORDER_UUID" -H "X-API-KEY: $KEY" \
  | jq -r '.data.result.files[0]')
URL=$(curl -s -X POST "$BASE/storage/url" "${AUTH[@]}" \
  -d '{ "path": "'"$FILE_PATH"'", "download": true }' | jq -r '.data.url')
curl -sL "$URL" -o result.mp3
```

## Common mistakes

| Mistake | What to do instead |
| --- | --- |
| Sending `voice_id` with the order | The voice is set in the template, in `config.tts_settings.voice_id`. `POST /orders` has no such field |
| Downloading the value from `result.files[]` | It is a file path. `POST /storage/url` returns a link, valid for one hour |
| Waiting only for `completed` | An order can stop at `partially_completed`. `POST /orders/{order}/items/retry-failed` retries the failed chunks |
| Paging the ElevenLabs catalog by `total` | For ElevenLabs `total` is `null`. `has_more: false` marks the end of the catalog |
| Downloading later | Order files are kept for 7 days after the order finishes. Deleted files are marked with `files_expired: true` |

## Errors at step 3

### 402 — 402 — payment required

| Что произошло | Что делать |
| --- | --- |
| The order was not created and no money was charged. `POST /orders` and `POST /orders/{order}/retry` return this code: both are paid for the same way. Chunk retry and regeneration also return `402` when an extra charge cannot be paid: `insufficient_balance`, `insufficient_allowance`, and for retry also `insufficient_funds` (the order's reserved remainder is not enough). The `reason` field names the cause. | Branch on `reason`, not on `message`: the message text can change without notice. For `insufficient_balance`, top up the balance. For `insufficient_allowance`, wait for the next quota or change the plan. Until then, the same request keeps returning the same 402. |

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

`402` with `reason: insufficient_balance` means the subscription quota is used up and your
balance does not have enough LMC to pay beyond it. `insufficient_allowance` means the quota is
used up and paying beyond the quota is disabled for this service. See
[Tokens, quotas, LMC and PAYG](/developers/docs/guide/billing).

`429` means one of the limits was hit. The `reason` field tells you which one: see
[Limits and the 429 code](/developers/docs/guide/limits).

`422` with an `errors` field is a problem with the request fields. `422` with a `reason` and no
`errors` is a content rejection: the same request returns the same response.

## Next steps

- [Keys, scopes and headers](/developers/docs/guide/authentication) — key scopes and presets.
- [The asynchronous order model](/developers/docs/guide/async) — order statuses and cancellation.
- [Realtime](/developers/docs/guide/realtime) — order statuses over WebSocket instead of polling.
- [Templates](/developers/docs/guide/templates) — service settings and `GET /templates/config-options`.
- [Voiceover text](/developers/docs/guide/text) — pauses, markup, and which markup is billed.
- [Files, links and storage](/developers/docs/guide/files) — subtitles and how long files are kept.
- [Conventions](/developers/docs/guide/conventions) — the response and error format.
- [Pagination](/developers/docs/guide/pagination) — page numbering across lists.
- [Voices](/developers/docs/guide/voices) — the voice catalog and where to get a `voice_id`.
- [Limits and the 429 code](/developers/docs/guide/limits) — the limits and how to tell them apart.
- [Tokens, quotas, LMC and PAYG](/developers/docs/guide/billing) — how orders are paid for.
- [Retries and idempotency](/developers/docs/guide/retries) — retrying orders and chunks.
- Operations in this flow: [POST /orders](/developers/docs/api/post-orders),
  [POST /templates](/developers/docs/api/post-templates),
  [POST /storage/url](/developers/docs/api/post-storage-url).

---

- Esta página en el navegador: https://lumean.app/es/developers/docs/start
- Referencia completa legible por máquina: https://api.lumean.app/docs/llm.md
