SDK reference
The complete AgentRoute Python SDK surface — every public class, function, and exception, organized by module.
The AgentRoute SDK is one import away. Everything you need to build, run, and reason about an agent lives under the top-level agentroute package, so you can pull symbols straight from the namespace:
from agentroute import Agent, tool, Context, Memory, ResultThis is the reference for the public API as of __version__ == "1.1.0". Each page below documents one module of the SDK with exact signatures, defaults, return types, and runnable examples. If you are new here, start with the Agent page, or read the concepts guide for the bigger picture before diving into signatures.
Reference pages
The agentic loop. Construct an agent, register tools, run it, and get a Result back.
The @tool decorator and the Tool dataclass. Turn any Python function into a model-callable tool.
The per-run Context injected into tools, and the Usage accumulator for tokens and cost.
In-RAM Memory and persistent MemorySQLite, plus the MemoryProto protocol they implement.
Conversation compaction policies: sliding window, truncation, and LLM summarization.
The Model protocol, OpenAI-compatible message types, and resolve_model for any provider string.
The Result your run returns, plus Event for streaming and ResultDeploy for deployment.
The error hierarchy — ErrorAgent, ErrorMaxTurns, ErrorBudget — and the Retry control signal.
Every export, by page
The agentroute package exports 24 public symbols. Here is each one and the reference page that documents it.
| Symbol | Kind | Documented on |
|---|---|---|
Agent | class | Agent |
tool | function | Tools |
Tool | dataclass | Tools |
Context | dataclass | Context & Usage |
Usage | dataclass | Context & Usage |
Memory | class | Memory |
MemorySQLite | class | Memory |
History | protocol | History |
HistorySlidingWindow | class | History |
HistoryTruncate | class | History |
HistorySummarize | class | History |
Model | protocol | Models |
resolve_model | function | Models |
Message | dataclass | Models |
LLMRequest | dataclass | Models |
LLMResponse | dataclass | Models |
Result | dataclass | Results |
Event | dataclass | Results |
ResultDeploy | dataclass | Results |
ErrorAgent | exception | Exceptions |
ErrorMaxTurns | exception | Exceptions |
ErrorBudget | exception | Exceptions |
Retry | exception | Exceptions |
Every symbol in the table is re-exported from the package root, so from agentroute import Agent, MemorySQLite, ErrorMaxTurns always works. You never need to reach into submodules like agentroute.memory.history.
A complete example
Here is a minimal agent that wires together symbols from several pages — a tool, structured output, and a typed Result:
from agentroute import Agent
from pydantic import BaseModel
class Weather(BaseModel):
city: str
summary: str
agent = Agent(name="forecaster", model="claude-sonnet-4", output=Weather)
@agent.tool
def get_temp(city: str) -> int:
"""Return the current temperature in Celsius for a city."""
return 21
result = agent.run("What's the weather in Berlin?")
print(result.output.summary) # -> a Weather instance
print(result.usage.total_cost_usd) # -> accumulated cost for the runFrom here, pick a page above to see the full surface of each module.
Source: agentroute/init.py