Documentation
¶
Overview ¶
Example: graph_with_llm — StateGraph with real LLM calls inside nodes.
What you'll learn:
- How to wire a real LLM provider (OpenAI, Anthropic, Gemini, Ollama) into graph nodes
- Building a multi-step workflow where each node calls the LLM for reasoning
- Conditional routing based on LLM classification output
- Using tools inside graph nodes for grounded agent behavior
- Checkpointing and resume with SQLite persistence
Prerequisites:
- Go 1.22+
- At least one LLM API key (or Ollama running locally)
Environment variables (set ONE of these):
OPENAI_API_KEY=sk-... → uses GPT-4o ANTHROPIC_API_KEY=sk-ant-... → uses Claude Sonnet 4 GEMINI_API_KEY=AIza... → uses Gemini 2.0 Flash (none) → uses Ollama at localhost:11434
Run:
export OPENAI_API_KEY=sk-your-key go run ./examples/graph_with_llm/
YAML equivalent (same behavior, no Go code):
See examples/yaml-configs/graph-agent.yaml CHRONOS_CONFIG=examples/yaml-configs/graph-agent.yaml go run ./cli/main.go run "Explain goroutines"
Click to show internal directories.
Click to hide internal directories.