as_router
as_router
Create a FastAPI APIRouter for this service. Use this to mount the service into an
existing FastAPI application rather than running a standalone server with
serve(). The router handles
both GET and POST requests at the root path and any registered routing callback paths.
Use as_router() for production deployments where you want to control the ASGI
application lifecycle, or when hosting multiple services on the same FastAPI instance
via AgentServer.
Returns
APIRouter — A FastAPI router with all endpoints registered.