router
Return an APIRouter exposing this gateway, ready to hand to include_router. It serves POST /
for the four browser methods and OPTIONS / for the CORS preflight.
The router returns chat bodies with StreamingResponse; the public endpoint may already have
buffered the response it received from the AI chat service. A newly minted handle is returned in
the X-Chat-Handle header.
Parameters
None.
Returns
fastapi.APIRouter.
Example
Mount it on an app you already run:
An agent already serves a FastAPI app, so it can host the gateway too. Use
mount(), which keeps the new routes ahead of the agent’s catch-all:
To let the widget move a conversation to a phone call and back, mount a
HandoffRouter at the same prefix.