> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nicecall.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Realtime Voice SDK

> Embed a browser voice session in your own application.

Use the SDK when you want to build your own voice interface. Your backend uses its Nicecall API key to [create a realtime session](https://docs.nicecall.ai/api-reference/realtime/create-session.md). Return only the session URL and token to your browser.

```bash theme={null}
npm install @voice-session/web
```

```javascript theme={null}
import { RealtimeSession } from "@voice-session/web";

const session = new RealtimeSession({ url, token });
session.on("transcript", ({ role, text, final }) => {
  if (final) showTranscript(role, text);
});
session.on("agent_state", updateVoiceStatus);
session.on("error", showSessionError);
await session.start({ microphone: true });

// When the user ends the session:
await session.end();
```

The SDK also emits `level` for remote audio volume and `ended` when the session finishes. Keep the API key on your server. Use the URL returned by the session endpoint and request a fresh token if it expires.

Sessions expire after 15 minutes if unused. The API allows 10 creations per minute per key and 10 concurrent sessions per account, including live voice-widget sessions. A call history entry appears once the browser connects.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.