Skip to main content

Anthropic

Anthropic is an AI safety and research company, and is the creator of Claude. This page covers all integrations between Anthropic models and LangChain.

Installation and Setupโ€‹

To use Anthropic models, you need to install a python package:

pip install -U langchain-anthropic

You need to set the ANTHROPIC_API_KEY environment variable. You can get an Anthropic API key here

Chat Modelsโ€‹

ChatAnthropicโ€‹

See a usage example.

from langchain_anthropic import ChatAnthropic

model = ChatAnthropic(model='claude-3-opus-20240229')
API Reference:ChatAnthropic

LLMsโ€‹

[Legacy] AnthropicLLMโ€‹

NOTE: AnthropicLLM only supports legacy Claude 2 models. To use the newest Claude 3 models, please use ChatAnthropic instead.

See a usage example.

from langchain_anthropic import AnthropicLLM

model = AnthropicLLM(model='claude-2.1')
API Reference:AnthropicLLM

Was this page helpful?


You can also leave detailed feedback on GitHub.