> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inceptionlabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain

> Call Mercury 2 from LangChain.

## Setup Instructions

<Steps>
  <Step title="Install langchain-openai">
    Mercury is OpenAI-compatible, so LangChain talks to it through the `langchain-openai` package.

    ```bash theme={null}
    pip install -qU langchain-openai
    ```
  </Step>

  <Step title="Set your API key">
    Export your API key as an environment variable in your terminal.

    <CodeGroup>
      ```bash macOS / Linux theme={null}
      export INCEPTION_API_KEY="your_api_key_here"
      ```

      ```powershell Windows (PowerShell) theme={null}
      $env:INCEPTION_API_KEY = "your_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Call Mercury 2">
    ```python theme={null}
    import os
    from langchain_openai import ChatOpenAI

    llm = ChatOpenAI(
        model="mercury-2",
        temperature=0.75,
        api_key=os.environ["INCEPTION_API_KEY"],
        base_url="https://api.inceptionlabs.ai/v1",
    )
    response = llm.invoke([("user", "What is a diffusion model?")]).content
    print(response)
    ```
  </Step>
</Steps>

[LangChain documentation](https://python.langchain.com/docs/introduction/)
