- Use the CrewAI
LLMclass, which leverages LiteLLM in the background. - Make sure to set the LLM provider before configuring the LLM. For Anthropic, use
anthropic/<LLM name>. If you’re unsure how to do this for a specific LLM provider, refer to the LiteLLM Providers page for guidance.
Also, see the docs.
from crewai import Agent, LLM
my_llm = LLM(
api_key=os.getenv("ANTHROPIC_API_KEY"),
model="anthropic/claude-3-5-sonnet-20240620",
),
my_agent = Agent(
...,
llm=my_llm,
)