---
title: AnthropicLLM
---


<Warning>
**현재 Anthropic의 레거시 Claude 2 모델을 text completion 모델로 사용하는 방법을 설명하는 페이지를 보고 계십니다. 최신이자 가장 인기 있는 Anthropic 모델은 [chat completion 모델](/oss/python/langchain/models)이며, text completion 모델은 더 이상 사용되지 않습니다.**

아마도 [이 페이지](/oss/python/integrations/chat/anthropic/)를 찾고 계실 것입니다.
</Warning>

이 예제는 LangChain을 사용하여 `Anthropic` 모델과 상호작용하는 방법을 다룹니다.

## Installation

```python
pip install -qU langchain-anthropic

Environment Setup

Anthropic API key를 발급받고 ANTHROPIC_API_KEY environment variable을 설정해야 합니다:
import os
from getpass import getpass

if "ANTHROPIC_API_KEY" not in os.environ:
    os.environ["ANTHROPIC_API_KEY"] = getpass()

Usage

from langchain_anthropic import AnthropicLLM
from langchain_core.prompts import PromptTemplate

template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate.from_template(template)

model = AnthropicLLM(model="claude-2.1")

chain = prompt | model

chain.invoke({"question": "What is LangChain?"})
'\nLangChain is a decentralized blockchain network that leverages AI and machine learning to provide language translation services.'

---

<Callout icon="pen-to-square" iconType="regular">
    [Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/llms/anthropic.mdx)
</Callout>
<Tip icon="terminal" iconType="regular">
    [Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for    real-time answers.
</Tip>
I