Skip to main content
POST
Convert text to speech using advanced TTS providers and stream the audio response. Code blocks and inline code are automatically processed for better speech generation.
This feature requires special activation. Please contact our support team to enable TTS for your account.

Path Parameters

string
required
The guru type identifier for the text-to-speech request

Headers

string
required
Your API key for authentication. You can obtain your API key from the Gurubase dashboard.

Body Parameters

string
required
The text to convert to speech

Response

The response is a streaming audio file in MP3 format.
audio/mpeg
Streaming audio response in MP3 format

Streaming Response

The endpoint returns a streaming audio response with the following headers:
  • Content-Type: audio/mpeg
  • Cache-Control: no-cache
  • X-Accel-Buffering: no (disables nginx buffering for real-time streaming)

Code Examples

The following examples show how to implement streaming TTS in your web application. These are complete, working examples that you can use immediately.

Streaming the TTS

This is a single self-contained HTML file that streams audio playback in real time without waiting for the entire response to finish. Save it, update the configuration, and open it in your browser.
Before running the example, you must update two constants at the top of the <script> section:
  • API_KEY — your API key from the Gurubase dashboard
  • GURU_SLUG — your guru’s slug (visible in the URL when you open your guru, e.g. my-guru)
The example will not work with the placeholder values.
Setup Instructions:
  1. Save the code below as gurubase-tts.html
  2. Update API_KEY and GURU_SLUG at the top of the script
  3. Open gurubase-tts.html in your browser
gurubase-tts.html
Testing Tips: - CORS errors? Serve the file from a local web server (e.g. npx serve .) instead of opening gurubase-tts.html directly via file://. - Safari / iOS: The example automatically falls back to a non-streaming blob approach on browsers that do not support the MediaSource Extensions API. - Audio begins playing as soon as the first chunks arrive from the server. - Open the browser console to inspect any errors if audio does not play.