# gemini-3-1-flash-tts > Gemini 3.1 Flash TTS turns written dialogue into expressive, natural multi-speaker speech with fine-grained control over voice, accent, emotional style, and pace. Ideal for fast, affordable voiceovers, character dialogue, and narration. ## Overview - **Endpoint**: `POST https://api.muapi.ai/api/v1/gemini-3-1-flash-tts` - **Model ID**: `gemini-3-1-flash-tts` - **Category**: text to audio - **Variant**: 3.1 Flash - **Family**: gemini-tts - **Cost**: 0.035 credits per call (some models compute cost dynamically based on params) ## API Usage MuApi uses a **submit-then-poll** pattern: submit a job, get a `request_id`, then poll the predictions endpoint until `status` is `completed`. Optionally pass `?webhook=YOUR_URL` on the submit call to receive a POST callback when the job finishes (skip polling). **Authentication**: send your MuApi key in the `x-api-key` header. Get one at https://muapi.ai/access-keys. ### 1. Submit a job ```http POST https://api.muapi.ai/api/v1/gemini-3-1-flash-tts Content-Type: application/json x-api-key: YOUR_API_KEY ``` **Minimum (required only):** ```json { "speakers": [ { "pace": "Natural", "style": "Deadpan", "accent": "British (RP)", "speaker_id": "Speaker 1", "voice_name": "Fenrir", "audio_profile": "A stern and weary gatekeeper" }, { "pace": "Staccato", "style": "Empathetic", "accent": "American (Gen)", "speaker_id": "Speaker 2", "voice_name": "Puck", "audio_profile": "A determined and courageous traveler seeking answers." } ], "dialogue_turns": [ { "text": "[shouting] Halt, traveler! The northern pass is sealed by order of the council.", "speaker_id": "Speaker 1" }, { "text": "[determination] I carry a message for the elder. Step aside, or I will force my way through.", "speaker_id": "Speaker 2" }, { "text": "[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors.", "speaker_id": "Speaker 1" }, { "text": "It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now.", "speaker_id": "Speaker 2" } ] } ``` **Full example (all params):** ```json { "scene": "", "speakers": [ { "pace": "Natural", "style": "Deadpan", "accent": "British (RP)", "speaker_id": "Speaker 1", "voice_name": "Fenrir", "audio_profile": "A stern and weary gatekeeper" }, { "pace": "Staccato", "style": "Empathetic", "accent": "American (Gen)", "speaker_id": "Speaker 2", "voice_name": "Puck", "audio_profile": "A determined and courageous traveler seeking answers." } ], "temperature": 1, "dialogue_turns": [ { "text": "[shouting] Halt, traveler! The northern pass is sealed by order of the council.", "speaker_id": "Speaker 1" }, { "text": "[determination] I carry a message for the elder. Step aside, or I will force my way through.", "speaker_id": "Speaker 2" }, { "text": "[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors.", "speaker_id": "Speaker 1" }, { "text": "It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now.", "speaker_id": "Speaker 2" } ], "sample_context": "" } ``` **Response:** ```json { "request_id": "abc123", "status": "processing" } ``` ### 2. Poll for the result ```http GET https://api.muapi.ai/api/v1/predictions/{request_id}/result x-api-key: YOUR_API_KEY ``` Possible `status` values: `queued`, `pending`, `processing`, `completed`, `failed`, `cancelled`. Poll every 2-5 seconds until terminal. When `completed`, the result URLs are in the `outputs` array. **Example response when `completed`:** ```json { "id": "abc123", "status": "completed", "outputs": [ "https://cdn.muapi.ai/.../output.png" ], "urls": { "get": "https://api.muapi.ai/api/v1/predictions/abc123/result" }, "created_at": "2026-05-08T12:34:56Z", "has_nsfw_contents": [] } ``` ### cURL ```bash # 1. Submit REQUEST_ID=$(curl -s -X POST https://api.muapi.ai/api/v1/gemini-3-1-flash-tts \ -H "x-api-key: $MUAPI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"speakers":[{"pace":"Natural","style":"Deadpan","accent":"British (RP)","speaker_id":"Speaker 1","voice_name":"Fenrir","audio_profile":"A stern and weary gatekeeper"},{"pace":"Staccato","style":"Empathetic","accent":"American (Gen)","speaker_id":"Speaker 2","voice_name":"Puck","audio_profile":"A determined and courageous traveler seeking answers."}],"dialogue_turns":[{"text":"[shouting] Halt, traveler! The northern pass is sealed by order of the council.","speaker_id":"Speaker 1"},{"text":"[determination] I carry a message for the elder. Step aside, or I will force my way through.","speaker_id":"Speaker 2"},{"text":"[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors.","speaker_id":"Speaker 1"},{"text":"It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now.","speaker_id":"Speaker 2"}]}' | jq -r .request_id) # 2. Poll until completed while :; do RESP=$(curl -s https://api.muapi.ai/api/v1/predictions/$REQUEST_ID/result -H "x-api-key: $MUAPI_API_KEY") STATUS=$(echo "$RESP" | jq -r .status) [ "$STATUS" = "completed" ] && echo "$RESP" | jq .outputs && break [ "$STATUS" = "failed" ] && echo "$RESP" && exit 1 sleep 3 done ``` ### Python ```python import os, time, requests API = "https://api.muapi.ai/api/v1" headers = {"x-api-key": os.environ["MUAPI_API_KEY"]} r = requests.post(f"{API}/gemini-3-1-flash-tts", headers=headers, json={"speakers":[{"pace":"Natural","style":"Deadpan","accent":"British (RP)","speaker_id":"Speaker 1","voice_name":"Fenrir","audio_profile":"A stern and weary gatekeeper"},{"pace":"Staccato","style":"Empathetic","accent":"American (Gen)","speaker_id":"Speaker 2","voice_name":"Puck","audio_profile":"A determined and courageous traveler seeking answers."}],"dialogue_turns":[{"text":"[shouting] Halt, traveler! The northern pass is sealed by order of the council.","speaker_id":"Speaker 1"},{"text":"[determination] I carry a message for the elder. Step aside, or I will force my way through.","speaker_id":"Speaker 2"},{"text":"[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors.","speaker_id":"Speaker 1"},{"text":"It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now.","speaker_id":"Speaker 2"}]}) request_id = r.json()["request_id"] while True: res = requests.get(f"{API}/predictions/{request_id}/result", headers=headers).json() if res["status"] == "completed": print(res["outputs"]); break if res["status"] == "failed": raise RuntimeError(res.get("error")); time.sleep(3) ``` ## Input Schema The API accepts the following input parameters: - **`scene`** (`string`, _optional_): Optional scene description that sets the acoustic setting, e.g. "A quiet, warm room with a fireplace crackling softly." - Default: `""` - **`speakers`** (`array`, _required_): List of speaker voice configurations. Each dialogue turn references a speaker by its ID. - **`speakers[].pace`** (`string`, _required_): Speaking pace. - Default: `"Natural"` - Options: `"Natural"`, `"Rapid Fire"`, `"The Drift"`, `"Staccato"` - **`speakers[].style`** (`string`, _required_): Emotional delivery style. - Default: `"Empathetic"` - Options: `"Vocal Smile"`, `"Newscaster"`, `"Whisper"`, `"Empathetic"`, `"Promo/Hype"`, `"Deadpan"` - **`speakers[].accent`** (`string`, _required_): Speaking accent. - Default: `"Neutral"` - Options: `"Neutral"`, `"American (Gen)"`, `"American (Valley)"`, `"American (South)"`, `"British (RP)"`, `"British (Brixton)"`, `"Transatlantic"`, `"Australian"` - **`speakers[].speaker_id`** (`string`, _required_): Speaker identifier. Must be in "Speaker N" format (e.g. "Speaker 1"). - **`speakers[].voice_name`** (`string`, _required_): Prebuilt Gemini voice name. - Options: `"Achernar"`, `"Achird"`, `"Algenib"`, `"Algieba"`, `"Alnilam"`, `"Aoede"`, `"Autonoe"`, `"Callirrhoe"`, `"Charon"`, `"Despina"`, `"Enceladus"`, `"Erinome"`, `"Fenrir"`, `"Gacrux"`, `"Iapetus"`, `"Kore"`, `"Laomedeia"`, `"Leda"`, `"Orus"`, `"Puck"`, `"Pulcherrima"`, `"Rasalgethi"`, `"Sadachbia"`, `"Sadaltager"`, `"Schedar"`, `"Sulafat"`, `"Umbriel"`, `"Vindemiatrix"`, `"Zephyr"`, `"Zubenelgenubi"` - **`speakers[].audio_profile`** (`string`, _optional_): Optional natural-language description of the persona, e.g. "A warm and soothing narrator". - **`temperature`** (`number`, _optional_): Sampling temperature (0-2). Higher values produce more varied delivery. - Default: `1` - Range: `0` to `2` - **`dialogue_turns`** (`array`, _required_): Ordered list of dialogue lines. Each turn's speaker_id must match a speaker defined above. Text may include tone tags like [shouting] or [whispers]. - **`dialogue_turns[].text`** (`string`, _required_): The line to speak. Supports inline tone tags. Max 10000 characters. - **`dialogue_turns[].speaker_id`** (`string`, _required_): ID of the speaker delivering this line (e.g. "Speaker 1"). - **`sample_context`** (`string`, _optional_): Optional overall tone/style, e.g. "Audiobook style narration. Tone is gentle and inviting." - Default: `""` ## Output Schema The polling endpoint returns the following fields: - **`id`** (`string`): The request ID. - **`status`** (`string`): One of `queued`, `pending`, `processing`, `completed`, `failed`, `cancelled`. - **`outputs`** (`array`): URLs to generated images/videos/audio. Empty until `status` is `completed`. - **`urls.get`** (`string`): Self-link to re-fetch this prediction. - **`error`** (`string` | `null`): Error message if `status` is `failed`. - **`created_at`** (`string`): ISO-8601 timestamp of when the request was created. - **`has_nsfw_contents`** (`array of boolean`): Per-output NSFW detection flags. ## Webhooks (optional) Append `?webhook=https://your-server/path` to the submit URL. When the job reaches a terminal state, MuApi will POST the same shape as the polling response to your URL — no polling needed. ## Agent Integration MuApi ships an MCP server and CLI so agents (Claude Code, Cursor, custom) can call this endpoint without writing HTTP code: ```bash # Install the CLI npm install -g muapi-cli # Authenticate once muapi auth login # Expose all MuApi models as MCP tools to your agent muapi mcp serve ``` The MCP server exposes tools that wrap submit + poll for every model, including `gemini-3-1-flash-tts`. See `muapi --help` for category-specific shortcuts (`muapi image generate`, `muapi video from-image`, etc.). ## Related Models - [3.1 Flash](https://muapi.ai/playground/gemini-3-1-flash-tts) - [2.5 Pro](https://muapi.ai/playground/gemini-2-5-pro-tts) ## Resources - [Playground Page](https://muapi.ai/playground/gemini-3-1-flash-tts) - [API Reference](https://muapi.ai/playground/gemini-3-1-flash-tts?tab=2) - [Global llms.txt](https://muapi.ai/llms.txt)