> For the complete documentation index, see [llms.txt](/llms.txt).
> A full single-fetch corpus is available at [llms-full.txt](/llms-full.txt).
---
title: Add AGNT5 to FastAPI
description: Mount AGNT5 serverless workflows in an existing FastAPI application and sync its deployed release.
last_verified: 2026-07-20
---

The Python ASGI adapter adds AGNT5 manifest and invoke routes without taking over your existing FastAPI application. AGNT5 calls those routes instead of maintaining a persistent worker connection.

## 1. Mount the adapter

Install the Python beta and mount the generated adapter:

```bash
uv add 'agnt5==0.9.0' fastapi 'uvicorn[standard]'
agnt5 serverless init --provider fastapi --name orders-api
```

The generated module follows this pattern:

```python
import os
from fastapi import FastAPI
from agnt5 import workflow
from agnt5.serverless import serve

app = FastAPI()

@workflow
async def hello(ctx, name: str = "world") -> dict[str, str]:
    return {"message": f"hello {name}"}

agnt5_serverless = serve(
    service_name="orders-api",
    service_version=os.getenv("GIT_SHA", "local"),
    signing_secret=lambda: os.getenv("AGNT5_SERVERLESS_SIGNING_SECRET"),
)
agnt5_serverless.mount_fastapi(app)
```

## 2. Validate locally

```bash
export AGNT5_SERVERLESS_SIGNING_SECRET="$(openssl rand -base64 32)"
uv run uvicorn app:app --host 127.0.0.1 --port 8787
agnt5 serverless validate http://127.0.0.1:8787
```

Run validation from a second terminal while Uvicorn remains active.

## 3. Deploy and sync

Deploy the ASGI service to an HTTPS host and configure the same signing secret there. Import the immutable release without activating it:

```bash
agnt5 serverless sync https://<fastapi-host> \
  --provider node \
  --immutable-ref <git-sha-or-release-id> \
  --signing-secret-env AGNT5_SERVERLESS_SIGNING_SECRET \
  --activate=false
```

The beta uses the provider label `node` for generic HTTP hosts, including Python ASGI. Verify the deployment before repeating sync with `--activate=true`.

## Next steps

- [Serverless SDK reference](/docs/run/serverless-sdk-reference.md): use Python durable steps, timers, user input, and events.
- [Operate serverless endpoints](/docs/run/operate-serverless-endpoints.md): promote and recover releases safely.
- [Serverless CLI reference](/cli/serverless.md): inspect sync and validation flags.
