Serverless Deployment
Serverless overview
Language support for serverless:
| TypeScript | Yes (Node.js runtime) | Yes (Node.js runtime) | Yes (Node.js runtime) |
Benefits:
- Auto-scaling
- Pay per invocation
- No server management
- High availability
AWS Lambda
Lambda handler
Python
TypeScript
handler.py:
Lambda requirements.txt (Python)
Lambda with API Gateway (Serverless Framework)
Lambda request flow

Google Cloud Functions
Cloud Functions handler
Python
TypeScript
main.py:
Cloud Functions requirements.txt (Python)
Deploying to Cloud Functions (Gen 2)
Azure Functions
Azure Functions handler
Python
TypeScript
function_app/__init__.py:
Azure Functions requirements.txt (Python)
function.json
host.json
Testing serverless
Local testing with swaig-test
Testing deployed endpoints
Authentication
The SDK automatically enables HTTP Basic Authentication. You can:
- Let the SDK generate credentials - Secure random credentials are created automatically
- Set your own credentials - Via environment variables:
Force mode override
For testing, you can force a specific execution mode:
Serverless best practices
Cold starts
- Keep dependencies minimal
- Initialize agent outside handler function
- Use provisioned concurrency for low latency
Timeouts
- Set appropriate timeout (Lambda: up to 15 min)
- Account for external API calls
- Monitor and optimize slow functions
Memory
- Allocate sufficient memory
- More memory = more CPU in Lambda
- Monitor memory usage
State
- Design for statelessness
- Use external storage for persistent data
- Don’t rely on local filesystem
Multi-agent serverless
Deploy multiple agents with AgentServer:
Environment detection
The SDK detects serverless environments automatically: