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

# LiveKit

> Realtime rooms and agents via the Cartesia plugin or LiveKit Inference

<Frame>
  <img src="https://mintcdn.com/cartesia-2650f86a/GOsvXpql8JfAlgjy/assets/images/livekit-agents.png?fit=max&auto=format&n=GOsvXpql8JfAlgjy&q=85&s=40fda2b78d535c4400f96caba840ce88" alt="LiveKit Agents logo" width="1200" height="630" data-path="assets/images/livekit-agents.png" />
</Frame>

LiveKit is a WebRTC-first platform for realtime video, voice, and data in your product. LiveKit Agents is its framework for conversational agents.

Cartesia integrates in two ways: open source plugins and [LiveKit Inference](https://docs.livekit.io/agents/models/inference/).

<Card horizontal title="Quickstart" href="https://github.com/cartesia-ai/cartesia-livekit-voice-agent">
  GitHub template for a basic LiveKit voice agent
</Card>

## Open source plugins

These are plugins that can be used with the open-source LiveKit Agents packages.

<Tabs>
  <Tab title="Python">
    You can use Cartesia with Python LiveKit Agents by installing the `livekit-plugins-cartesia` package.
    If needed, you can the source code of the plugin in the [/livekit-plugins/livekit-plugins-cartesia](https://github.com/livekit/agents/tree/main/livekit-plugins/livekit-plugins-cartesia) directory of the `livekit/agents` repo.

    <Note>
      Ink 2 requires `livekit-plugins-cartesia>=1.5.15`.\
      Older versions will produce poor results without raising runtime errors.
    </Note>

    ### Setting up the Python plugin in your own agent

    To get started, first install the main [livekit-agents](https://pypi.org/project/livekit-agents) package as well as [livekit-plugins-cartesia](https://pypi.org/project/livekit-plugins-cartesia/):

    ```bash theme={null}
    pip install livekit-agents livekit-plugins-cartesia
    ```

    Then, use the Cartesia STT and TTS plugins when creating your agent:

    ```python theme={null}
    from livekit.agents import AgentSession
    from livekit.plugins import cartesia

    session = AgentSession(
        stt=cartesia.STT(
            api_key=os.environ.get("CARTESIA_API_KEY"),
        ),
        tts=cartesia.TTS(
            api_key=os.environ.get("CARTESIA_API_KEY"),
        ),
        # ... llm, vad, turn_handling, etc.
    )
    ```

    ### Running a Python example

    Check out [/examples/other/cartesia.py](https://github.com/livekit/agents/blob/99d81a1dd3a026ee3e708dcde74ee8c224fc2a57/examples/other/cartesia.py) in the `livekit/agents` repo for a fully working conversational agent.

    ```bash theme={null}
    # clone and setup livekit/agents
    git clone git@github.com:livekit/agents.git
    cd agents
    uv sync

    # run with required API keys:
    # - CARTESIA_API_KEY
    # - LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET
    # -  some LLM provider's API key
    uv run examples/other/cartesia.py console
    ```
  </Tab>

  <Tab title="Node.js">
    You can use Cartesia with Node.js LiveKit Agents by installing the `@livekit/agents-plugins-cartesia` package.
    If needed, you can reference the source code of the plugin in the [/plugins/cartesia](https://github.com/livekit/agents-js/tree/main/plugins/cartesia) directory of the `livekit/agents-js` repo.

    <Note>
      LiveKit Agents is not feature complete in Node.js
    </Note>

    ### Setting up the Node.js plugin in your own agent

    To get started, first install the main [@livekit/agents](https://www.npmjs.com/package/@livekit/agents) package as well as [@livekit/agents-plugins-cartesia](https://www.npmjs.com/package/@livekit/agents-plugin-cartesia):

    ```bash theme={null}
    npm i @livekit/agents @livekit/agents-plugin-cartesia
    ```

    Then, use the Cartesia STT and TTS plugins when creating your agent:

    ```typescript theme={null}
    import { AgentSession } from '@livekit/agents';
    import * as cartesia from "@livekit/agents-plugin-cartesia";

    const session = new AgentSession({
      stt: new cartesia.STT({
        apiKey: process.env.CARTESIA_API_KEY,
      }),
      tts: new cartesia.TTS({
        apiKey: process.env.CARTESIA_API_KEY,
      }),
      // ... llm, vad, turnHandling, etc.
    });
    ```

    ### Running a Node.js example

    Check out [/examples/src/cartesia.ts](https://github.com/livekit/agents-js/blob/ee078ec394e697a989bd0faf53aa043392fa7ae4/examples/src/cartesia.ts) in the `livekit/agents-js` repo for a fully working conversational agent.

    ```bash theme={null}
    # clone and setup livekit/agents-js
    git clone git@github.com:livekit/agents-js.git
    cd agents-js
    pnpm i && pnpm run build

    # run with required API keys:
    # - CARTESIA_API_KEY
    # - LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET
    # -  some LLM provider's API key
    node ./examples/src/cartesia.ts dev

    # go to https://agents-playground.livekit.io/
    # find your agent (make sure you're in the right org)
    # then connect to it with WebRTC transport
    ```
  </Tab>
</Tabs>

## LiveKit Inference

You can also use Cartesia's models on LiveKit's infrastructure. API keys and pricing are managed by LiveKit rather than Cartesia.

1. [LiveKit docs for Cartesia STT](https://docs.livekit.io/agents/models/stt/cartesia/)
2. [LiveKit docs for Cartesia TTS](https://docs.livekit.io/agents/models/tts/cartesia/)

<CodeGroup>
  ```python Python theme={null}
  from livekit.agents import AgentSession, inference

  session = AgentSession(
      stt=inference.STT(model="cartesia/ink-2"),
      tts=inference.TTS(model="cartesia/sonic-latest"),
      # ... llm, vad, turn_handling, etc.
  )
  ```

  ```typescript Node.js theme={null}
  import { AgentSession, inference } from '@livekit/agents';

  const session = new AgentSession({
      stt: new inference.STT({ model: "cartesia/ink-2" }),
      tts: new inference.TTS({ model: "cartesia/sonic-latest" }),
      // ... llm, vad, turnHandling, etc.
  });
  ```
</CodeGroup>

## Demo

<Card title="LiveKit Cartesia Demo" icon="solid link" href="https://cartesia-assistant.vercel.app/">
  Try out a simple voice assistant built with LiveKit Agents and Cartesia.
</Card>

Simplified source code for the demo is available on GitHub in the [cartesia-ai/livekit-agents-example](https://github.com/cartesia-ai/livekit-agents-example) repo.
