To get the most out of the Sonna.ai API, we recommend following these best practices.
Request Optimization
Batching Text
The models work best when given complete sentences. Try to avoid splitting sentences across multiple API calls, as this can affect the prosody (natural rhythm) of the voice.
Character Limits
The maximum input length per request is 4096 characters. For longer texts, we recommend splitting the content at paragraph boundaries.
Error Handling
Implement robust error handling in your application. Common status codes to watch for:
Latency Management
Since Sonna.ai returns a URL to the audio file, you can start pre-fetching or playing the audio as soon as the JSON response is received.
For a smoother user experience, consider:
- Showing a loading state during the generation (
MISScache). - Using the built-in caching (
HITcache) for repetitive UI elements.