Introduction
What the AgentRoute SDK is and how its layered API works.
What is AgentRoute?
AgentRoute is a Python SDK for building, running, and shipping AI agents. You write agent logic with plain Python functions, run it against any OpenAI-compatible model, and layer in tools, persistent memory, conversation history compaction, and structured output as your agent grows.
The API is designed to be progressive — the simplest program is three lines, and every capability is opt-in from there.
from agentroute import Agent
agent = Agent("my-bot", model="claude-sonnet-4")
print(agent.run("Tell me a joke"))Set AGENTROUTE_API_KEY (or OPENROUTER_API_KEY) and the same code works for
claude-sonnet-4, gpt-4o, gemini-2.0-flash, deepseek-v3, and more — one
key, every model.
The layered API
- Layer 0 — talk to a model. Construct an
Agent, callagent.run(...). - Layer 1 — add tools. Decorate a function with
@agent.tooland the model can call it. - Memory & history. Persist conversation and facts, and compact long transcripts to fit the context window.
- Structured output. Ask for a typed Pydantic model back instead of text, with validators that can request a retry.
Start with the Quickstart, then dig into the Concepts and the SDK reference.