# Run the voice demo locally
Source: https://docs.maelstrom-ai.co/dev/tutorials/run-voice-locally/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

By the end of this tutorial you will talk to the repository demo, watch the UI rearrange itself, and hear it describe what it just did.

This tutorial explicitly selects **OpenAI Realtime** for a server-held-key setup. Fresh visits otherwise select **GPT-Live**, which uses a different credential flow. The only provider key needed for this Realtime checkpoint is an OpenAI one.

This is a learning checkpoint, not a deployment. The demo mint route is development-only and is not deployable.

## What you need

-   The repository cloned, with `bun install` already run.
-   An `OPENAI_API_KEY` with access to the Engine and realtime models.
-   A browser with microphone permission.

## Start the demo

> [!CAUTION]
> Repository demo route is development-only
> 
> The checked-in mint route does not authenticate the caller, and it forwards the request body to the minter, so the caller chooses the model. It exists to make this tutorial runnable. Replace it with the server-owned route from the [OpenAI Realtime guide](https://docs.maelstrom-ai.co/dev/guides/voice/openai-realtime/#mint-a-credential-on-your-server) before any deployment.

1.  Copy the root `.env.example` to `.env`. Set `OPENAI_API_KEY` and uncomment `VITE_VOICE_PROVIDER=realtime`. Leave `DEMO_LOCAL_SERVER_KEY=0`; authenticated local Live is a different setup. The Deepgram, Cartesia, and LiveKit values belong to the [cascade tutorial](https://docs.maelstrom-ai.co/dev/tutorials/run-the-cascade-locally/).
    
2.  From the repository root, start the demo:
    
    Terminal window
    
    ```bash
    bunx nx dev demo
    ```
    
    This starts two processes: the Engine host and the browser app. Wait until both report ready.
    

## Take a turn

Open [http://localhost:3000](http://localhost:3000/), confirm the selector shows **OpenAI Realtime**, and connect voice. The browser asks for microphone permission — allow it.

Now just talk. There is no button to hold. OpenAI decides where your turn ends, so ask for something the demo can show and then stop speaking.

Three things should happen in order: your words appear as a transcript, the UI rearranges itself, and then the model describes the result out loud.

Watch that order. The model speaks _after_ the screen changes, never before — it is describing a layout it has already been told about, rather than predicting one. That is [the settle wait](https://docs.maelstrom-ai.co/dev/understanding/voice-architecture/#why-the-boundary-holds) doing its job.

Try one more thing: start a new request while it is still speaking. Audio interruption does not cancel a UI request. Accepted voice and typed requests share a bounded FIFO: the second waits for the first to settle, then runs against the current UI. A full or expired queue reports the request as not submitted; an unknown outcome is not permission to retry automatically.

If nothing is spoken back, check the terminal running `nx dev demo`. A rejected mint is reported there, and an expired or unauthorized `OPENAI_API_KEY` is the usual cause.

## What you just ran

You did not write any of this, but three parts of it are worth knowing before you build your own.

**You selected Realtime explicitly.** `VITE_VOICE_PROVIDER=realtime` changes the initial provider; the selector can switch it at runtime. All three providers reach the same `m.useVoice()` hook and Vessels.

| Provider | Initial selection | Credential custody | First endpoint and model to inspect |
| --- | --- | --- | --- |
| GPT-Live | Default on fresh visits | Browser-supplied key goes directly to OpenAI for voice; server-held key requires authenticated, loopback-only local mode | Browser: `/v1/live/sessions`; local server: `/api/live-session`; `gpt-live-1` with `gpt-6-luna` Responses backend |
| OpenAI Realtime | `VITE_VOICE_PROVIDER=realtime`, or select it manually | Local server mints a short-lived credential; browser-key mode mints directly with OpenAI | Local: `/api/realtime-token`; browser: `/v1/realtime/client_secrets`; default `gpt-realtime-2.1` |
| LiveKit cascade | `dev-livekit` sets `VITE_VOICE_PROVIDER=livekit`; unavailable in hosted mode | Server signs room grants; LiveKit, Deepgram, and Cartesia keys stay in the server/worker | Demo `getLivekitToken` server function and LiveKit room connection; Deepgram `nova-3`, Cartesia `sonic-3` |

Browser-key mode also supplies the key separately to the Engine for planning; browser-direct voice does not mean the entire demo keeps it exclusively in the browser. For local GPT-Live, follow the [demo README](https://github.com/maelstrom-co/maelstrom/blob/main/apps/demo/README.md#optional-gpt-live-with-a-local-server-key).

**Your key never reached the browser.** The browser posted to `/api/realtime-token`, and the server minted a short-lived credential from `OPENAI_API_KEY` and returned only that. The same server-held key also synthesizes the one fixed greeting through a development-only same-origin TTS route (`gpt-4o-mini-tts` / recommended `cedar` voice / WAV). Ordinary Realtime conversation audio still goes from the browser straight to OpenAI over WebRTC, so it never passed through the process you started. Both mint and greeting TTS routes are development-only — replace them before any deployment. The [OpenAI Realtime guide](https://docs.maelstrom-ai.co/dev/guides/voice/openai-realtime/) shows the route you would deploy in place of the demo’s.

**The greeting is AI-generated speech.** The demo discloses that next to the voice orb. It is not a human voice recording, and it uses the same recommended built-in `cedar` voice as later model replies.

**Nothing you said reached the Engine as structure.** The model called one tool with one sentence, and the Maelstrom client attached the Chart snapshot itself. That is why speaking to the demo could not break a Vessel, and it is the subject of [The voice boundary](https://docs.maelstrom-ai.co/dev/understanding/voice-architecture/).

## Next steps

-   [OpenAI Live setup and recovery](https://docs.maelstrom-ai.co/dev/guides/voice/live-opening-recovery/) — use the default provider in your own integration
-   [OpenAI Realtime](https://docs.maelstrom-ai.co/dev/guides/voice/openai-realtime/) — build the deployable integration, with an authenticated mint route
-   [Run the cascade demo locally](https://docs.maelstrom-ai.co/dev/tutorials/run-the-cascade-locally/) — the same demo with speech recognition and synthesis you operate
-   [The voice boundary](https://docs.maelstrom-ai.co/dev/understanding/voice-architecture/) — why a voice model never plans your UI
