Registry / llm-agents / livekit-plugins-anthropic

livekit-plugins-anthropic

JSON →
library1.6.0pypypi✓ verified 83d ago

livekit-plugins-anthropic is an Agent Framework plugin for integrating Anthropic's Claude family of Large Language Models (LLMs) with LiveKit Agents. It enables developers to use Claude APIs as an LLM provider for building real-time voice AI agents, supporting both text-based conversations and vision input capabilities. The current version is 1.5.4, with releases tied to the livekit-agents framework's active development and rapid feature additions.

pip install livekit-plugins-anthropic
INSTALL
IMPORT
SIG · LIVEKIT-PLUGINS-AN
L
livekit-plugins-anthropic
llm-agentspythonv1.6.0
Install
15.3s avg
Import
6482ms
Disk
291MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 6.216s · 241.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 18.4s · import 5.451s · 331MB
291MB installed
● package 291MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LLM
from livekit.plugins.anthropic import LLM
from livekit.plugins import anthropic

This quickstart demonstrates how to initialize the Anthropic LLM within a LiveKit AgentSession. It highlights the essential `livekit.plugins.anthropic.LLM` class and the requirement for the `ANTHROPIC_API_KEY` environment variable. A full LiveKit agent typically processes real-time audio/text, but this snippet focuses on the Anthropic LLM setup.

import os from livekit.agents import AgentSession, JobContext from livekit.plugins import anthropic # Set your Anthropic API key as an environment variable # os.environ["ANTHROPIC_API_KEY"] = "sk-your-anthropic-key" async def my_agent(ctx: JobContext): # Ensure ANTHROPIC_API_KEY is set in your environment or passed directly anthropic_api_key = os.environ.get('ANTHROPIC_API_KEY', '') if not anthropic_api_key: raise ValueError("ANTHROPIC_API_KEY environment variable is not set.") print("Starting agent session with Anthropic LLM...") session = AgentSession( llm=anthropic.LLM( model="claude-3-5-sonnet-20241022", api_key=anthropic_api_key # Can be omitted if env var is set ) ) # In a real agent, you'd process audio/text input and generate replies. # This is a minimal example to show LLM instantiation. print(f"Agent session created with LLM model: {session.llm.model}") # Example of a simple chat interaction (requires AgentSession context for full functionality) # from livekit.agents.llm import ChatContext, UserMessage # chat_ctx = ChatContext() # chat_ctx.append(UserMessage(text="Hello, what can you do?")) # response = await session.llm.chat(chat_ctx) # async for chunk in response.stream: # print(chunk.delta) await session.astop() print("Agent session stopped.") # To run this, you would typically integrate it with a LiveKit server # and an Agent runner, like: # if __name__ == "__main__": # from livekit.agents import cli # cli.run_agent(my_agent)
Debug
Known issues
breakingStarting with livekit-agents 1.5.0, preemptive generation is enabled by default. This alters how LLM and TTS inference begins before a user's turn ends, potentially changing latency characteristics.
fix
To disable preemptive generation, initialize AgentSession with `AgentSession(preemptive_generation=False)`.
affects: >=1.5.0
gotchaOlder versions of livekit-plugins-anthropic (before 1.4.5) might experience issues with 'trailing assistant turns' when using Claude 4.6+ models, potentially leading to incorrect responses.
fix
Upgrade to livekit-plugins-anthropic version 1.4.5 or newer to ensure correct handling of Claude 4.6+ models.
affects: <1.4.5
gotchaWhen using Anthropic prompt caching, the `max_tokens` parameter must be strictly greater than `budget_tokens` to avoid configuration errors. Very short system prompts or tool lists may also not qualify for caching.
fix
Ensure `max_tokens` is set sufficiently higher than `budget_tokens` in your LLM configuration. Refer to Anthropic's documentation for minimum cacheable block sizes.
affects: All
gotchaThe Anthropic plugin may not generate tool schemas with strict mode constraints, even though Anthropic's API supports a `strict` field on tool definitions for guaranteed schema conformance. This could lead to the model returning incompatible types or missing required fields.
fix
Carefully validate tool outputs from the Anthropic LLM. Monitor GitHub issues for updates on `strict` tool schema support in livekit-plugins-anthropic. If strict validation is critical, implement manual validation or consider alternative tool invocation strategies.
affects: All known versions up to 1.5.4 (as of March 2026 issue)
Upgrade
Version history
1.6.0latest on PyPI · released Jun 11, 2026
Audit
Dependencies
livekit-agentsrequiredCore framework for building LiveKit agents; this is a plugin for it.
anthropicrequiredOfficial Anthropic Python client library, required for API interaction.
Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
1
Resources
livekit-plugins-anthropic — pip install livekit-plugins-anthropic · libregistry