Overview
Resonance uses tRPC to provide a type-safe API for building text-to-speech applications. The API is organized into three main routers:- Voices - Manage custom and system voices
- Generations - Create and retrieve TTS generations
- Billing - Handle subscriptions and usage tracking
Architecture
tRPC Setup
Resonance uses tRPC with the following configuration:Data Transformation
The API uses SuperJSON for serialization, which allows for:- Date objects to be preserved across the wire
- BigInt support for large numbers
- Map and Set objects
- Undefined values in objects
Error Handling
All endpoints use tRPC’s standardized error codes:| Code | Description | HTTP Status |
|---|---|---|
UNAUTHORIZED | User not authenticated | 401 |
FORBIDDEN | Missing permissions or subscription | 403 |
NOT_FOUND | Resource not found | 404 |
PRECONDITION_FAILED | Required condition not met | 412 |
INTERNAL_SERVER_ERROR | Server-side error | 500 |
Next Steps
Authentication
Learn about Clerk-based authentication
Voices API
Manage voice clones
Generations API
Generate speech audio
Billing API
Handle subscriptions