Skip to content

Commit 2b3bd63

Browse files
authored
Merge pull request #1343 from bunnysayzz/docs/openrouter-tts-integration
docs: document OpenRouter TTS integration and response_format requirement
2 parents 234c36d + 2568f62 commit 2b3bd63

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

docs/features/chat-conversations/audio/text-to-speech/openai-tts-integration.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,62 @@ services:
112112
| `AUDIO_TTS_MODEL` | TTS model (`tts-1` or `tts-1-hd`) | `tts-1` |
113113
| `AUDIO_TTS_VOICE` | Voice to use | `alloy` |
114114

115+
## Using OpenRouter as a Text-to-Speech Provider
116+
117+
Open WebUI's `OpenAI` TTS engine is compatible with any service that implements the OpenAI Audio API, including [OpenRouter](https://openrouter.ai). This section explains how to configure OpenRouter as your TTS provider and how to avoid a common `400 Bad Request` error.
118+
119+
### Why the 400 Error Happens
120+
121+
OpenRouter's [`/audio/speech` endpoint](https://openrouter.ai/docs/guides/overview/multimodal/tts) defaults `response_format` to `pcm` when the field is omitted. Open WebUI does not send `response_format` in its request payload, so OpenRouter returns raw PCM audio, which Open WebUI cannot play back — resulting in a `400 Bad Request`.
122+
123+
The fix is to explicitly request MP3 by adding `{"response_format": "mp3"}` to the **OpenAI Params** field (extra parameters) in the TTS settings.
124+
125+
### Quick Setup (UI)
126+
127+
1. Click your **profile icon** (bottom-left corner)
128+
2. Select **Admin Panel**
129+
3. Click **Settings****Audio** tab → **Text-to-Speech Settings**
130+
4. Configure the following:
131+
132+
| Setting | Value |
133+
|---------|-------|
134+
| **Text-to-Speech Engine** | `OpenAI` |
135+
| **API Base URL** | `https://openrouter.ai/api/v1` |
136+
| **API Key** | Your OpenRouter API key (`sk-or-...`) |
137+
| **TTS Model** | Any OpenRouter TTS model, e.g. `openai/tts-1` |
138+
| **TTS Voice** | Choose from available voices |
139+
| **OpenAI Params** | `{"response_format": "mp3"}` |
140+
141+
:::important
142+
143+
The **OpenAI Params** field must contain `{"response_format": "mp3"}`. Without it, OpenRouter defaults to `pcm`, and speech requests fail with a `400 Bad Request` error.
144+
:::
145+
146+
5. Click **Save**
147+
148+
### Environment Variables Setup
149+
150+
If you prefer to configure via environment variables, add the parameters JSON via `AUDIO_TTS_OPENAI_PARAMS`:
151+
152+
```yaml
153+
services:
154+
open-webui:
155+
image: ghcr.io/open-webui/open-webui:main
156+
environment:
157+
- AUDIO_TTS_ENGINE=openai
158+
- AUDIO_TTS_OPENAI_API_BASE_URL=https://openrouter.ai/api/v1
159+
- AUDIO_TTS_OPENAI_API_KEY=sk-or-...
160+
- AUDIO_TTS_MODEL=openai/tts-1
161+
- AUDIO_TTS_VOICE=alloy
162+
- AUDIO_TTS_OPENAI_PARAMS={"response_format":"mp3"}
163+
# ... other configuration
164+
```
165+
166+
:::info
167+
168+
OpenRouter supports `mp3` and `pcm` output formats. Always select `mp3` in Open WebUI — PCM output is intended for real-time streaming pipelines and cannot be played back by Open WebUI.
169+
:::
170+
115171
## Testing TTS
116172

117173
1. Start a new chat

0 commit comments

Comments
 (0)