跳到主要内容
Open on GitHub

Anthropic

Anthropic 是一家 AI 安全和研究公司,是 Claude 的创建者。本页涵盖了 Anthropic 模型和 LangChain 之间的所有集成。

安装和设置

要使用 Anthropic 模型,您需要安装一个 python 包

pip install -U langchain-anthropic

您需要设置 ANTHROPIC_API_KEY 环境变量。您可以在此处获取 Anthropic API 密钥

聊天模型

ChatAnthropic

请参阅使用示例

from langchain_anthropic import ChatAnthropic

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

LLMs

[旧版] AnthropicLLM

注意AnthropicLLM 仅支持旧版 Claude 2 模型。要使用最新的 Claude 3 模型,请改用 ChatAnthropic

请参阅使用示例

from langchain_anthropic import AnthropicLLM

model = AnthropicLLM(model='claude-2.1')
API 参考:AnthropicLLM

此页是否对您有帮助?