OLED Studio

start here · 3 steps

1 · Get a key. Mint one on the API keys page — oled_sk_live_…, shown once.

2 · Install. Only what your stack needs:

install
// nothing to install — fetch + WebSocket are built into browsers & node 18+

3 · Render. Press ▶ Run — audio appears below, free preview lane, never billed:

JavaScriptPlayground →
// render text -> one complete WAV. Runs LIVE when you press Run.
const API_KEY = process.env.OLED_API_KEY; // oled_sk_live_…
const res = await fetch(`https://oled-studio.onrender.com/v1/speech`, {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ text: "Hello from the docs — press Run and listen.", voice_id: "ada" }),
});
if (!res.ok) throw new Error(`render failed: ${res.status}`);
const wav = await res.arrayBuffer(); // audio/wav — save or play it
console.log("balance:", res.headers.get("x-balance-chars"));
Authenticationwhere the key goes · what gets billed+

What this is. The key proves which wallet pays. Every speech call carries it in the Authorization header, the server debits that wallet 1 token per character, and tells you the remaining balance in the X-Balance-Chars response header.

how to use it

  1. Mint a key on the API keys page and copy the oled_sk_live_… secret — it shows once.
  2. Send it as Authorization: Bearer oled_sk_live_… on every speech call (or api_key inside the /v1/talk message).
  3. Read X-Balance-Chars after each render; when it nears zero, top up on Billing before users notice.

GET /health and GET /v1/voices are open: no key, never billed. Everything that synthesizes needs one.

GET/healthengine heartbeat — call it first+

What this is. A tiny JSON report saying the engine is alive: which provider is loaded, which model version, the sample rate, and how many voices are ready. It costs nothing and needs no key.

how to use it

  1. Call it once when your app boots — if it fails, don't bother calling anything else yet.
  2. Check voices is above zero and model_version matches what you tested against.
  3. Point your status page or uptime monitor at it; ok: true means serving.
JavaScriptPlayground →
// no auth needed — ping the engine
const res = await fetch(`https://oled-studio.onrender.com/health`);
const health = await res.json();
console.log(health);
// → { ok: true, provider: "piper-standin-0.1.0", voices: 4, ... }
GET/v1/voicesevery renderable voice + accents+

What this is. The full menu of voices the engine can speak with right now — ids, labels, accents, and which ones are switched on. Voice ids are what you pass as voice_id everywhere else.

how to use it

  1. Fetch the list and let your users pick from it instead of hardcoding voice names.
  2. Play each voice's sample_url so people hear before they commit.
  3. If a render ever answers voice_disabled, re-fetch this list — that voice was switched off.
JavaScriptPlayground →
// list every voice the engine can render
const res = await fetch(`https://oled-studio.onrender.com/v1/voices`);
const { voices } = await res.json();
for (const v of voices) console.log(v.id, "-", v.label);
POST/v1/speechone request → one complete WAV+

What this is. The simplest way to speak: you send text (up to 2000 characters) and get back one complete WAV file. The audio IS the response body; the receipt — remaining balance, request id, voice used — rides in the response headers.

how to use it

  1. POST your text with voice_id and your key; save the response bytes as .wav and play them.
  2. Keep X-Balance-Chars from the headers and update your UI before the next render.
  3. Need a preview first? Add preview: true (≤200 chars) — real audio, costs nothing, never billed.
paramtypenotes
textstring · 1–2000What gets spoken.
voice_idstring · optionalDefaults to your console voice. Unknown ids 404.
session_idstring · optionalEphemeral generation session.
previewbool · default falseFree lane: ≤200 chars, never billed.
JavaScriptPlayground →
// render text -> one complete WAV. Runs LIVE when you press Run.
const API_KEY = process.env.OLED_API_KEY; // oled_sk_live_…
const res = await fetch(`https://oled-studio.onrender.com/v1/speech`, {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ text: "One WAV, one request — the simplest way to speak.", voice_id: "ada" }),
});
if (!res.ok) throw new Error(`render failed: ${res.status}`);
const wav = await res.arrayBuffer(); // audio/wav — save or play it
console.log("balance:", res.headers.get("x-balance-chars"));
WS/v1/talkstreaming socket · first audio fast+

What this is. A WebSocket for long text: you send sentences down one socket and audio chunks stream back while the rest is still rendering, so playback starts after sentence one instead of after the whole document. A done frame closes with total bytes and your balance.

how to use it

  1. Open the socket and send {type: 'speak', text, voice_id, api_key} — include the key inside the message, not a header.
  2. Play each binary frame as it arrives; the very first frame is the WAV header, so feed an incremental player.
  3. Wait for the done frame before closing — it carries balance_chars for your UI.

Python and SDK streaming recipes live in the playground.

stream.mjsplayground →
// STREAMING: text in, chunked WAV back on one socket. Runs LIVE on Run.
// First audio lands after the first sentence — the rest keeps flowing.
const ws = new WebSocket("wss://oled-studio.onrender.com/v1/talk");
ws.binaryType = "arraybuffer";
const chunks = []; // collect binary frames; frame[0] is the WAV header

ws.onopen = () => ws.send(JSON.stringify({
  type: "speak",
  request_id: "r-" + Math.random().toString(36).slice(2),
  text: "Streaming speaks sentence by sentence.",
  voice_id: "ada",
  api_key: process.env.OLED_API_KEY, // oled_sk_live_…
}));

ws.onmessage = (ev) => {
  if (typeof ev.data !== "string") return chunks.push(ev.data); // audio!
  const msg = JSON.parse(ev.data);
  if (msg.type === "done") {
    const wav = new Blob(chunks, { type: "audio/wav" });
    console.log(`done: ${msg.bytes} bytes, balance ${msg.balance_chars}`);
    ws.close();
  }
  if (msg.type === "error") throw new Error(msg.code + ": " + msg.message);
};
Errorsevery failure shape, one list+

What this is. When anything goes wrong you get the same envelope every time — an HTTP status plus { error: { code, message } }. The code is stable and documented; the message is human flavor that may change, so branch your logic on the code.

how to use it

  1. On 401, refresh the key or sign in again — never retry with the same secret in a loop.
  2. On 402, send the user to Billing — the wallet is empty, retries can't help.
  3. On 429 or 500, wait and retry once with backoff; include the X-Request-ID if you contact support.
  • 400 · bad_request / voice_disabledMissing text, bad voice, or a disabled voice. Check ids against GET /v1/voices.
  • 401 · unauthorized / login_requiredNo (or bad) API key — or session expired. Sign in again or mint a key.
  • 402 · insufficient_creditsWallet empty for this render. Top up on the Billing page.
  • 404 · unknown_voiceNo such voice id. List voices first.
  • 429 · rate_limited / preview_budgetToo fast, or the free preview budget is spent. Slow down or run billed.
  • 500 · synthesis_failedThe engine stumbled. Retry once; if it persists, report the X-Request-ID.
Billingtokens, top-ups, free lane+

What this is. Prepaid tokens, not subscriptions: ₦1 buys 1,000 tokens and rendering 1 character burns 1 token. You top up with Paystack (card typed on Paystack's page, never here), the webhook credits your wallet, and every kobo is listed under Transaction history.

how to use it

  1. Fund the wallet on the Billing page — start small, watch the tokens land.
  2. Just exploring? Keep renders under 200 chars with preview: true — free lane, never billed.
  3. Track spend per key on the Usage page; rotate a key the moment its numbers look wrong.