> ## Documentation Index
> Fetch the complete documentation index at: https://thethirdpenco-feat-tool-lifecycle-events.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Serverless Agents

> Deploy agents to AWS Lambda, Vercel, and other platforms

Deploying agents to serverless platforms is easy with `ai-query`.

For deep dives into architecture and adapters, see the [Deployment Guide](/how-to/deployment).

## AWS Lambda

Use the `handle_lambda` adapter.

```python theme={null}
# lambda_function.py
from ai_query.adapters.aws import handle_lambda
from my_agent import SupportAgent

def handler(event, context):
    agent_id = event.get("pathParameters", {}).get("agent_id", "default")
    return handle_lambda(SupportAgent(agent_id), event, context)
```

## Vercel / Next.js

Use the `handle_vercel` adapter with the standard Python runtime.

```python theme={null}
# api/agent/[agent_id].py
from http.server import BaseHTTPRequestHandler
from ai_query.adapters.vercel import handle_vercel
from my_agent import SupportAgent

class handler(BaseHTTPRequestHandler):
    def do_POST(self):
        agent_id = self.path.split("/")[-1]
        handle_vercel(SupportAgent(agent_id), self)
```

## Consuming

You can consume these agents from any Python client using `connect()`:

```python theme={null}
from ai_query import connect

agent = connect("https://my-lambda-url.com/agent/user-1")
response = await agent.chat("Hello!")
```
