# Quickstart

From the Lero API docs: https://lero.studio/docs/en#inicio. Everything in one file: https://lero.studio/docs/en/llms-full.txt.

1. Create a key at [app.lero.studio/desenvolvedores](https://app.lero.studio/desenvolvedores?aba=chaves). The API is on the Creator and Dev plans.
2. Keep the key on your server, in the `LERO_API_KEY` variable.
3. Ask for your first speech:

cURL:

```bash
curl -X POST "https://app.lero.studio/api/v1/tts" \
  -H "Authorization: Bearer $LERO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"texto": "Fala, tudo bem? Aqui é o Lero, direto do Rio.", "voz": "rio"}' \
  --output fala.mp3
```

Python:

```python
import os

import requests

r = requests.post(
    "https://app.lero.studio/api/v1/tts",
    headers={"Authorization": f"Bearer {os.environ['LERO_API_KEY']}"},
    json={"texto": "Fala, tudo bem? Aqui é o Lero, direto do Rio.", "voz": "rio"},
    timeout=300,
)
r.raise_for_status()
with open("fala.mp3", "wb") as f:
    f.write(r.content)
print("credits left:", r.headers["X-Creditos-Restantes"])
```

JavaScript:

```javascript
import { writeFile } from "node:fs/promises";

const res = await fetch("https://app.lero.studio/api/v1/tts", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.LERO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ texto: "Fala, tudo bem? Aqui é o Lero, direto do Rio.", voz: "rio" }),
});
if (!res.ok) throw new Error(`${res.status} ${(await res.json()).erro}`);
await writeFile("fala.mp3", Buffer.from(await res.arrayBuffer()));
```

Base URL for every route: `https://app.lero.studio/api/v1`. Requests and responses are JSON (UTF-8), except the audio: speech returns MP3 and [transcription](https://lero.studio/docs/en#transcricao) takes the file as `multipart/form-data`.

Route names are in English: `/v1/tts`, `/v1/stt`, `/v1/voices`, `/v1/balance`, `/v1/agents` and `/v1/agents/conversation`. The old Portuguese paths (`/v1/fala`, `/v1/transcricao`, `/v1/vozes`, `/v1/saldo`, `/v1/agentes` and `/v1/agentes/conversa`) keep working the same way.
