> ## Documentation Index
> Fetch the complete documentation index at: https://togetherai-migration.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LangGraph

> Using LangGraph with Together AI

LangGraph is an OSS library for building stateful, multi-actor applications with LLMs, specifically designed for agent and multi-agent workflows. The framework supports critical agent architecture features including persistent memory across conversations and human-in-the-loop capabilities through checkpointed states.

## Installing Libraries

<CodeGroup>
  ```shell Shell theme={null}
  pip install -U langgraph langchain-together
  ```
</CodeGroup>

Set your Together AI API key:

<CodeGroup>
  ```shell Shell theme={null}
  export TOGETHER_API_KEY=***
  ```
</CodeGroup>

## Example

In this simple example we augment an LLM with a calculator tool!

<CodeGroup>
  ```python Python theme={null}
  import os
  from langchain_together import ChatTogether

  llm = ChatTogether(model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
                     api_key=os.getenv("TOGETHER_API_KEY"))

  # Define a tool
  def multiply(a: int, b: int) -> int:
      return a * b

  # Augment the LLM with tools
  llm_with_tools = llm.bind_tools([multiply])

  # Invoke the LLM with input that triggers the tool call
  msg = llm_with_tools.invoke("What is 2 times 3?")

  # Get the tool call
  msg.tool_calls
  ```
</CodeGroup>

## Next Steps

<Info>
  ### LangGraph - Together AI Notebook

  Learn more about building agents using LangGraph with Together AI in our:

  * [Agentic RAG Notebook](https://github.com/togethercomputer/together-cookbook/blob/main/Agents/LangGraph/Agentic_RAG_LangGraph.ipynb)
  * [Planning Agent Notebook](https://github.com/togethercomputer/together-cookbook/blob/main/Agents/LangGraph/LangGraph_Planning_Agent.ipynb)
</Info>
