{"data":{"slug":"github-google-skills-skills-cloud-gemini-live-api-7cb3b65c99d9","title":"Generate Gemini LiveAPI Client Service","summary":"Create a client service class to connect to the Gemini Enterprise LiveAPI websocket endpoint, handling session setup, token refresh, and bidirectional message exchange. The generated code is written to a user-specified output folder, and includes an isolated environment setup for Python.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gemini-live-api-7cb3b65c99d9","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-gemini-live-api-7cb3b65c99d9","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gemini-live-api-7cb3b65c99d9.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gemini-live-api-7cb3b65c99d9\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before running the generation flow, ensure a Google Cloud project with Vertex AI \/ Gemini Enterprise Agent Platform APIs enabled, Application Default Credentials configured, and a destination output folder provided. For Python, an isolated environment (e.g. `venv`) is created inside the destination folder, and a `setup.sh` script is generated to recreate the environment and install dependencies.","instructions":"---\nname: gemini-live-api\nmetadata:\n  version: \"1.0.2\"\n  category: AiAndMachineLearning\ndescription: >-\n  Generates a Gemini LiveAPI client service class in the user's chosen programming\n  language. Use when the user wants to build, scaffold, or integrate a client\n  that connects to the Gemini Enterprise LiveAPI websocket endpoint, handles\n  session setup\/resumption, bearer token refresh, and sending\/receiving\n  `ClientMessage`\/`ServerMessage` protos. Don't use for general (non-live,\n  non-bidirectional) Gemini API usage such as one-shot `generateContent`,\n  embeddings, image\/video generation, or fine-tuning \u2014 use the `gemini-api`\n  skill for those.\n---\n\n# LiveAPI Service Skill\n\nThis skill provides instructions for generating a **LiveAPI client service\nclass** that connects to the Gemini Enterprise Live API over WebSockets. The\ngenerated client handles bidirectional streaming, bearer-token authentication\nvia Application Default Credentials (ADC), transparent session resumption, and\n`ClientMessage` \/ `ServerMessage` proto exchange.\n\nThe skill also produces a demo frontend + backend service so the user can\ninteractively validate the generated client (text, audio, video, transcription,\nand interrupt handling).\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:gemini-live-api)\"`\nand append `agent-skills\/1.0 (skill:gemini-live-api)` to `User-Agent` headers.\n\n## Prerequisites\n\nBefore running the generation flow, ensure the following are available on the\nhost:\n\n-   A Google Cloud project with the Vertex AI \/ Gemini Enterprise Agent Platform\n    APIs enabled.\n-   Application Default Credentials configured on the host running the generated\n    client:\n\n    ```bash\n    gcloud auth application-default login\n    ```\n\n-   A destination output folder supplied by the user (e.g. `\/tmp\/liveapi_out`)\n    where the generated code, environment, and demo will be written. **Never**\n    mutate the host's system Python environment.\n\n-   The user's chosen implementation language (Python is the default and\n    reference language for this skill).\n\n## Reference Files\n\nProvided files in `references\/` (do **not** treat these as standalone skills \u2014\nthey are loaded on demand):\n\n-   `client_server_messages.md`: Public reference for the `ClientMessage` \/\n    `ServerMessage` schemas used by the Live API.\n-   `client_server_messages.proto`: The proto definition generated from\n    `client_server_messages.md`.\n-   `session_manager.md`: Describes how to correctly handle sessions, buffering,\n    and resumption on disconnection.\n\n## Steps\n\n### Step 1: Copy the reference files\n\nCopy `client_server_messages.md`, `client_server_messages.proto`, and\n`session_manager.md` from this skill's `references\/` folder into the user's\ndestination output folder. These files become the source of truth for the\ngenerated client.\n\n### Step 2: Reconcile with the public documentation\n\nExamine the public documents linked from `client_server_messages.md`. If there\nare any discrepancies between the public documents and the copied\n`client_server_messages.md` \/ `client_server_messages.proto`, update the copies\nin the destination folder so the generated client compiles and runs against the\ncurrent server contract.\n\n### Step 3: Implement the client class\n\nImplement a class in the user's chosen language that:\n\n-   Imports the local `client_server_messages.proto` types (`ClientMessage`,\n    `ServerMessage`).\n-   Opens a WebSocket connection to the Live API endpoint.\n-   Exposes async methods so the user can send and receive data to\/from the\n    model.\n\nFor languages that require an isolated runtime (e.g. Python), create an isolated\nenvironment (e.g. `venv`) **inside the destination folder** and generate a bash\nscript (e.g. `setup.sh`) that recreates the environment and installs\ndependencies. **Never** install into the system interpreter or the user's global\nsite-packages, and never instruct the user to run `sudo pip install`.\n\n#### Initialization parameters\n\nThe user provides the following at construction time:\n\n-   `project_id`\n-   `location`\n-   `model_id`\n-   `config`: a `ClientMessage` with the `setup` field populated.\n\n#### Authentication\n\nObtain a bearer token via Application Default Credentials, attach it to the\nWebSocket connect request as `Authorization: Bearer <token>`, refresh the token\nbefore or upon expiry, and reuse the refreshed token on every reconnection\n(including `go_away` and unexpected disconnects). **Do not** hard-code a\nlong-lived API key as the only auth mechanism.\n\n#### Public async API\n\nThe class MUST expose the following async methods, gated on receipt of a\n`setup_complete` `ServerMessage` before sending:\n\n-   `send_realtime_data(data)`: send realtime input. `data` is a `ClientMessage`\n    carrying a `realtime_input` field.\n-   `send_client_content(data)`: send non-realtime, turn-based content that\n    contributes to history. `data` is a `ClientMessage` carrying a\n    `client_content` field.\n-   `receive()`: yield `ServerMessage` instances parsed from the WebSocket\n    stream.\n\nDo not expose synchronous blocking variants as the primary API surface.\n\n### Step 4: Write a test file\n\nOnce the client is implemented, generate a test file that initializes the\nconnection and exercises sending `text`, `audio`, and `video` data and receiving\nthe responses. Ask the user for any information required to run the test\n(project, model, media samples).\n\n### Step 5: Generate `how_to_run.md`\n\nProvide a `how_to_run.md` in the destination folder that documents the generated\nclass. Include full examples showing how to build `ClientMessage` payloads for\nevery supported modality, how to send them, and how to receive data from the\nmodel.\n\n### Step 6: Generate a demo frontend + backend service\n\nCreate scripts that deploy the implementation as a service with both a frontend\nUI and a backend service (any language). The service MUST reuse the\n`ClientMessage` \/ `ServerMessage` protos from Step 1 for wire traffic. Through\nthe UI the user should be able to:\n\n-   Start a new connection \/ close the current connection.\n-   Select the model to use.\n-   Select input sources (audio and\/or video from camera or screenshot) and\n    stream them to the model.\n-   Send a text message to the model.\n-   Hear model audio and see the interleaved model and user transcription \/\n    conversation history.\n\nWhile implementing audio and transcription playback, follow the guidance in\n[Live API best practices](https:\/\/docs.cloud.google.com\/gemini-enterprise-agent-platform\/models\/live-api\/best-practices).\n\n#### Handling the `interrupt` signal\n\nWhen a `ServerMessage`'s `server_content` arrives with `interrupted: true`, the\nUI MUST:\n\n-   Ensure played audio and its corresponding transcription remain time-aligned.\n-   Immediately stop the currently playing model audio and stop appending to the\n    in-progress transcription bubble.\n-   Clear the unplayed audio buffer and any pending unrendered transcription so\n    stale content does not bleed into the next turn.\n-   Start new chat bubbles for the next user and model turns.\n\n#### Handling the transcription `finished` signal\n\nFor streamed `input_transcription` \/ `output_transcription` chunks, append to\nthe currently active bubble while `finished` is unset, and close that bubble and\nstart a fresh one when `finished` is observed. Route `input_transcription` text\nto user-role bubbles and `output_transcription` text to model-role bubbles.\n\n### Step 7: Generate `how_to_test_with_ui.md`\n\nWrite `how_to_test_with_ui.md` describing how to launch and use the demo\nservice. It MUST include:\n\n-   The exact shell command(s) or script invocation(s) to start the backend\n    service.\n-   The exact shell command(s) or script invocation(s) to start the frontend UI.\n-   The host and port (e.g. `http:\/\/localhost:PORT`) the user should open in\n    their browser.\n-   How to start a session, select a model, choose input sources (mic, camera,\n    screen), send a text message, and observe model audio and transcription in\n    the UI.\n\n## Validation Checklist\n\nBefore considering the generation complete, verify each item:\n\n-   [ ] `client_server_messages.md`, `client_server_messages.proto`, and\n    `session_manager.md` were copied into the destination folder.\n-   [ ] The generated client imports the local proto-generated `ClientMessage`\n    and `ServerMessage` types.\n-   [ ] The client connects to the Live API WebSocket at\n    `wss:\/\/{location}-aiplatform.googleapis.com\/ws\/google.cloud.aiplatform.v1beta1.LlmBidiService\/BidiGenerateContent`\n    (regional endpoint required; Live API models do not support the `global` endpoint), and formats\n    the setup `model` field as\n    `projects\/{project_id}\/locations\/{location}\/publishers\/google\/models\/{model_id}`.\n-   [ ] Authentication uses ADC-provided bearer tokens sent as `Authorization:\n    Bearer <token>`, is refreshed before expiry, and reattached on every\n    reconnect.\n-   [ ] Public async methods `send_realtime_data`, `send_client_content`, and\n    `receive` are present, correctly typed, and gated on `setup_complete`.\n-   [ ] Transparent session resumption is enabled\n    (`session_resumption.transparent = true`), the latest `new_handle` is\n    tracked, sent-message indexing starts at 1, the buffer is pruned via\n    `last_consumed_client_message_index`, and buffered messages are replayed on\n    reconnect (including on `go_away` and WebSocket close codes 1000 \/ 1006).\n-   [ ] If using python, an isolated environment (e.g. `venv`) plus a `setup.sh`\n    and `requirements.txt` (or equivalent) exist inside the destination folder;\n    no changes were made to system or user-global Python.\n-   [ ] `how_to_run.md` and `how_to_test_with_ui.md` are present, and the demo\n    UI reuses the same `ClientMessage` \/ `ServerMessage` protos.\n-   [ ] Interrupt handling and transcription `finished` handling behave as\n    described above.\n-   [ ] The client does **not** target `generativelanguage.googleapis.com` and\n    does **not** authenticate via API key in a query string.\n","use_cases":["Build a real-time chatbot that streams responses from Gemini Enterprise","Develop a live data analysis tool that exchanges structured messages with the model","Create a collaborative AI interface that supports turn-based content input"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/gemini-live-api\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T14:47:49.000000Z","updated_at":"2026-11-17T10:20:00.000000Z","seo_title":"Generate Gemini LiveAPI Client Service","seo_description":"Create a Gemini LiveAPI client service class for bidirectional WebSocket communication with session management and token refresh.","seo_keywords":["Gemini LiveAPI client","WebSocket bidirectional communication","Gemini Enterprise session management","Realtime AI message exchange","Gemini LiveAPI setup"]}}