agentroute (Python SDK)
Build, deploy, and monetize AI agents. Phase 2 ships Agent with tools,
persistent memory, conversation-history policies, and structured output —
all against any OpenAI-compatible model (OpenRouter default, plus Ollama
and custom HTTP endpoints).
Install
pip install agentroute
Quick start
Layer 0 — three-line hello world
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) to an OpenRouter key.
One key works for every model string (claude-sonnet-4, gpt-4o,
gemini-2.0-flash, deepseek-v3, ...).
Layer 1 — add a tool
from agentroute import Agent
agent = Agent("weather-bot", model="claude-sonnet-4")
@agent.tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return "Sunny, 22C"
print(agent.run("What's the weather in Zurich?"))
Memory (conversation + facts)
from agentroute import Agent, Memory, MemorySQLite
# In-RAM (lost on restart):
agent = Agent("bot", model="claude-sonnet-4", memory=Memory())
# Persistent (SQLite + FTS5 search):
agent = Agent("bot", model="claude-sonnet-4", memory=MemorySQLite("agent.db"))
agent.run("remember my favorite color is blue")
agent.run("what is my favorite color?") # remembers across runs
History policies
from agentroute import Agent, MemorySQLite, HistorySlidingWindow
agent = Agent(
"bot",
model="claude-sonnet-4",
memory=MemorySQLite("agent.db"),
history=HistorySlidingWindow(20), # keep last 20 user-turn groups
)
Also available: HistoryTruncate(max_tokens=100_000) and
HistorySummarize(model=...).
Structured output
from agentroute import Agent, Retry
from pydantic import BaseModel
class WeatherReport(BaseModel):
city: str
temp_c: float
agent = Agent("bot", model="claude-sonnet-4", output=WeatherReport)
@agent.output_validator
def sanity(ctx, output: WeatherReport) -> WeatherReport:
if output.temp_c > 60:
raise Retry("Temperature unrealistic, reconsider.")
return output
result = agent.run("Weather in Zurich?")
print(result.output.city, result.output.temp_c)
Async
import asyncio
from agentroute import Agent
async def main() -> None:
agent = Agent("bot", model="claude-sonnet-4")
result = await agent.arun("hi")
print(result.output)
asyncio.run(main())
Local models (Ollama)
agent = Agent("local", model="ollama/llama3")
print(agent.run("hi"))
Development
cd packages/python
pip install -e '.[dev]'
pytest # unit tests (integration tests auto-skipped)
pytest -m integration # integration tests (mocked + live)
ruff check src tests
mypy src/agentroute
Phase 2 scope: Agent, Tool, Context, Result, Event, ModelCloud,
resolve_model(), Config, exceptions (ErrorAgent, ErrorMaxTurns,
ErrorBudget, Retry), Memory, MemorySQLite, HistorySlidingWindow,
HistorySummarize, HistoryTruncate, structured output with validators.
Multi-agent (Team/Company), guards, MCP, A2A, and deployment land in later phases.
Metadata
Release files for agentroute 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentroute-1.1.0.tar.gz | 29.4 kB | Without provenance | Details for agentroute-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentroute-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for agentroute-1.1.0-py3-none-any.whl |
Total release size: 52.9 kB
Release files / agentroute-1.1.0.tar.gz
| Download URL | agentroute-1.1.0.tar.gz |
|---|---|
| Size | 29.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da014e549bba1131e790ebe87f0ace16fcc071654821c3cd9fff7bf3670ab3ec
|
|
BLAKE2b-256 checksum How to use checksums |
097566bfee6020cc7f422bd8438e1e75237d4c31904a670e82109cf227a1b135
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / agentroute-1.1.0-py3-none-any.whl
| Download URL | agentroute-1.1.0-py3-none-any.whl |
|---|---|
| Size | 23.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03d8e5dc4595b66d0d2e2f6fbc67f511863c7414fb95f5087f15b32f28b738b3
|
|
BLAKE2b-256 checksum How to use checksums |
d506817be93360691ca84f05b6dfac0af032be38f429094c06fcfebbc5358079
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for agentroute 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.