Skip to main content

Anthropic Claude LLM integration guide

How to use the Anthropic Claude LLM plugin for LiveKit Agents.

Available in
Python

Overview

Anthropic provides Claude, an advanced AI assistant with capabilities including advanced reasoning, vision analysis, code generation, and multilingual processing. With LiveKit's Anthropic integration and the Agents framework, you can build sophisticated voice AI applications.

You can also use Claude with Amazon Bedrock.

Quick reference

This section includes a basic usage example and some reference material. For links to more detailed documentation, see Additional resources.

Installation

Install the plugin from PyPI:

pip install "livekit-agents[anthropic]~=1.2"

Authentication

The Anthropic plugin requires an Anthropic API key.

Set ANTHROPIC_API_KEY in your .env file.

Usage

Use Claude within an AgentSession or as a standalone LLM service. For example, you can use this LLM in the Voice AI quickstart.

from livekit.plugins import anthropic
session = AgentSession(
llm=anthropic.LLM(
model="claude-3-5-sonnet-20241022",
temperature=0.8,
),
# ... tts, stt, vad, turn_detection, etc.
)

Parameters

This section describes some of the available parameters. See the plugin reference for a complete list of all available parameters.

modelstr | ChatModelsOptionalDefault: claude-3-5-sonnet-20241022

Model to use. For a full list of available models, see the Model options.

max_tokensintOptional

The maximum number of tokens to generate before stopping. To learn more, see the Anthropic API reference.

temperaturefloatOptionalDefault: 1

Controls the randomness of the model's output. Higher values, for example 0.8, make the output more random, while lower values, for example 0.2, make it more focused and deterministic.

Valid values are between 0 and 1. To learn more, see the Anthropic API reference.

parallel_tool_callsboolOptional

Controls whether the model can make multiple tool calls in parallel. When enabled, the model can make multiple tool calls simultaneously, which can improve performance for complex tasks.

tool_choiceToolChoice | Literal['auto', 'required', 'none']OptionalDefault: auto

Controls how the model uses tools. Set to 'auto' to let the model decide, 'required' to force tool usage, or 'none' to disable tool usage.

Additional resources

The following links provide more information about the Anthropic LLM plugin.

Voice AI quickstart

Get started with LiveKit Agents and Anthropic.