Skip to main content
`Ctrl`+`K`

# Anthropic

Anthropic is creator of the `Claude` LLM.

This example goes over how to use LangChain to interact with Anthropic models.

    # Install the package
    !pip install anthropic

    # get a new token: https://www.anthropic.com/earlyaccess

    from getpass import getpass

    ANTHROPIC_API_KEY = getpass()

    from langchain.llms import Anthropic
    from langchain import PromptTemplate, LLMChain

    template = """Question: {question}

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

    prompt = PromptTemplate(template=template, input_variables=["question"])

    llm = Anthropic(anthropic_api_key=ANTHROPIC_API_KEY)

    llm_chain = LLMChain(prompt=prompt, llm=llm)

    question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"

    llm_chain.run(question)

    " Step 1: Justin Beiber was born on March 1, 1994\nStep 2: The NFL season ends with the Super Bowl in January/February\nStep 3: Therefore, the Super Bowl that occurred closest to Justin Beiber's birth would be Super Bowl XXIX in 1995\nStep 4: The San Francisco 49ers won Super Bowl XXIX in 1995\n\nTherefore, the answer is the San Francisco 49ers won the Super Bowl in the year Justin Beiber was born."