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

# Node SDK

> Stream audio or play a file from a Node voice agent.

Use Node 20+.

```bash theme={null}
npm install @openspline/node
```

For Cloud, set `OPENSPLINE_API_KEY`. For a local service, leave it unset or set `OPENSPLINE_URL`.

```ts theme={null}
import { Openspline } from "@openspline/node";

const client = new Openspline();
const avatar = await client.avatar("portrait.jpg");
try {
  console.log(avatar.viewerUrl);
  await avatar.stream(agent.audioStream(), { sample_rate: 24000 });
} finally {
  await avatar.close();
}
```

Play a WAV or MP3 file:

```js theme={null}
const avatar = await new Openspline().avatar("portrait.jpg");
try {
  console.log(avatar.viewerUrl);
  await avatar.playFile("speech.wav");
} finally {
  await avatar.close();
}
```

For a saved Cloud avatar, call `client.avatar({ avatarId: "YOUR_AVATAR_ID" })`. The Node equivalents of `send_audio`, `end_turn`, and `interrupt` are `sendAudio`, `endTurn`, and `interrupt`.

[Runnable Node example](https://github.com/openspline/openspline/blob/main/examples/node/universal.mjs) · [Configuration](/reference/configuration) · [Backgrounds](/guides/backgrounds)


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