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

# Livekit

LiveKit is a realtime communication platform that allows you to create voice and video chat applications.

## Build your AI video agent with LiveKit

We recommend using LiveKit to run your Simli agent. below is a guide to set up your environment and dependencies.

0. **Set up a LiveKit account at [LiveKit.io](https://livekit.io).**

You're gonna a "Video conference" Sandbox project and 3 environment variables from your settings page for later.

<img src="https://mintcdn.com/simli/NELbEX-teJCHwcnx/images/livekit-tutorial.png?fit=max&auto=format&n=NELbEX-teJCHwcnx&q=85&s=f66aaeda677c51cd475bb7408872be96" alt="LiveKit Logo" width="3149" height="1856" data-path="images/livekit-tutorial.png" />

1. **Create a new folder on your computer**:

   ```bash theme={null}
   python3 -m venv .venv
   source .venv/bin/activate
   touch livekit-simli.py
   ```

2. **Install dependencies**:

   ```bash theme={null}
   pip install \
   "livekit-agents[openai]" \
   "livekit-plugins-simli" \
   "python-dotenv"
   ... etc
   ```

3. **Set up your .env file**:
   Create a `.env` file in your project directory and add your api keys for Simli, Livekit, and other services. For example:

   ```
   LIVEKIT_URL=wss://...
   LIVEKIT_API_KEY=...
   LIVEKIT_API_SECRET=...

   OPENAI_API_KEY=...

   SIMLI_API_KEY=...
   SIMLI_FACE_ID=...
   ```

4. **Fill in your LiveKit runner code**:
   Here's a simple example of a `livekit-simli.py` file. Ensure your `.env` file is in the same directory as this file.

```python livekit-simli.py theme={null}
import logging
import os

from dotenv import load_dotenv

from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, WorkerType, cli
from livekit.plugins import openai, simli

# from livekit.plugins import deepgram, elevenlabs, silero

logger = logging.getLogger("simli-avatar-example")
logger.setLevel(logging.INFO)

load_dotenv()


async def entrypoint(ctx: JobContext):
    session = AgentSession(
        llm=openai.realtime.RealtimeModel(voice="alloy"),
    )

    simliAPIKey = os.getenv("SIMLI_API_KEY")
    simliFaceID = os.getenv("SIMLI_FACE_ID")

    simli_avatar = simli.AvatarSession(
        simli_config=simli.SimliConfig(
            api_key=simliAPIKey,
            face_id=simliFaceID,
        ),
    )
    await simli_avatar.start(session, room=ctx.room)

    # start the agent, it will join the room and wait for the avatar to join
    await session.start(
        agent=Agent(instructions="Talk to me!"),
        room=ctx.room,
    )

```

5. **Run your bot**:

   ```bash theme={null}
   python3 livekit-simli.py
   ```

   and visit your Sandbox in `LiveKit.io` to talk to your agent in the browser. You can of course build your own clients that plug into the LiveKit pipeline!

6. **Deploy**:
   You can self host livekit agents by running the command in a macbook in a closet. However, we recommend that you check [livekit cloud](https://docs.livekit.io/deploy/agents/). To make your frontend instead of the sandboxes, you can checkout the [livekit docs for agent frontends](https://docs.livekit.io/frontends/components/agents-ui/)

7. **Learn more**:
   For detailed documentation, visit [LiveKit's guide to Simli](https://docs.livekit.io/agents/integrations/avatar/simli/) or keep exploring Simli docs for more insights.
