Skip to main content
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
{
  "mcpServers": {
    "respan-docs": {
      "url": "https://respan.ai/docs/mcp"
    }
  }
}

What is LangGraph?

LangGraph is a Python framework for building stateful, multi-step agent workflows as graphs. Nodes represent operations (LLM calls, tools, routing), and edges define the flow between them.

Setup

1

Install packages

pip install langgraph langchain-anthropic respan-tracing
2

Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
export ANTHROPIC_API_KEY="YOUR_ANTHROPIC_API_KEY"
3

Initialize Respan and build a graph

from respan_tracing import RespanTelemetry, workflow, task
from langgraph.graph import StateGraph, START, END
from langchain_anthropic import ChatAnthropic
from typing import TypedDict

# Initialize Respan — auto-instruments LangChain/Anthropic calls
telemetry = RespanTelemetry()

llm = ChatAnthropic(model="claude-sonnet-4-5-20250929")

class State(TypedDict):
    topic: str
    joke: str

@task(name="generate_joke")
def generate_joke(state: State) -> dict:
    response = llm.invoke(f"Tell me a joke about {state['topic']}")
    return {"joke": response.content}

@task(name="review_joke")
def review_joke(state: State) -> dict:
    response = llm.invoke(f"Rate this joke: {state['joke']}")
    return {"review": response.content}

# Build graph
graph = StateGraph(State)
graph.add_node("generate", generate_joke)
graph.add_node("review", review_joke)
graph.add_edge(START, "generate")
graph.add_edge("generate", "review")
graph.add_edge("review", END)

app = graph.compile()

@workflow(name="joke_graph")
def run_graph():
    return app.invoke({"topic": "AI tracing"})

result = run_graph()
print(result)
4

View your trace

Open the Traces page to see the graph execution.

Configuration

LangGraph uses the respan-tracing SDK for instrumentation. Instruments.LANGCHAIN auto-captures LangChain operations. See the Python Tracing SDK reference for configuration options.