Skip to main content
AgentOS is built on FastAPI, which means you can integrate your existing FastAPI application, routes, middleware, dependencies, and deployment entrypoints with AgentOS.
app.py
The returned app serves both routes:

Handle Route Conflicts

Set on_route_conflict when the base application already defines a path and method used by AgentOS. "preserve_agentos" is the default.
See Override Routes for conflict examples and matching behavior.

Keep Existing Application Behavior

AgentOS prepares the supplied FastAPI app in place: Use AgentOS authorization for runtime access control. Keep product-specific FastAPI dependencies on the custom routes that need them.

Add Middleware

Add FastAPI or Starlette middleware to the base app before calling get_app():
See AgentOS Middleware for JWT validation, request context, logging, and custom middleware.

Combine Lifespans

Pass a lifespan to AgentOS when the runtime needs its own startup and shutdown work. AgentOS wraps the lifespan already configured on the base app.
See Custom Lifespan for a complete example.

Run the Combined App

Install the AgentOS and FastAPI CLI dependencies:

Next Steps