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

# LangGraph

> Use LangGraph with Together AI to build agent workflows.

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

```shell Python theme={null}
  uv add langgraph langchain-together
```

```shell TypeScript theme={null}
  pnpm add @langchain/langgraph @langchain/core  @langchain/community
```

Set your Together API key:

```shell Shell theme={null}
export TOGETHER_API_KEY=***
```

## Example

In this example you augment an LLM with a calculator tool!

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

llm = ChatTogether(
    model="meta-models/Muse-Glimmer-30B",
    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
```

```typescript TypeScript theme={null}
import { ChatTogetherAI } from "@langchain/community/chat_models/togetherai";

const llm = new ChatTogetherAI({
    model: "meta-models/Muse-Glimmer-30B",
    apiKey: process.env.TOGETHER_API_KEY,
});

// Define a tool
const multiply = {
    name: "multiply",
    description: "Multiply two numbers",
    schema: {
        type: "function",
        function: {
            name: "multiply",
            description: "Multiply two numbers",
            parameters: {
                type: "object",
                properties: {
                    a: { type: "number" },
                    b: { type: "number" },
                },
                required: ["a", "b"],
            },
        },
    },
};

// Augment the LLM with tools
const llmWithTools = llm.bindTools([multiply]);

// Invoke the LLM with input that triggers the tool call
const msg = await llmWithTools.invoke("What is 2 times 3?");

// Get the tool call
console.log(msg.tool_calls);
```

## Next steps

> [!NOTE]
>
> ### LangGraph - Together AI notebook
>
> Learn more about building agents using LangGraph with Together AI in these notebooks:
>
> * [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).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.