{"id":51861289,"url":"https://github.com/csicar/gemini-live-mock-server","last_synced_at":"2026-07-24T07:30:25.008Z","repository":{"id":368593368,"uuid":"1272046490","full_name":"csicar/gemini-live-mock-server","owner":"csicar","description":"Basic websocket server implementing the gemini live api","archived":false,"fork":false,"pushed_at":"2026-07-01T08:45:57.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-01T10:26:54.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csicar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-17T08:36:06.000Z","updated_at":"2026-07-01T08:57:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/csicar/gemini-live-mock-server","commit_stats":null,"previous_names":["csicar/gemini-live-mock-server"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/csicar/gemini-live-mock-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csicar%2Fgemini-live-mock-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csicar%2Fgemini-live-mock-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csicar%2Fgemini-live-mock-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csicar%2Fgemini-live-mock-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csicar","download_url":"https://codeload.github.com/csicar/gemini-live-mock-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csicar%2Fgemini-live-mock-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35832970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-24T02:00:07.870Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-24T07:30:24.541Z","updated_at":"2026-07-24T07:30:25.001Z","avatar_url":"https://github.com/csicar.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gemini Live API Mock Server\n\nA WebSocket mock server that implements the Gemini Live API protocol for testing speech-to-speech bots without consuming API tokens.\n\n## Features\n\n- **Full Gemini Live API protocol support** - Setup, client content, realtime input, tool calls\n- **Configurable response delays** - Simulate network/model latency\n- **Tool call support** - Trigger tool calls at configurable intervals\n- **Energy-based VAD** - Detect end-of-turn using audio energy levels\n- **Audio logging** - Write input/output audio to WAV files for analysis\n- **Echo mode** - Returns input audio upsampled from 16kHz to 24kHz\n- **Session close control** - From Rust test code, trigger the active session's connection to close with a specific WebSocket close code/reason, or drop abruptly (see [Simulating a Server-Initiated Disconnect](#simulating-a-server-initiated-disconnect))\n\n## Installation\n\n```bash\ncargo build --release\n```\n\n## Usage\n\n```bash\n# Basic usage with defaults\ncargo run\n\n# With custom configuration\ncargo run -- \\\n    --listen 127.0.0.1:8080 \\\n    --response-delay 500 \\\n    --tool-call-interval 3 \\\n    --vad-energy-threshold 0.01 \\\n    --vad-silence-frames 30 \\\n    --audio-output-dir ./audio_logs\n```\n\n### Command Line Options\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `--listen` | `127.0.0.1:8080` | Address to listen on |\n| `--response-delay` | `200` | Delay (ms) between end-of-speech and response |\n| `--tool-call-interval` | `0` | Trigger tool call every N turns (0 = disabled) |\n| `--vad-energy-threshold` | `0.01` | RMS energy threshold for speech detection |\n| `--vad-silence-frames` | `30` | Frames of silence before end-of-turn |\n| `--audio-output-dir` | `./audio_logs` | Directory for WAV audio logs |\n\n## Testing\n\n### With websocat\n\n```bash\n# Install websocat\ncargo install websocat\n\n# Connect to the mock server\nwebsocat ws://127.0.0.1:8080\n```\n\nSend a setup message:\n```json\n{\"setup\":{\"model\":\"gemini-live-2.5-flash-preview\",\"generationConfig\":{\"responseModalities\":[\"TEXT\"]}}}\n```\n\nSend content:\n```json\n{\"clientContent\":{\"turns\":[{\"role\":\"user\",\"parts\":[{\"text\":\"Hello!\"}]}],\"turnComplete\":true}}\n```\n\n### With Python\n\n```python\nimport asyncio\nimport websockets\nimport json\n\nasync def test_mock_server():\n    async with websockets.connect(\"ws://127.0.0.1:8080\") as ws:\n        # Setup\n        await ws.send(json.dumps({\n            \"setup\": {\n                \"model\": \"gemini-live-2.5-flash-preview\",\n                \"generationConfig\": {\"responseModalities\": [\"TEXT\"]}\n            }\n        }))\n        print(\"Setup response:\", await ws.recv())\n\n        # Send content\n        await ws.send(json.dumps({\n            \"clientContent\": {\n                \"turns\": [{\"role\": \"user\", \"parts\": [{\"text\": \"Hello!\"}]}],\n                \"turnComplete\": True\n            }\n        }))\n\n        # Receive responses\n        while True:\n            msg = await ws.recv()\n            data = json.loads(msg)\n            print(\"Received:\", data)\n            if data.get(\"serverContent\", {}).get(\"turnComplete\"):\n                break\n\nasyncio.run(test_mock_server())\n```\n\n### Simulating a Server-Initiated Disconnect\n\nFor Rust integration tests that need to verify how a client handles Gemini closing the\nconnection (e.g. with a specific close code/reason, or an abrupt drop), start the server\nwith `run_server_with_control` instead of `run_server`:\n\n```rust\nuse gemini_live_mock_server::{CloseMode, ServerConfig, run_server_with_control};\n\nlet config = ServerConfig::default();\nlet (server, control) = run_server_with_control(\n    config,\n    CloseMode::Frame { code: 1008, reason: \"policy violation\".to_string() },\n);\ntokio::spawn(async move { server.await.unwrap(); });\n\n// ... connect a client and drive the interaction ...\n\ncontrol.trigger_close();\n```\n\n`CloseMode` covers three distinct wire-level scenarios:\n\n- `Frame { code, reason }` - a close handshake carrying an explicit code and reason.\n- `EmptyFrame` - a close handshake with no payload at all (many clients surface this as\n  close code 1005, \"no status received\").\n- `Abrupt` - the connection is dropped without any close handshake, simulating a crash or\n  network failure (many clients surface this as close code 1006, \"abnormal closure\").\n\n`ServerControl` reaches into whichever session is currently active, so this is intended for\ntest scenarios with one connection at a time.\n\n## Audio Formats\n\n- **Input**: PCM 16-bit mono, 16kHz (matches Gemini Live API)\n- **Output**: PCM 16-bit mono, 24kHz (matches Gemini Live API)\n\n## Audio Logging\n\nWhen audio is received, the server writes WAV files to the configured output directory:\n\n- `{session_id}_input.wav` - Input audio at 16kHz\n- `{session_id}_output.wav` - Output audio at 24kHz\n\n## Protocol Support\n\n### Supported Client Messages\n\n- `setup` - Session configuration\n- `clientContent` - Turn-based text/image content\n- `realtimeInput` - Streaming audio/video input\n- `toolResponse` - Function call responses\n\n### Supported Server Messages\n\n- `setupComplete` - Session established\n- `serverContent` - Model responses (text/audio)\n- `toolCall` - Function call requests\n- `usageMetadata` - Token usage statistics\n- `voiceActivity` - VAD events (start/end)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsicar%2Fgemini-live-mock-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsicar%2Fgemini-live-mock-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsicar%2Fgemini-live-mock-server/lists"}