Input and Output Schemas
Public and private.
Inside a graph, the state often holds working data, like intermediate prices, or flags. Callers don't need to see all that. Input and output schemas say what goes in, and what comes out.

- Working data inside
- Callers need less
- Define what's in and out
A clean interface
The full state has the title, a working price, and a reply. The input schema accepts only the title. The output schema returns only the reply. We pass them to state graph. Run it. We send just a title, and get back just the reply. The working price stays private.
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
class In(TypedDict):
title: str
class Out(TypedDict):
reply: str
class State(In, Out):
price: float
def look_up(s): return {"price": {"Dune": 9.99}.get(s["title"], 0.0)}
def answer(s): return {"reply": f"{s['title']} costs £{s['price']}"}
b = StateGraph(State, input_schema=In, output_schema=Out)
b.add_sequence([look_up, answer]); b.add_edge(START, "look_up"); b.add_edge("answer", END)
print(b.compile().invoke({"title": "Dune"})){'reply': 'Dune costs £9.99'}Why schemas help
Schemas make a graph easy to use, like a function with clear arguments and a clear return value. They keep private data private. And they matter later, when one graph is used inside another, as a subgraph.
| key | value |
|---|---|
| Input schema | what callers send |
| Output schema | what they get |
| Private | working keys hidden |
| Later | subgraphs |
Summary
Input and output schemas define a graph's public interface, and hide its working data. Next, a quiz on branching.
Key takeaways- input_schema
- output_schema
- Private working keys