This tutorial uses the all-in-one API. See the docs, live demo, and pricing.
I wanted to build a photo editing SaaS. Background removal, face enhancement, anime filters, OCR, content moderation. Each feature normally requires its own ML model, its own GPU, its own API subscription.
Instead, I built the whole thing with one API, one Lambda function, and zero ML code. Twelve AI features, $15/month infrastructure cost, 16x margin on every request.

The 12 Features
Every feature is a single POST request to the same API host. Same key, same auth, same response format.
| Feature | Endpoint | Credits |
|---|---|---|
| Remove background | /v1/remove-background | 1 |
| Blur background | /v1/blur-background | 1 |
| Replace background (color/gradient) | /v1/color-background | 1 |
| Enhance faces | /v1/enhance-face | 1 |
| Anime/Ghibli filter | /v1/cartoonize | 1 |
| Colorize B&W photos | /v1/colorize-photo | 1 |
| Pencil sketch | /v1/photo-to-portrait | 1 |
| Face swap | /v1/swap-face | 1 |
| Extract text (OCR) | /v1/ocr | 2 |
| Detect objects | /v1/objects-detection | 2 |
| Face analysis (age, gender, emotion) | /v1/faceanalysis | 2 |
| NSFW check | /v1/nsfw-detect | 2 |
All endpoints are on ai-all-in-one.p.rapidapi.com. One host, one key, one subscription.
Architecture

No GPU on your side. No ML models. No Docker containers with TensorFlow. The Lambda function is a proxy that checks credits and forwards the request.
The Backend
The entire Lambda handler in one file:
import json
import boto3
import requests
API_HOST = "ai-all-in-one.p.rapidapi.com"
API_KEY = "YOUR_RAPIDAPI_KEY" # store in env vars / Secrets Manager
HEADERS = {"x-rapidapi-key": API_KEY, "x-rapidapi-host": API_HOST}
# Credits cost per action
COSTS = {
"remove-bg": (1, "/v1/remove-background"),
"blur-bg": (1, "/v1/blur-background"),
"enhance-face": (1, "/v1/enhance-face"),
"cartoonize": (1, "/v1/cartoonize"),
"colorize": (1, "/v1/colorize-photo"),
"portrait": (1, "/v1/photo-to-portrait"),
"face-swap": (1, "/v1/swap-face"),
"ocr": (2, "/v1/ocr"),
"detect-objects": (2, "/v1/objects-detection"),
"face-analysis": (2, "/v1/faceanalysis"),
"nsfw-check": (2, "/v1/nsfw-detect"),
}
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("user_credits")
def handler(event, context):
user_id = event["requestContext"]["authorizer"]["user_id"]
action = event["queryStringParameters"]["action"]
if action not in COSTS:
return {"statusCode": 400, "body": json.dumps({"error": "Unknown action"})}
cost, endpoint = COSTS[action]
# Check credits
user = table.get_item(Key={"user_id": user_id}).get("Item", {})
credits = user.get("credits", 0)
if credits < cost:
return {"statusCode": 402, "body": json.dumps({"error": "Not enough credits"})}
# Call AI API
body = json.loads(event["body"])
resp = requests.post(
f"https://{API_HOST}{endpoint}",
headers={**HEADERS, "Content-Type": "application/json"},
json=body,
)
# Decrement credits
table.update_item(
Key={"user_id": user_id},
UpdateExpression="SET credits = credits - :c",
ExpressionAttributeValues={":c": cost},
)
return {"statusCode": 200, "body": resp.text}That is the entire backend. Every AI feature goes through the same function. The action parameter selects the endpoint, the credits system handles billing.
Credits System
Each user gets a credits balance in DynamoDB. Simple key-value:
{
"user_id": "usr_abc123",
"credits": 450,
"plan": "pro"
}When a user calls an action, the Lambda checks their balance, calls the API, and decrements. Image features cost 1 credit. Analysis features (OCR, object detection, face analysis) cost 2.
For signups, insert a row with 10 free credits. For paid plans, a Stripe webhook increments the balance monthly.
The Money Math
This is where it gets interesting.
Your cost per request
| API Plan | Price | Credits | Cost/credit |
|---|---|---|---|
| Basic | $0 | 50/mo | Free |
| Pro | $14.99 | 10,000/mo | $0.0015 |
| Ultra | $49.99 | 50,000/mo | $0.001 |
| Mega | $149.99 | 200,000/mo | $0.00075 |
Your revenue per request
If you charge your users $0.02 per credit (or $9.99/month for 500 credits):
| Metric | Value |
|---|---|
| Your cost per credit (Pro plan) | $0.0015 |
| You charge per credit | $0.02 |
| Margin per credit | 13x |
Monthly projection
| Users | Requests/mo | API cost | Lambda cost | Revenue | Profit |
|---|---|---|---|---|---|
| 50 free | 500 | $0 (free tier) | ~$0.10 | $0 | -$0.10 |
| 10 paid | 5,000 | $14.99 | ~$0.50 | $99.90 | $84.41 |
| 100 paid | 50,000 | $49.99 | ~$5 | $999 | $944 |
Ten paying users and you are profitable. One hundred and you are making $944/month from a Lambda function and an API subscription.
How to Charge Your Users
The credits model makes pricing simple. Sell credits at $0.02 each ($9.99/month for 500 credits), give 10 free per day to attract signups. Every feature maps to a credit cost, so you never need to change your pricing when you add new features.
Why This Works
- One integration: 12 features from 1 API means 1 set of docs, 1 SDK, 1 billing dashboard
- No ML ops: no models to download, update, or host. The API handles GPU inference
- Scales to zero: Lambda + DynamoDB on-demand means you pay nothing when nobody is using it
- Ship fast: the backend is ~50 lines of Python. The hard part is the frontend, not the AI
Frequently Asked Questions
- Can I build a SaaS with just one AI API?
- Yes. The AI All-in-One API provides 36+ endpoints covering background removal, OCR, face analysis, object detection, style transfer, and more. You can build a multi-feature product with a single API key and a single subscription, instead of integrating 5+ separate services.
- How much does it cost to run an AI photo SaaS?
- With the All-in-One API at $14.99/month for 10,000 credits and AWS Lambda at roughly $0.50 for 5,000 invocations, a SaaS serving 1,000 users costs about $15.50/month in infrastructure. If you charge $9.99/month per user, even 10 paying users cover your costs.
- Do I need a GPU to run AI features in my SaaS?
- No. The AI processing runs on the API provider's GPU infrastructure. Your backend is a simple Lambda function that proxies requests. No GPU, no model downloads, no ML dependencies.



