***

title: serve
slug: /reference/python/agents/agent-base/serve
description: Start a FastAPI/uvicorn web server to serve this agent's SWML and SWAIG endpoints.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[run]: /docs/server-sdks/reference/python/agents/agent-base/run

Start a FastAPI web server powered by uvicorn to serve this agent. The server
exposes endpoints for SWML document delivery, SWAIG function execution,
post-prompt summary handling, and health checks.

This method blocks until the server is shut down (e.g., via SIGINT).

<Info>
  For most cases, use [`run()`][run]
  instead -- it auto-detects the environment and calls `serve()` in server mode or
  dispatches to the appropriate serverless handler.
</Info>

The server automatically includes:

* SWML document endpoint at the agent's route
* SWAIG function endpoints for each registered tool
* `/health` and `/ready` health check endpoints
* Security headers middleware
* SSL support when configured via environment variables

## **Parameters**

<ParamField path="host" type="Optional[str]" toc={true}>
  Host override. Defaults to the value set in the constructor.
</ParamField>

<ParamField path="port" type="Optional[int]" toc={true}>
  Port override. Defaults to the value set in the constructor.
</ParamField>

## **Returns**

`None` -- This method blocks and does not return until the server is stopped.

## **Example**

```python {5}
from signalwire import AgentBase

agent = AgentBase(name="my-agent", host="0.0.0.0", port=3000)
agent.set_prompt_text("You are a helpful assistant.")
agent.serve()  # Blocks here, serving at http://0.0.0.0:3000/
```