Skip to main content
By the end of this page, you’ll have a WAV file of a Rime voice reading a short sentence, made with one request to Rime’s text-to-speech API. Choose a language tab, copy the complete script, and run it from your terminal.

Prerequisites

You need:
  • A Rime API token: Create a free Rime account and copy your API key from the API Tokens page.
  • A language runtime, depending on which tab you follow:
    • cURL: a terminal with cURL installed (included with macOS and most Linux distributions).
    • Python: Python 3.10 or later.
    • JavaScript: Node.js 18 or later.
    • TypeScript: Node.js 18+ plus tsx (npm install -g tsx).
Each code block is tabbed by language. Pick the same language in every block.
These examples call Rime’s HTTPS API with a standard library or built-in fetch. No Rime package is required.Rime publishes Python rime-api and JavaScript @rimelabs/api with generated TTS message definitions for the standalone engine. See package installation and scope.Framework-specific starters are available for Next.js, Vite, Express, plain Node, and FastAPI.
The scripts read your key from the RIME_API_KEY environment variable, which keeps it out of files you might share or commit. Set it in the terminal you’ll run them from:

Copy the request

Each script sends “Hello! This is Rime speaking.” to the celeste voice and saves the audio to output.wav, so you can replay it as many times as you need while you check it. One sentence is short enough to hear the whole result. Create a file called rime_hello_world.py, rime_hello_world.js, or rime_hello_world.ts (or run the cURL version directly in your terminal) and paste the full script:

Run it

The cURL tab runs the request directly. For Python, JavaScript, or TypeScript, run:
A successful request writes output.wav and prints:

Confirm it worked

Play the file. If you hear the sentence, your key, the request, and the voice all worked.
A file on disk isn’t proof of audio. If the player won’t open it, check what the file contains:
A file without the RIFF header usually means the request reached the API with no Accept header or a wildcard such as */*, for example because a proxy or client wrapper dropped the header. For Coda, the API then streams raw 16-bit PCM (audio/pcm) with no WAV header, and players won’t open it. The cURL example uses --fail --show-error so HTTP errors stop the command instead of being saved as output.wav.

If it did not work

Find the row that matches what you see. For the complete list of statuses and messages, see the error reference.

Build the request step by step

Create a file called rime_hello_world.py, rime_hello_world.js, or rime_hello_world.ts and import the required library modules:
Set the request headers with your Rime API key and the expected audio format:
Set the text, speaker, and model in the request body:
This payload includes the three required parameters:
  • text is the content to synthesize.
  • speaker selects a voice from the voice catalog.
  • modelId selects the model. Use coda for the full Coda voice lineup or mistv3 for the lowest time to first audio.
The Coda API reference lists the optional request parameters.Send the POST request and write the streamed audio response to a file:
These examples stream the response but write each chunk to disk. Interactive applications can play chunks as they arrive so speech begins before the complete response is generated. The LiveKit quickstart shows this pattern in a conversational agent.

Choose a voice

Keep the same sentence and change only speaker. With the words held constant, it’s easier to hear what the new voice changes:
The Voices page lists starter voices and the full catalog. Each voice speaks one language. If you choose a voice in another language, give it text in that language and add lang with the voice’s language tag.

Custom pronunciation

Custom pronunciation is supported on Mist v1, Mist v2, and English Mist v3. Coda and non-English Mist v3 do not support phonemizeBetweenBrackets.
The mistv2 model lets you specify the pronunciation of brand names or uncommon words using the Rime phonetic alphabet. Add the custom pronunciation in curly brackets and set phonemizeBetweenBrackets to true:
See the Rime phonetic alphabet for the full symbol reference, and Pronunciation control for an overview of all the ways to control pronunciation.

Production choices

The LiveKit quickstart extends the same streaming API into a real-time voice agent. These references cover the main model, voice, latency, and transport decisions:

Models

Compare Coda (flagship) and Mist v3 (fast)

Voices

Browse all available voice options

Latency

Optimize for real-time performance

Coda Streaming API

Stream audio with Coda, Rime’s flagship model