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.

Parameters

None.

Returns

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

Examples

AWS Lambda with Mangum

1from mangum import Mangum
2from signalwire import AgentBase
3
4agent = AgentBase(name="lambda-agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7app = agent.get_app()
8handler = Mangum(app)

Embed in existing FastAPI app

1from fastapi import FastAPI
2from signalwire import AgentBase
3
4main_app = FastAPI()
5agent = AgentBase(name="assistant", route="/agent")
6
7main_app.mount("/ai", agent.get_app())