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
pip install -U langgraph langchain-together
Set your Together AI API key:
export TOGETHER_API_KEY=***
Example
In this simple example we augment an LLM with a calculator tool!
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
Next Steps
LangGraph - Together AI Notebook
Learn more about building agents using LangGraph with Together AI in our:
Updated 3 days ago