Deploying Agents
How to deploy and share your AI agents with others
Deploy your agents as APIs, web apps, or serverless functions to share with others.
Deployment Options
Local Script
Run directly on your machine
Web APIFlask, FastAPI, or similar
ServerlessAWS Lambda, Cloud Functions
Built-in UIPraisonAI’s Chainlit interface
Quick Start: Built-in UI
The easiest way to deploy with a chat interface:
pip install praisonai
praisonai uiThis launches a Chainlit-based chat interface for your agents.
Web API with FastAPI
from fastapi import FastAPI
from praisonaiagents import Agent
app = FastAPI()
# Create agent once at startup
agent = Agent(
name="SupportBot",
instructions="You are a helpful support agent"
)
@app.post("/chat")
async def chat(query: str):
response = agent.start(query)
return {"response": response}
# Run with: uvicorn app:app --reloadWeb API with Flask
from flask import Flask, request, jsonify
from praisonaiagents import Agent
app = Flask(__name__)
agent = Agent(
name="SupportBot",
instructions="You are a helpful support agent"
)
@app.route("/chat", methods=["POST"])
def chat():
query = request.json.get("query", "")
response = agent.start(query)
return jsonify({"response": response})
# Run with: python app.py
if __name__ == "__main__":
app.run(port=5000)Serverless (AWS Lambda)
import json
from praisonaiagents import Agent
agent = Agent(
name="ServerlessAgent",
instructions="You are a helpful assistant"
)
def lambda_handler(event, context):
body = json.loads(event.get("body", "{}"))
query = body.get("query", "")
response = agent.start(query)
return {
"statusCode": 200,
"body": json.dumps({"response": response})
}Environment Variables
Always use environment variables for API keys:
export OPENAI_API_KEY=your_key_hereimport os
from praisonaiagents import Agent
# API key is automatically read from environment
agent = Agent(instructions="You are helpful")Scaling Considerations
Rate Limiting
Control API usage and costs
CachingCache common responses
Error HandlingHandle API failures gracefully
MonitoringTrack usage and performance
Best Practices
Test Before Deploying
Verify agent works correctly with various inputs
Use Environment Variables
Never hardcode API keys or secrets
Add Error Handling
Wrap agent calls in try/except blocks
Monitor Usage
Track API calls and costs
Course Complete! 🎉
You’ve learned how to:
- ✅ Create AI agents with instructions
- ✅ Add tools for extended capabilities
- ✅ Enable memory for conversations
- ✅ Add knowledge from documents
- ✅ Build multi-agent teams
- ✅ Create specialized agents
- ✅ Deploy agents for real use