Using LangGraph with Together AI
pip install -U langgraph langchain-together
export TOGETHER_API_KEY=***
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
Was this page helpful?