AgenticAPI¶
Agent-native web framework with harness engineering for Python.
AgenticAPI lets you build web applications where endpoints accept natural language intents, dynamically generate code via LLMs, and execute it in a sandboxed, policy-controlled environment. Think of it as FastAPI for agent-powered APIs — with safety guardrails built in.
from agenticapi import AgenticApp, AgentResponse, Intent
from agenticapi.runtime.context import AgentContext
app = AgenticApp(title="Hello Agent")
@app.agent_endpoint(name="greeter", autonomy_level="auto")
async def greeter(intent: Intent, context: AgentContext) -> AgentResponse:
return AgentResponse(
result={"message": f"Hello! You said: {intent.raw}"},
reasoning="Direct greeting response",
)
Highlights¶
- Intent-based endpoints — Natural language in, structured results out
- Typed intents — Schema-aware
Intent[T]parsing with validation and OpenAPI publication - Dynamic code generation — LLMs generate Python code on the fly
- Native function calling —
ToolCall+tool_choice+finish_reasonacross all four backends (Anthropic, OpenAI, Gemini, Mock) with automatic retry - Harness engineering — Policies, static analysis, sandbox, audit trails
- Persistent audit — In-memory for dev or
SqliteAuditRecorderfor production - Cost budgeting —
BudgetPolicyandPricingRegistryprimitives for LLM spend ceilings - Observability — OpenTelemetry spans, Prometheus metrics, W3C trace propagation — all graceful no-ops when unused
- Dependency injection — FastAPI-style
Depends()with generator-based teardown - Tool decorator —
@toolturns plain functions into registered tools with auto-generated JSON schemas - Multi-LLM — Anthropic Claude, OpenAI GPT, Google Gemini, or your own
- Authentication — API key, Bearer token, Basic auth — per-endpoint or app-wide
- Custom responses —
HTMLResult,PlainTextResult,FileResult, or any StarletteResponse - HTMX support —
HtmxHeadersauto-injection, partial page updates - File handling — Upload via multipart, download via
FileResult, streaming - MCP support — Expose endpoints as MCP tools for Claude Desktop, Cursor, etc.
- OpenAPI / Swagger / ReDoc — Auto-generated, like FastAPI
- Background tasks — Post-response processing via
AgentTasks - Approval workflows — Human-in-the-loop for sensitive operations
-
ASGI-native — Built on Starlette, runs on uvicorn
-
Multi-agent orchestration —
AgentMeshwith@mesh.role/@mesh.orchestrator, budget propagation, cycle detection - Agentic loop — Multi-turn ReAct pattern where the LLM autonomously calls tools and reasons to a final answer, all harness-governed
- Workflow engine — Declarative multi-step workflows with typed state, conditional branching, parallel execution, checkpoints
- Agent playground — Self-hosted debugger UI at
/_playgroundfor chatting with agents and inspecting execution traces - Trace inspector — Self-hosted trace inspection UI at
/_tracewith search, diff, cost analytics, and compliance export - Harness-governed MCP —
HarnessMCPServerexposes@toolfunctions as MCP tools with full policy enforcement, audit, and budget tracking - Multi-turn tool conversations —
LLMMessagecarriestool_call_idandtool_callsfor provider-native multi-turn format translation across Anthropic, OpenAI, and Gemini - Project scaffolding —
agenticapi initgenerates a ready-to-run project with tools, harness, and eval set
Current scale: 141 Python modules, ~26,725 lines of code, 1,507 tests (+38 in extensions), 32 examples, 1 extension.
For the full shipped / active / deferred / superseded status matrix see ROADMAP.md at the repo root. For speculative forward tracks (Agent Mesh, Hardened Trust, Self-Improving Flywheel) see VISION.md at the repo root.
Quick Links¶
Getting started
- Installation
- Quick Start
- Examples — 32 runnable apps from hello-world to agentic workflows
Core guides
- Architecture
- Intent System / Typed Intents
- Dependency Injection
- Harness & Safety / Security Model
- Cost Budgeting
- Observability
- Authentication
- File Handling / HTMX Support
- LLM Backends / Tools / Tool Decorator
- Streaming / Agent Memory
- Eval Harness / Safety Policies
- Approval Workflows / Sessions
- Agent Mesh / REST Compatibility / Agent-to-Agent
- Ops Agents
- OpenAPI & Swagger
- Testing
For contributors
- Internals → Current State
- Internals → Module Reference
- Internals → Extending the Framework
- Internals → Extensions Architecture
- Internals → Contributing
Reference
- API Reference — every public class and function
- GitHub Repository