Choosing Models per Node
Big and small.
Every node can use a different model. That's a big advantage of graphs. Use a small, fast, cheap model where the job is easy, and save a larger model for the hard steps.

- A model per node
- Small for easy jobs
- Large for hard steps
Two models, two jobs
A small model, with structured output, classifies the message. That's an easy job. A second model writes the reply. In this demo both are Gemini flash lite, but in a real app, you'd point the writer at a larger model, by changing one string. Run it. The classifier picks the topic, and the writer replies.
from typing import Literal
from pydantic import BaseModel
from langchain.chat_models import init_chat_model
SMALL = "google_genai:gemini-flash-lite-latest" # fast and cheap
LARGE = "google_genai:gemini-flash-lite-latest" # swap in a bigger model here
class Topic(BaseModel):
topic: Literal["books", "orders", "other"]
classifier = init_chat_model(SMALL, temperature=0).with_structured_output(Topic)
writer = init_chat_model(LARGE, temperature=0)
message = "Can you suggest a gripping fantasy series for a long holiday?"
print("topic:", classifier.invoke(message).topic)
print("reply:", writer.invoke(f"One sentence reply: {message}").text.strip())topic: books reply: Lose yourself in Brandon Sanderson's *Stormlight Archive*, a massive, epic fantasy series filled with intricate world-building, high stakes, and unforgettable characters that will easily consume your entire holiday.
Which model where
Routing, grading, and extraction suit small models. Most agent steps, and RAG answers, suit mid sized models. Planning, tricky reasoning, and critiques of important work suit the largest. Test each choice with your test set.
| Node job | Model |
|---|---|
| Route, grade, extract | small |
| Agent steps, RAG answers | mid |
| Plan, reason, critique | large |
| Always | test with your test set |
Summary
Give each node the smallest model that does its job well. Graphs make mixing models easy. Next, the advanced quiz.
Key takeaways- Small for routing
- Large for reasoning
- Test each choice