# Set up Lero

You are helping someone add Lero to a project: AI voice in Brazilian Portuguese, with Rio de Janeiro, São Paulo or Niterói accents. Do the whole setup from this one prompt. The user creates the account and the key and answers a few questions; you do the rest.

Full index: [https://lero.studio/llms.txt](https://lero.studio/llms.txt). API reference: [https://lero.studio/docs/en/llms-full.txt](https://lero.studio/docs/en/llms-full.txt). Contract: [https://lero.studio/docs/openapi.json](https://lero.studio/docs/openapi.json). Site pages accept `.md` at the end of the URL, or the `Accept: text/markdown` header, and return Markdown.

## Before you start

- **Reply first.** Your first message is the step 1 questions. Before it, read only local files that help you guess the answers (package.json, .env.example, existing audio code). Do not search the web yet.
- **Open the docs only when a step needs them.** Do not read ahead.
- **Know where you run.**
  - With the project and a terminal (Claude Code, Codex, Cursor, Conductor): follow every step.
  - In a chat app without the project (Claude, ChatGPT): skip the project guesses and give the user the code to paste.

## 1. Ask what they want

In one message, with your best guess filled in, so the user can reply "ok" or change a value:

1. **What are you building?** More than one is fine.
   - **Voice in the product:** the app generates speech through the API (alerts, read-aloud, IVR, accessibility, voice-over).
   - **Audio and podcasts from the agent:** you generate voice-overs and episodes through the Lero MCP, with no code in the project.
   - **Live voice agent:** a WebRTC conversation with the user's own system prompt and knowledge.
2. **Which voice?** `rio` (Rio de Janeiro), `sp` (São Paulo) or `niteroi` (Niterói). If unsure, generate the same sentence in all three.
3. **Access:** the user needs an account and a key (step 2).

## 2. Get access

- **Account:** without one, the user signs up at [https://app.lero.studio/cadastro](https://app.lero.studio/cadastro). The Free plan has 10,000 credits a month; the API and the MCP are on the Creator and Dev plans.
- **Key:** the user creates one at [https://app.lero.studio/desenvolvedores?aba=chaves](https://app.lero.studio/desenvolvedores?aba=chaves) and stores it as `LERO_API_KEY` in the environment (the project .env, the deploy secret or the shell). Never ask for the key in chat. If the user pastes one, do not use it: tell them to revoke it and create a new one.
- **MCP** (to generate audio from the agent). Prefer the remote server: the user signs in with their Lero account (OAuth) and no key passes through the chat. Connect it directly, do not search for it:
  - Claude Code: `claude mcp add --transport http lero https://mcp.lero.studio/mcp`, then `/mcp` to sign in.
  - Codex: `codex mcp add lero --url https://mcp.lero.studio/mcp`
  - Claude (web or desktop): Settings → Connectors → Add custom connector → `https://mcp.lero.studio/mcp`
  - Cursor, Conductor or any MCP client: `https://mcp.lero.studio/mcp` as a remote MCP server. The manifest is at [https://lero.studio/.well-known/mcp.json](https://lero.studio/.well-known/mcp.json).
  - Without OAuth, the local MCP with the key in `LERO_API_KEY`: `claude mcp add --env LERO_API_KEY=$LERO_API_KEY lero -- npx -y lero-mcp`
- **Skill** (optional, for agents that support Agent Skills): `mkdir -p ~/.claude/skills/lero-api && curl -fsSL https://lero.studio/docs/en/skill.md -o ~/.claude/skills/lero-api/SKILL.md`

## 3. Build what they chose

### Voice in the product

- `POST https://app.lero.studio/api/v1/tts` with `{"texto": "...", "voz": "rio"}` returns the MP3 (`audio/mpeg`). With `Accept: application/json`, the audio comes base64-encoded in the `audio` field.
- 1 to 500 characters per request. For long text, split on sentences, generate each part and join the MP3s in order.
- Call it from the server, reading the key from `LERO_API_KEY`. Never expose the key in the browser or in the app.
- Handle `402 sem_credito`, `429 muitos_pedidos` and `429 ocupado` (respect `Retry-After`) and `503 carregando` (retry in a few seconds).
- 1 credit per character. The `X-Creditos-Restantes` header has the balance after each request.

### Audio and podcasts from the agent

- The MCP has the tools `lero_fala`, `lero_transcrever` (remote only), `lero_vozes` and `lero_saldo`. On the remote server, `lero_fala` returns the audio and a download link valid for 1 hour: fetch it with `curl -o`. Locally, MP3 files are saved to `~/Downloads/Lero`, or to the folder in `LERO_PASTA`.
- Podcast: write the script, split it into lines of up to 500 characters, alternate the voices, generate each line and, if ffmpeg is installed, join them into one file.

### Live voice agent

- `GET https://app.lero.studio/api/v1/agents` lists the versions, LLMs, voices and the recommended setup. `POST https://app.lero.studio/api/v1/agents/conversation` takes the SDP offer from your WebRTC client and returns the SDP answer. Walkthrough: [https://lero.studio/docs/en#agente-guia](https://lero.studio/docs/en#agente-guia).

## 4. Test

- Generate a short sentence with the chosen voice and play it, or say where the file was saved.
- Check the balance with `GET https://app.lero.studio/api/v1/balance`.

## 5. Report

Say what is ready, the name of the key variable (never the value), the chosen voice, how many credits the test used and the next step.

## If the project already uses another voice service

- ElevenLabs: follow [https://lero.studio/en/migrate/elevenlabs.md](https://lero.studio/en/migrate/elevenlabs.md).
- Other services: replace the call with `POST /v1/tts`, map the voice id to `rio`, `sp` or `niteroi` and split texts over 500 characters.

## Help

Docs: [https://lero.studio/docs/en](https://lero.studio/docs/en). Pricing: [https://lero.studio/en/pricing.md](https://lero.studio/en/pricing.md). Contact: oi@lero.studio, with the `X-Pedido-Id` of the failed request.
