Gemini Live API Client Builder

Gemini Live API Client Builder

Builds a Gemini Live API WebSocket client and demo app, and diagnoses session problems such as silent turns, audio glitches, tool-call loops and dropped connections.

Skill files8 files

references/

SKILL.md411 lines
1
---
2
name: gemini-live-api
3
metadata:
4
version: "1.1.0"
5
category: AiAndMachineLearning
6
description: >-
7
Builds, integrates, and troubleshoots Gemini Enterprise Agent Platform Live
8
API (BidiGenerateContent) WebSocket clients and sessions. Use when scaffolding
9
a LiveAPI client or demo UI/backend (GA v1 WebSockets, isolated Python venv,
10
ADC bearer token refresh, transparent session resumption, ClientMessage and
11
ServerMessage JSON protos, tool responses, context_update, interrupt and
12
transcription handling) or debugging Live API issues such as silent or empty
13
turns, audio amplitude collapse, tonal humming, voice gender or accent drift,
14
premature turn completion, barge-in failures, output_transcription leaks,
15
malformed or looping tool calls, WebSocket 1008/1011/goAway drops, or latency
16
spikes. Don't use for non-live, non-bidirectional Gemini API calls such as
17
unary generateContent, embeddings, image/video generation, or fine-tuning —
18
use the gemini-api skill for those.
19
---
20
21
> [!IMPORTANT]
22
> Gemini Enterprise Agent Platform was previously named "Vertex AI"; the API
23
> service endpoint remains `aiplatform.googleapis.com`.
24
25
# LiveAPI Service Skill
26
27
This skill provides instructions for generating a **LiveAPI client service
28
class** that connects to the Gemini Enterprise Agent Platform Live API over
29
WebSockets (`LlmBidiService/BidiGenerateContent`), as well as diagnosing and
30
resolving Live API runtime issues. The generated client handles bidirectional
31
JSON frame streaming, bearer-token authentication via Application Default
32
Credentials (ADC), transparent session resumption, tool call responses,
33
mid-session context updates, and `ClientMessage` / `ServerMessage` proto
34
exchange.
35
36
The skill also produces a demo frontend + backend service so the user can
37
interactively validate the generated client (text, audio, video, transcription,
38
and interrupt handling).
39
40
## Usage Attribution
41
42
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
43
MUST read and follow the instructions in
44
[Usage Attribution](references/attribution.md).
45
46
## Prerequisites
47
48
Before running the generation flow, verify or guide the user through the
49
following prerequisites (always ask for user approval before modifying host
50
configurations or installing system tools):
51
52
- **Google Cloud Project & Billing**: An active Google Cloud project with a
53
linked billing account (review [Gemini Enterprise Agent Platform pricing](https://cloud.google.com/products/gemini-enterprise-agent-platform/pricing)):
54
55
```bash
56
gcloud config set project {project_id}
57
```
58
59
- **API Enablement & IAM**: The `aiplatform.googleapis.com` API enabled on the
60
project, and the caller principal granted at least Vertex AI User
61
(`roles/aiplatform.user`):
62
63
```bash
64
gcloud services enable aiplatform.googleapis.com
65
```
66
67
- **Application Default Credentials (ADC)**: Configured on the host running
68
the generated client (see [Google Cloud authentication](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/start/gcp-auth.md.txt)):
69
70
```bash
71
gcloud auth application-default login
72
```
73
74
- **Regional Location**: Default to `us-central1` unless the user specifies
75
another supported US or EU region (e.g., `europe-west4`; see [supported locations](https://docs.cloud.google.com/gemini-enterprise-agent-platform/resources/locations.md.txt)).
76
Live API models do **not** support the `global` endpoint.
77
- **Isolated Output Directory**: A destination folder supplied by the user
78
(e.g., `/tmp/liveapi_out`) where generated code, virtual environments, and
79
the demo service will be written. **Never** mutate the host's system Python
80
environment.
81
- **Implementation Language**: Python is the default and reference language
82
when the user does not specify another language.
83
84
## Supported Live API Models
85
86
- **`gemini-3.8-live` (GA — Recommended default)**: Native audio I/O, VAD,
87
affective dialog and proactive audio **always enabled by default**,
88
`NON_BLOCKING` and `BLOCKING` function calling, mid-session
89
`context_update`, and custom transcription vocabulary.
90
- **`gemini-live-2.5-flash-native-audio` (GA)**: Native audio I/O,
91
transcriptions, VAD, optional `generation_config.enable_affective_dialog`
92
and `proactivity.proactive_audio`, and function calling.
93
- **`gemini-3.5-transcribe-live-preview` (Preview)**: Dedicated low-latency
94
speech-to-text streaming (`input_transcription` and
95
`interim_input_transcription`) with `VERBATIM` and `SMART` modes and custom
96
vocabulary.
97
98
## Reference Files
99
100
Load these files from `references/` on demand (do **not** treat them as
101
standalone skills):
102
103
- [client_server_messages.md](references/client_server_messages.md): Wire
104
protocol reference for `ClientMessage` / `ServerMessage`, model-specific
105
`gemini-3.8-live` rules, and JSON examples.
106
- [client_server_messages.proto](references/client_server_messages.proto):
107
Proto3 schema derived from the public Live API documentation for generating
108
typed `ClientMessage` and `ServerMessage` classes.
109
- [session_manager.md](references/session_manager.md): Specification for
110
connection lifecycle, 1-based message buffering, `go_away` handling, and
111
transparent session resumption.
112
- [Audio, Voice, Accent, and Quality Troubleshooting](references/troubleshooting_audio_voice.md):
113
Prebuilt voice gender table, accent/locale fixes, amplitude collapse, tonal
114
humming, and jitter buffering.
115
- [Turns, VAD, Barge-In, and Transcriptions Troubleshooting](references/troubleshooting_turns_vad.md):
116
`generationComplete` vs. `turnComplete`, `contextWindowCompression` readback
117
settings, client stall nudges, backchannel gating, telephony VAD padding,
118
and transcription/instruction leakage guards.
119
- [Tool Calling, Safety Filters, Lifecycle, Latency, and Cost Troubleshooting](references/troubleshooting_tools_lifecycle.md):
120
Typed schemas, `NON_BLOCKING` scheduling, state-machine polarity, pre-tool
121
filler handling, safety filters, WebSocket `1008`/`1011` and `goAway`
122
recovery, `TTFT` triage, and cost optimization.
123
124
## Steps
125
126
### Step 1: Copy the reference files
127
128
Copy `client_server_messages.md`, `client_server_messages.proto`, and
129
`session_manager.md` from this skill's `references/` folder into the user's
130
destination output folder. These files become the local source of truth for the
131
generated client.
132
133
### Step 2: Reconcile and compile the proto definitions
134
135
Check the public documentation linked in
136
[client_server_messages.md](references/client_server_messages.md). If any new
137
server fields are needed for the user's task, update the copied
138
`client_server_messages.md` and `client_server_messages.proto` in the
139
destination folder, and compile `client_server_messages.proto` (e.g., via
140
`grpc_tools.protoc` or `protoc`) into the destination folder.
141
142
### Step 3: Implement the client class and `SessionManager`
143
144
Implement a client service class in the user's chosen language that:
145
146
- Imports the local compiled `client_server_messages.proto` types
147
(`ClientMessage`, `ServerMessage`).
148
- Connects over WebSockets to:
149
`wss://{location}-aiplatform.googleapis.com/ws/google.cloud.aiplatform.{api_version}.LlmBidiService/BidiGenerateContent`
150
where `api_version` defaults to `"v1"` (allow overriding to `"v1beta1"` for
151
preview-only features such as Vertex RAG Engine).
152
- Formats `setup.model` as
153
`projects/{project_id}/locations/{location}/publishers/google/models/{model_id}`.
154
- Serializes outgoing `ClientMessage` instances as **UTF-8 JSON text frames**
155
(e.g., `google.protobuf.json_format.MessageToJson`) and parses incoming JSON
156
text frames into `ServerMessage` with unknown fields ignored
157
(`ignore_unknown_fields=True`). **Never** send binary protobuf bytes.
158
- Implements transparent session resumption per
159
[session_manager.md](references/session_manager.md) (including
160
`context_window_compression.sliding_window` when sessions may exceed 15
161
minutes).
162
163
For languages that require an isolated runtime (e.g., Python), create an
164
isolated environment (e.g., `venv`) **inside the destination folder** along with
165
a `requirements.txt` pinning exact compatible versions within tested bounds
166
(`websockets>=13.0,<16.0`, `protobuf>=5.29.0,<7.0.0`,
167
`google-auth>=2.35.0,<3.0.0`, `requests>=2.32.0,<3.0.0`,
168
`grpcio-tools>=1.68.0,<2.0.0`) and a runnable `setup.sh` script that creates the
169
`venv`, runs `pip install -r requirements.txt` (explicitly referencing
170
`requirements.txt`), and compiles `client_server_messages.proto`. **Never**
171
install into the system interpreter or user-global site-packages, and never
172
instruct the user to run `sudo pip install`.
173
174
#### Initialization parameters
175
176
Accept at construction time:
177
178
- `project_id`: Google Cloud project ID.
179
- `location`: Regional location (e.g., `"us-central1"`; reject `"global"`).
180
- `model_id`: Live API model ID (e.g., `"gemini-3.8-live"`).
181
- `config`: A `ClientMessage` with the `setup` field populated.
182
- `api_version` (optional): Defaults to `"v1"` (supports `"v1beta1"`).
183
184
#### Authentication
185
186
Obtain an access token via Application Default Credentials with scope
187
`https://www.googleapis.com/auth/cloud-platform`, attach it to the WebSocket
188
handshake header as `Authorization: Bearer <token>`, refresh it before or upon
189
expiry, and attach the valid/refreshed token on every reconnection (including
190
`go_away` and close codes `1000`, `1006`, or `1011`). **Do not** hard-code a
191
long-lived API key as the only auth mechanism.
192
193
#### Public async API
194
195
Expose the following async methods, all gated on receipt of a `setup_complete`
196
`ServerMessage` before sending:
197
198
- `send_realtime_data(data: ClientMessage)`: Send continuous low-latency
199
media/text. `data` MUST be typed as `ClientMessage` carrying
200
`realtime_input`.
201
- `send_client_content(data: ClientMessage)`: Send discrete, history-bearing
202
turns. `data` MUST be typed as `ClientMessage` carrying `client_content`.
203
(On `gemini-3.8-live`, set
204
`setup.history_config.initial_history_in_client_content = true` when seeding
205
prior history, and never use `role="system"` in `client_content`.)
206
- `send_tool_response(data: ClientMessage)`: Reply to a server `tool_call`.
207
`data` MUST be typed as `ClientMessage` carrying `tool_response`. (On
208
`gemini-3.8-live`, return informative status objects such as
209
`{"status": "ok"|"not_found", "retryable": false, ...}` instead of empty
210
`{}` to prevent retry sweeps.)
211
- `send_context_update(data: ClientMessage)`: Update `system_instruction`
212
and/or `tools` mid-session (`gemini-3.8-live`). `data` MUST be typed as
213
`ClientMessage` carrying `context_update`.
214
- `receive() -> AsyncIterator[ServerMessage]`: Async generator yielding
215
`ServerMessage` instances parsed from the WebSocket stream.
216
217
Do not expose synchronous blocking variants as the primary API surface.
218
219
### Step 4: Write a test file
220
221
Generate a test file in the destination folder that initializes the client and
222
exercises `text`, `audio` (16 kHz PCM), `video` (sampled JPEG/PNG frames),
223
`send_tool_response`, and `send_context_update`, verifying `ServerMessage`
224
responses. Ask the user for any runtime inputs needed (`project_id`, model, or
225
sample media).
226
227
### Step 5: Generate `how_to_run.md`
228
229
Write `how_to_run.md` in the destination folder documenting the generated client
230
class, setup scripts, and complete examples building `ClientMessage` payloads
231
for realtime audio/video/text, `client_content` turns (including seeded
232
history), `tool_response` (async `scheduling` and structured responses), and
233
`context_update`.
234
235
### Step 6: Generate a demo frontend + backend service
236
237
Create a frontend UI and backend service in the destination folder that reuse
238
the local `ClientMessage` / `ServerMessage` protos from Step 1. Through the UI
239
the user must be able to:
240
241
- Open and close a Live API session.
242
- Select the model (defaulting to `gemini-3.8-live`).
243
- Stream microphone audio (16 kHz mono PCM) and camera or screen frames (~1
244
fps JPEG) to the model.
245
- Send typed text messages.
246
- Play back 24 kHz model audio and view interleaved user and model
247
transcriptions.
248
249
Follow [Live API best practices](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/live-api/best-practices.md.txt)
250
for audio capture, echo cancellation, and playback buffering.
251
252
#### Handling the `interrupt` signal
253
254
When `server_content` arrives with `interrupted: true`, the UI MUST:
255
256
- Keep played audio and rendered transcription time-aligned.
257
- Immediately stop currently playing model audio and stop appending to the
258
in-progress model transcription bubble.
259
- Clear unplayed audio buffers and queued unrendered transcription text so
260
stale content never bleeds into the next turn.
261
- Start fresh chat bubbles for subsequent user and model turns.
262
263
#### Handling the transcription `finished` signal
264
265
For streamed `input_transcription` and `output_transcription` chunks (and
266
optional `interim_input_transcription` previews), append text to the active
267
bubble while `finished` is unset/`false`, and close that bubble to start a fresh
268
one when `finished: true` arrives. Route `input_transcription` to user-role
269
bubbles and `output_transcription` to model-role bubbles.
270
271
### Step 7: Generate `how_to_test_with_ui.md`
272
273
Write `how_to_test_with_ui.md` in the destination folder with:
274
275
- Exact shell command(s) to start the backend service.
276
- Exact shell command(s) to start the frontend UI.
277
- Browser URL (`http://localhost:PORT`).
278
- Walkthrough for starting a session, selecting a model, streaming mic/camera/
279
screen inputs, sending text, and verifying audio + transcription + barge-in.
280
281
## Validation Checklist
282
283
Verify every item before completing generation:
284
285
- [ ] `client_server_messages.md`, `client_server_messages.proto`, and
286
`session_manager.md` were copied into the destination folder.
287
- [ ] The generated client compiles and imports the local `ClientMessage` and
288
`ServerMessage` proto types, and exchanges UTF-8 JSON text frames
289
(`MessageToJson` / `Parse` with unknown fields ignored).
290
- [ ] The client connects to
291
`wss://{location}-aiplatform.googleapis.com/ws/google.cloud.aiplatform.{api_version}.LlmBidiService/BidiGenerateContent`
292
defaulting `api_version` to `"v1"` on a regional endpoint (never `global`),
293
and formats `setup.model` as
294
`projects/{project_id}/locations/{location}/publishers/google/models/{model_id}`.
295
- [ ] Authentication uses ADC bearer tokens (`Authorization: Bearer <token>`),
296
refreshes before expiry, and reattaches the valid token on every reconnect.
297
- [ ] Public async methods `send_realtime_data`, `send_client_content`,
298
`send_tool_response`, `send_context_update`, and `receive` are present,
299
typed with `ClientMessage` / `ServerMessage`, and gated on `setup_complete`.
300
- [ ] Transparent session resumption sets `session_resumption.transparent =
301
true`, tracks `new_handle`, indexes buffered messages starting at `1`,
302
prunes via `last_consumed_client_message_index`, and replays from index `1`
303
on reconnect (`go_away` and WebSocket codes `1000` / `1006` / `1011`).
304
- [ ] For Python, an isolated `venv`, `setup.sh`, and `requirements.txt` live
305
inside the destination folder with zero changes to system/global Python.
306
- [ ] `how_to_run.md` and `how_to_test_with_ui.md` exist, and the demo UI
307
implements `interrupted: true` and `Transcription.finished` handling.
308
- [ ] The client does **not** target `generativelanguage.googleapis.com` and
309
does **not** pass API keys in URL query strings.
310
311
--------------------------------------------------------------------------------
312
313
## Troubleshooting Live API Issues
314
315
When debugging an existing Live API integration or runtime failure (rather than
316
scaffolding a new client from scratch), follow this diagnostic workflow before
317
making prompt tweaks.
318
319
### Diagnostic Workflow
320
321
1. **Verify environment and model currency:** Confirm a regional endpoint
322
(for example, `us-central1`; `global` is not supported for Live API
323
WebSockets) and active billing ([Google Cloud Pricing](https://cloud.google.com/pricing)).
324
Legacy `gemini-2.0-*` models and `gemini-live-2.5-flash` (half-cascade) are
325
deprecated or shut down; test whether the symptom resolves on
326
`gemini-3.8-live` or `gemini-live-2.5-flash-native-audio`.
327
2. **Capture the full serialized wire payload:** Log the exact
328
`BidiGenerateContentSetup` JSON, `clientContent`, `realtimeInput`,
329
`toolResponse`, and `contextUpdate` frames actually sent over the WebSocket.
330
Frameworks often inject extra session state or tool declarations absent from
331
source prompt files.
332
3. **Audit against Pre-Flight Configuration Rules:** Fix primary structural
333
defects (gender mismatch, missing regional `languageCode`, low `temperature`
334
+ `generationConfig.enableAffectiveDialog`, bloated `tools` or
335
`systemInstruction`) first.
336
4. **Isolate optional flags and tools:** On
337
`gemini-live-2.5-flash-native-audio`, temporarily disable
338
`setup.proactivity.proactiveAudio` and
339
`setup.generationConfig.enableAffectiveDialog` (both are built-in by default
340
on `gemini-3.8-live` and should be omitted there), and stub out `tools` when
341
testing minimal prompt behavior.
342
5. **Reproduce and verify A/B:** Replay the failing turn sequence before and
343
after 1-2 targeted changes, checking audio duration, PCM amplitude,
344
`output_transcription`, and `turnComplete` signals.
345
346
### Quick Symptom Triage Matrix
347
348
| Symptom | Primary Suspect | Immediate Fix | Reference |
349
| --- | --- | --- | --- |
350
| Voice flips gender (Turn 1 or mid-call) | Prebuilt voice gender mismatches SI persona name/pronouns | Match `voiceName` gender to SI persona | [Audio & Voice](references/troubleshooting_audio_voice.md#voice-gender-swaps) |
351
| Accent reverts to `en-US`, pitch jumps, or code-mix fails | Omitted `speechConfig.languageCode` or long single-script SI | Set supported BCP-47 `languageCode` (e.g., `en-IN`) and concise SI | [Audio & Voice](references/troubleshooting_audio_voice.md#accent-reversion-pitch-jumps-and-code-mixed-switching) |
352
| Output mimics user's voice timbre | Native audio role leakage from user audio in context | Upgrade to `gemini-3.8-live`; clarify role boundaries; reconnect | [Audio & Voice](references/troubleshooting_audio_voice.md#output-voice-mimics-user-timbre) |
353
| Gradual voice/tone drift over long calls | Audio-token conditioning drift as history grows | Enable `contextWindowCompression` and rotate long sessions | [Audio & Voice](references/troubleshooting_audio_voice.md#multi-turn-voice-and-tone-drift) |
354
| Fast speech (240+ WPM) or raw `/IPA/` leaks | Long single-breath clauses, `2.5` affective dialog, or TTS markup in SI | Shorten clauses, strip TTS headers/IPA, or use `gemini-3.8-live` | [Audio & Voice](references/troubleshooting_audio_voice.md#fast-speech-rate-and-tts-markup-or-ipa-leaks) |
355
| Near-zero audio volume (`-34 dBFS`), intact text | Tool schemas `>40k` tokens or rolling text logs in SI | Prune `tools` to active turn/step, drop rolling text logs, keep SI `<2,000` tokens | [Audio & Voice](references/troubleshooting_audio_voice.md#near-zero-audio-amplitude-collapse) |
356
| `150-700 Hz` tonal hum or endless greeting | `temperature <= 0.3` with `2.5` `generationConfig.enableAffectiveDialog` | Set `temperature >= 0.7`, disable `2.5` affective dialog, open fresh session | [Audio & Voice](references/troubleshooting_audio_voice.md#tonal-humming-buzz-150-700-hz-and-non-terminating-greetings) |
357
| Choppy playback with `0.1-0.5s` gaps | Small variable WebSocket audio chunks played raw | Add a `~200 ms` client-side jitter buffer | [Audio & Voice](references/troubleshooting_audio_voice.md#choppy-playback-and-audio-jitter) |
358
| Premature `generationComplete` (`~0.75s`) or missing `turnComplete` | Advancing on `generationComplete`, `<verbatim>` tags, or history bloat | Wait for `turnComplete`, strip `<verbatim>` tags, add `contextWindowCompression` | [Turns & Transcripts](references/troubleshooting_turns_vad.md#premature-generationcomplete-and-missing-turncomplete) |
359
| `0` audio chunks after `toolResponse` (`>14k` tokens) | XML/JSON bloat diluting voice conditioning | Use prose SI, clean JSON tools, and `contextWindowCompression` | [Turns & Transcripts](references/troubleshooting_turns_vad.md#post-toolresponse-zero-audio-turns-in-deep-contexts) |
360
| Empty turns (`output_audio=0`) and `12-30s` wedges | `2.5` `proactivity.proactiveAudio` or client `3s` stall nudges | Disable `proactivity.proactiveAudio` on `2.5`; remove `3s` `clientContent` nudges | [Turns & Transcripts](references/troubleshooting_turns_vad.md#empty-turns-from-proactiveaudio-and-client-stall-nudges) |
361
| Turn-1 `output_transcription` dropped or silence placeholder leak | `realtimeInput.text` kickoff under `TURN_INCLUDES_ALL_INPUT` | Use `TURN_INCLUDES_ONLY_ACTIVITY` and `clientContent(turnComplete=True)` | [Turns & Transcripts](references/troubleshooting_turns_vad.md#turn-1-transcript-drops-and-prompt-template-newlines) |
362
| Unspoken Markdown or code in `output_transcription` | Post-speech text flush into UI / persisted transcripts | Set `languageCode`, ban Markdown in SI, strip trailing code blocks in UI | [Turns & Transcripts](references/troubleshooting_turns_vad.md#unspoken-markdown-or-code-tail-bursts-in-output_transcription) |
363
| Audible instruction leak pre-tool without transcript | Spoken pre-tool filler in `>70k`-token context | Call tools silently, strip `"speak..."` wrappers, compress context | [Turns & Transcripts](references/troubleshooting_turns_vad.md#pre-tool-filler-audible-leakage-without-transcripts) |
364
| Model speaks `<no speech>`, `{pause}`, or raw JSON | `NON_BLOCKING` missing `scheduling="SILENT"`, echo, or routing trap | Set `scheduling="SILENT"`, enable AEC, cap unclear turns | [Turns & Transcripts](references/troubleshooting_turns_vad.md#spoken-placeholder-tokens-and-raw-json-leaks) |
365
| Short `"Mm-hmm"` cuts off speech; double interrupt stalls | Acoustic barge-in firing on brief backchannels | Filter `<500 ms` backchannels client-side before streaming | [Turns & Transcripts](references/troubleshooting_turns_vad.md#short-backchannel-cutoffs-and-double-interruption-silence) |
366
| Final digits clipped (`"98058"` -> `"98050"`) | Manual VAD closing too fast on 8 kHz PSTN audio | Add `400-500 ms` hangover padding; confirm critical digits | [Turns & Transcripts](references/troubleshooting_turns_vad.md#manual-vad-tail-clipping-and-8-khz-telephony-distortion) |
367
| New turn plays over old turn after barge-in | Server finished fast without emitting `interrupted: true` | Flush client playback buffer on new turn start and on `interrupted` | [Turns & Transcripts](references/troubleshooting_turns_vad.md#barge-in-playback-overlap-and-background-noise-triggers) |
368
| `MALFORMED_FUNCTION_CALL` on complex args | Single `STRING` parameter used as mini-DSL | Use typed `OBJECT`, `ARRAY`, `ENUM`, `BOOLEAN` properties | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#malformed_function_call-on-complex-tool-arguments) |
369
| Tool loops or duplicate reply on `NON_BLOCKING` tool | State machine in SI or missing `scheduling="SILENT"` | Move state machine to app layer; set `scheduling="SILENT"` | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#redundant-tool-loops-and-duplicate-non_blocking-speech) |
370
| Unreliable pre-tool filler on fast vs. slow tools | Per-latency-tier natural-language filler rules in SI | Call tools silently and play a client-side UI/audio cue while waiting | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#pre-tool-early-acknowledgement-filler-misfires) |
371
| Minimal test prompt ignored or agent invents data | Production `tools` left attached or framework context leak | Stub `tools` in tests; audit full serialized wire JSON | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#test-prompt-ignored-or-model-invents-unseen-data) |
372
| Stall on search grounding or ignored SI update | Undeclared `googleSearch` (incompatible with custom functions) or `clientContent` SI update | Use `googleSearch` alone or custom search tool; use `contextUpdate` on `3.8-live` | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#undeclared-google-search-deadlock-and-mid-session-si-updates) |
373
| Safety refusal on `custom_vocabulary` | Synthetic concatenated single-token compounds distorting ASR | Keep multi-word phrases space-delimited in `custom_vocabulary` | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#safety-refusals-on-custom_vocabulary) |
374
| WebSocket `1008` / `1011` / `goAway` or `429` | Unsupported `generationConfig`, timeout, or burst traffic | Audit setup fields, enable `sessionResumption`, backoff on `429` | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#websocket-1008-1011-goaway-drops-and-429-throttling) |
375
| `6-12s` `TTFT` spike or high multi-turn audio cost | Client 3P tool delay, regional queue, or 1:1 audio token retention | Log per-stage timestamps; compress/rotate sessions; check pricing | [Tools & Lifecycle](references/troubleshooting_tools_lifecycle.md#latency-ttft-triage) |
376
377
### Pre-Flight Configuration Rules
378
379
1. **Align voice gender with persona gender:** Match prebuilt `voiceName`
380
gender with `systemInstruction` persona gender so acoustic and text
381
conditioning do not compete.
382
2. **Set `speechConfig.languageCode` when pinning a regional accent or default
383
language:** While optional for dynamic multilingual auto-detection, omitting
384
it defaults the initial voice reference to `en-US` and overrides text accent
385
instructions. Use a supported BCP-47 code (such as `en-IN` or `es-US`).
386
3. **Keep `temperature >= 0.7` (default `1.0`):** Values `<= 0.3` (especially
387
when paired with `generationConfig.enableAffectiveDialog` on `2.5` models)
388
trap native-audio sampling in tonal humming loops.
389
4. **Keep `systemInstruction` `< 2,000` tokens and prune `tools` per turn:**
390
Rolling text transcripts in SI and `>40,000`-token tool declarations dilute
391
voice conditioning, causing `-34 dBFS` amplitude collapse and `0`-audio
392
turns.
393
5. **Write plain-spoken prose without markup:** Strip `#` Markdown headers,
394
`<verbatim>` / `<taskflow>` XML, Gemini-TTS `# Director's Notes`, raw IPA
395
`/slashes/`, and `"""` code delimiters so unspoken code or markup does not
396
leak into `output_transcription`.
397
6. **Separate prompt template blocks with `\n`:** Avoid concatenating adjacent
398
template sections onto a single run-on line without newline separators.
399
7. **Declare typed tool schemas:** Use `OBJECT`, `ARRAY`, `ENUM`, and `BOOLEAN`
400
instead of packing mini-DSLs into a single `STRING` argument.
401
8. **Set `scheduling="SILENT"` on transactional `NON_BLOCKING` responses:**
402
Prevents duplicate speech or `<no speech>` leaks after async tool results
403
(note: `gemini-3.8-live-extended-thinking-preview` does not support explicit
404
`FunctionResponse.scheduling`).
405
9. **Wait for `turnComplete`, not `generationComplete`:** Prevents sequential
406
`clientContent` turns from self-interrupting active playback pacing.
407
10. **Enable `contextWindowCompression` and `sessionResumption`:** Prevents
408
long-session audio drop/drift, bounds multi-turn audio token retention cost,
409
and recovers cleanly across `goAway`, `1000`, `1006`, and `1011`
410
disconnects.
411

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…