Agent Frameworks

How do you use Claude with LlamaIndex?

QUICK ANSWER

To use Claude with LlamaIndex, install 'llama-index-llms-anthropic', initialize the Anthropic class model, and configure it as your global LLM setting.

Python Setup

# pip install llama-index-llms-anthropic

from llama_index.llms.anthropic import Anthropic
from llama_index.core import Settings

Settings.llm = Anthropic(
    model="claude-3-5-sonnet-20241022",
    api_key="your-api-key"
)
Verified against: LlamaIndex v0.10.0