AgentsAgentBase

get_app

View as MarkdownOpen in Claude

Get the fully initialized FastAPI application instance. If the app has not been created yet, this method initializes it with all routes, middleware, health checks, and security headers — the same configuration that serve() would create.

This is primarily used with deployment adapters like Mangum (AWS Lambda) or when embedding the agent in a larger FastAPI application.

To add routers or static files to the agent’s own app, use mount() rather than get_app().include_router(...). Routes added by hand land behind the agent’s catch-all route and never run.

Parameters

None.

Returns

FastAPI — The configured FastAPI application instance with all agent endpoints registered.

Examples

AWS Lambda with Mangum

from mangum import Mangum
from signalwire import AgentBase
agent = AgentBase(name="lambda-agent")
agent.set_prompt_text("You are a helpful assistant.")
app = agent.get_app()
handler = Mangum(app)

Embed in existing FastAPI app

from fastapi import FastAPI
from signalwire import AgentBase
main_app = FastAPI()
agent = AgentBase(name="assistant", route="/agent")
main_app.mount("/ai", agent.get_app())