The LLMNode is the "brain" of your agent. It is a resilient, state-aware node that calls a generative AI model (like Google's Gemini) to perform a reasoning task.
It automatically formats your prompt with data from the GraphState and writes the model's text output back to the state.
Key Features
Resilient: Automatically retries on 429 (rate-limit) errors with exponential backoff.
Cost Auditing: Automatically logs prompt_tokens, output_tokens, and total_tokens to the run_metadata in the history log.
Stateful: Uses Python's format() string method to dynamically populate your prompt with any value from the GraphState.
Example Usage
# The LLMNode reads `task` from the state
planner_node = LLMNode(
model_name="gemini/gemini-2.5-pro",
prompt_template="You are a planner. Your task is: {task}",
output_key="plan", # Saves the result to state["plan"]
next_node=...
)
__init__ Parameters
Parameter
Type
Required
Description
model_name
str
Yes
The name of the model (e.g., "gemini-2.5-pro").
prompt_template
str
Yes
An f-string compatible template. Keys in {braces} will be filled from the GraphState.
output_key
str
Yes
The key to save the LLM's text response to in the GraphState (e.g., "draft_answer").
next_node
BaseNode
Yes
The next node to run after this one successfully completes.
max_retries
int
No
The number of times to retry on a 429 error. Default: 3.
1---2name: 2697-llmnode-5292fdfb3description: API Reference: `LLMNode`4---567# API Reference: `LLMNode`89The `LLMNode` is the "brain" of your agent. It is a resilient, state-aware node that calls a generative AI model (like Google's Gemini) to perform a reasoning task.1011It automatically formats your prompt with data from the `GraphState` and writes the model's text output back to the state.1213## Key Features1415- Resilient: Automatically retries on `429` (rate-limit) errors with exponential backoff.1617- Cost Auditing: Automatically logs `prompt_tokens`, `output_tokens`, and `total_tokens` to the `run_metadata` in the history log.1819- Stateful: Uses Python's `format()` string method to dynamically populate your prompt with any value from the `GraphState`.2021## Example Usage2223```python24# The LLMNode reads `task` from the state25planner_node = LLMNode(26 model_name="gemini/gemini-2.5-pro",27 prompt_template="You are a planner. Your task is: {task}",28 output_key="plan", # Saves the result to state["plan"]29 next_node=...30)31```32`__init__` Parameters3334| Parameter | Type | Required | Description|35|-----------|------|----|---------------|36| `model_name` | `str` | Yes | The name of the model (e.g., `"gemini-2.5-pro"`). |37| `prompt_template` | `str` | Yes | An f-string compatible template. Keys in `{braces}` will be filled from the GraphState. |38| `output_key` | `str` | Yes | The key to save the LLM's text response to in the `GraphState` (e.g., `"draft_answer"`). |39| `next_node` | `BaseNode`| Yes | The next node to run after this one successfully completes. |40| `max_retries` | `int` | No | The number of times to retry on a 429 error. Default: 3. |
Run npx skillmds@latest add tools-only/2697-llmnode-5292fdfb in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
API Reference: `LLMNode` It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tools-only (@tools-only) published this skill. Their other Agent Skills are listed on their SkillMD profile.