Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Rime SDK for Python

Use TTS to turn your text into speech, or Prism to run a conversation with text, audio, and tool calls. Both use the same Rime client and credentials.

Install

Requires Python 3.11 or later. This package is in alpha.

uv add --prerelease=allow rimelabs-sdk
export RIME_API_KEY="your-api-key"

An explicit Rime(api_key="...") overrides the environment. The SDK does not load .env files.

TTS quick start

Save this as speech.py and run uv run speech.py:

import asyncio
from rimelabs_sdk import Rime


async def main():
    async with Rime() as client:
        async with client.tts.stream("Hello. This is Rime.") as audio:
            with open("speech.pcm", "wb") as output:
                async for chunk in audio:
                    output.write(chunk)
            print(audio.request_id)


asyncio.run(main())

Output is raw mono 24 kHz signed little-endian PCM16, with no WAV header. The default model is Coda. Select Mist v3 with Rime(model="mistv3").

For streamed text, voices, audio formats, and cancellation, read the TTS guide.

Prism quick start

Prism needs a full WebSocket endpoint that accepts the Rime API key as a Bearer token. Set PRISM_URL to that endpoint. Set PRISM_VOICE if the deployment has no default voice.

import asyncio
import os
from rimelabs_sdk import Rime
from rimelabs_sdk.realtime import FaultEvent, ResponseEnded, RimeRealtimeError, TextDelta


async def read_reply(session):
    async for event in session.events:
        payload = event.payload
        if isinstance(payload, TextDelta):
            print(payload.delta, end="", flush=True)
        elif isinstance(payload, FaultEvent):
            raise RimeRealtimeError(payload.error)
        elif isinstance(payload, ResponseEnded):
            if payload.status != "completed":
                raise RuntimeError(f"Response {payload.status}: {payload.reason}")
            print()
            return
    raise RuntimeError("Session closed before the response ended")


async def main():
    async with asyncio.timeout(60), Rime() as client:
        async with client.realtime.connect(
            endpoint=os.environ["PRISM_URL"],
            voice=os.getenv("PRISM_VOICE"),
        ) as session:
            async with asyncio.TaskGroup() as tasks:
                tasks.create_task(read_reply(session))
                await session.send_text("Hello!")


asyncio.run(main())

This prints the text from one reply and discards its audio. Keep event consumption running alongside input tasks; each session supports one event consumer.

Connection options, audio input, tools, playback, and errors are in the Realtime guide. The client-level model, endpoint, and timeout options apply to TTS and discovery. Configure Prism through realtime.connect(...).

Examples and license

Run the examples from a source checkout. They cover streamed TTS text, saved Prism audio, and a tool round.

The SDK uses the MIT license. The Prism protocol module uses Apache 2.0.

Metadata

Release files for rimelabs-sdk 0.1.0a6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rimelabs-sdk 0.1.0a6
File Size Uploaded
rimelabs_sdk-0.1.0a6.tar.gz 131.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rimelabs-sdk 0.1.0a6
File Interpreter ABI Platform
rimelabs_sdk-0.1.0a6-py3-none-any.whl Python 3 none any Details

Total release size: 172.7 kB

Release files / rimelabs_sdk-0.1.0a6.tar.gz

Download URL rimelabs_sdk-0.1.0a6.tar.gz
Size 131.8 kB
Tags Source
SHA-256 checksum
How to use checksums
eac7cb7f8f742b5873fba64eac732c797a782591ecfb34c804593c06c24924f0
BLAKE2b-256 checksum
How to use checksums
7cc86e233cac66d527deb4dd338b1639789f2b58b3834675bc62c316e9e2cd9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rimelabs_sdk-0.1.0a6-py3-none-any.whl

Download URL rimelabs_sdk-0.1.0a6-py3-none-any.whl
Size 40.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5de813aaa3d0eb5ab2aabaae26113808c061d40cfa21a3db65f2017a7d1b3e91
BLAKE2b-256 checksum
How to use checksums
7f9c73272d05be900ca64b8005051af1a522cd3ff3589d25bda884aa6084fcf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page