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

# JavaScript SDK

> Build web applications with TruGen AI avatars using the JavaScript SDK.

The TruGen JavaScript SDK lets you embed interactive AI avatars directly into your web application. It handles the WebRTC connection, audio streaming, and event system — so you can focus on building your experience.

```bash theme={null}
npm install @trugen/js-sdk
```

Or import directly in the browser via CDN:

```html theme={null}
<script type="module">
  import { createClient, TruGenEvent } from "https://esm.sh/@trugen/js-sdk";
</script>
```

## When to Use the SDK

| Use Case                                         | Recommended Approach                                                                             |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
| Custom UI with full control over the session     | **JavaScript SDK**                                                                               |
| Fine-grained event handling and audio management | **JavaScript SDK**                                                                               |
| Quick embed with no code                         | [iFrame](/docs/integrations/embed-via-iFrame) or [Widget](/docs/integrations/widget-integration) |

## What the SDK Provides

* **Session management** — create, connect, and disconnect avatar sessions
* **Real-time events** — listen for speaking, transcript, connection, and mic events
* **Audio control** — mute, unmute, switch devices, and inject custom audio
* **Media access** — direct access to WebRTC video and audio tracks
* **Raw frame processing** — feed frames into custom pipelines or canvas layouts

## What's Next?

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/docs/sdks/javascript/quickstart">
    Get your first AI avatar running in under 5 minutes.
  </Card>

  <Card title="Authentication" icon="lock" href="/docs/sdks/javascript/authentication">
    Learn how to secure your API key with server-side session tokens.
  </Card>

  <Card title="Examples" icon="code" href="/docs/sdks/javascript/examples/basic-javascript">
    Full working examples in JavaScript and TypeScript.
  </Card>

  <Card title="Reference" icon="book" href="/docs/sdks/javascript/reference/basic-usage">
    Complete SDK reference for all methods and events.
  </Card>
</CardGroup>
