Learn how to use your own FastAPI app in your AgentOS
AgentOS is built on FastAPI, which means you can easily integrate your existing FastAPI applications or add custom routes and routers to extend your agent’s capabilities.
The simplest way to bring your own FastAPI app is to pass it to the AgentOS constructor:
Copy
Ask AI
from fastapi import FastAPIfrom agno.agent import Agentfrom agno.models.openai import OpenAIChatfrom agno.os import AgentOS# Create your custom FastAPI appapp = FastAPI(title="My Custom App")# Add your custom routes@app.get("/status")async def status_check(): return {"status": "healthy"}# Pass your app to AgentOSagent_os = AgentOS( agents=[Agent(id="basic-agent", model=OpenAIChat(id="gpt-5-mini"))], base_app=app # Your custom FastAPI app)# Get the combined app with both AgentOS and your routesapp = agent_os.get_app()
Your custom FastAPI app can have its own middleware and dependencies.If you have your own CORS middleware, it will be updated to include the AgentOS allowed origins, to make the AgentOS instance compatible with the Control Plane.
If not then the appropriate CORS middleware will be added to the app.
You can add any FastAPI middleware to your custom FastAPI app and it would be respected by AgentOS.Agno also provides some built-in middleware for common use cases, including authentication.See the Middleware page for more details.
You can programmatically access and inspect the routes added by AgentOS:
Copy
Ask AI
agent_os = AgentOS(agents=[agent])app = agent_os.get_app()# Get all routesroutes = agent_os.get_routes()for route in routes: print(f"Route: {route.path}") if hasattr(route, 'methods'): print(f"Methods: {route.methods}")