Validate speech requests and settle reported Gemini usage

This commit is contained in:
404oops authored and Daniel Salazar committed 2026-10-17 00:27:54 -04:00
1 parent f80f479a19
commit 33c84b4f1b
12 files changed
+657 -150

No files matched your search

+5 -3
View File
@@ -20,7 +20,7 @@ puter.ai.txt2speech(text, language, voice, engine, testMode = false)
#### `text` (String) (required)
A string containing the text you want to convert to speech. The text must be less than 3000 characters long. Defaults to AWS Polly provider when no options are provided.
A string containing the text you want to convert to speech. The text can be up to 3,000 characters long. Longer text is rejected with an `input_too_large` error. Defaults to AWS Polly provider when no options are provided.
#### `testMode` (Boolean) (optional)
@@ -84,9 +84,11 @@ Available when `provider: 'gemini'`:
|--------|------|-------------|
| `model` | `String` | TTS model. Available: `'gemini-3.8-flash-tts'` (default), `'gemini-3.8-flash-lite-tts'` |
| `voice` | `String` | Voice name. Defaults to `'Kore'`. Available: `'Zephyr'`, `'Puck'`, `'Charon'`, `'Kore'`, `'Fenrir'`, `'Leda'`, `'Orus'`, `'Aoede'`, `'Callirrhoe'`, `'Autonoe'`, `'Enceladus'`, `'Iapetus'`, `'Umbriel'`, `'Algieba'`, `'Despina'`, `'Erinome'`, `'Algenib'`, `'Rasalgethi'`, `'Laomedeia'`, `'Achernar'`, `'Alnilam'`, `'Schedar'`, `'Gacrux'`, `'Pulcherrima'`, `'Achird'`, `'Zubenelgenubi'`, `'Vindemiatrix'`, `'Sadachbia'`, `'Sadaltager'`, `'Sulafat'` |
| `instructions` | `String` | Natural language instructions to control speaking style (tone, speed, mood, etc.) |
| `instructions` | `String` | Natural language instructions to control speaking style (tone, speed, mood, etc.), up to 3,000 characters |
Gemini generates speech from the `text` field. The `instructions` string isn't included in the generated audio. It guides delivery (tone, pacing, accent, emotion). Instructions count toward input tokens. Audio is returned as WAV.
Gemini generates speech from the `text` field. The `instructions` string isn't included in the generated audio. It guides delivery (tone, pacing, accent, emotion). Instructions count toward input tokens. Longer instructions are rejected with an `input_too_large` error. Audio is returned as WAV.
A Gemini request is charged for the tokens Gemini reports, even when it fails or returns no audio. If Gemini returns audio without reporting its token usage, the request fails with an `upstream_failed` error.
For more details about Gemini TTS, see the [Google Gemini speech generation documentation](https://ai.google.dev/gemini-api/docs/speech-generation).
+2 -1
View File
@@ -65,6 +65,7 @@ Shared by chat, image generation, video, TTS, speech and OCR. Each interface and
| Input | Limit |
| ---------------------------------------------- | ---------------- |
| Text for `txt2speech()` | 3,000 characters |
| Gemini `instructions` for `txt2speech()` | 3,000 characters |
| Audio for `speech2speech()` | 25 MiB |
| Image inlined in a chat message | 5 MB |
| File attached to a chat message, Claude models | 30 MB |
@@ -78,7 +79,7 @@ A `gemini-4-argon` response that isn't streamed is capped at 32,768 output token
Text-to-speech calls to ElevenLabs, xAI, Speechify and Gemini time out after 2 minutes; xAI speech-to-text and voice-changer calls after 10 minutes, upload included. A call that times out before any audio or transcript comes back fails with `504 upstream_timeout`. For Gemini, the 2 minutes cover the whole reply, audio included.
A Gemini text-to-speech reply is capped at 32 MiB, about 8 minutes of audio. A larger reply fails with `502 upstream_failed`.
A Gemini text-to-speech reply is capped at 32 MiB, about 8 minutes of audio. A larger reply fails with `502 upstream_failed`. A Gemini text-to-speech request is charged for the tokens Gemini reports, even when it fails or returns no audio.
The OpenAI- and Anthropic-compatible endpoints (`/puterai/openai/v1/*`, `/puterai/anthropic/v1/messages`) require a paid plan; a free account gets `402 subscription_required`. The same models are available to every account through `puter.ai.*` and `/drivers/call`, and the model catalogue endpoints are open to everyone.