DEV Community

Cover image for How to Build an Anime Filter App with Python and an API
AI Engine
AI Engine

Posted on • Originally published at ai-engine.net

How to Build an Anime Filter App with Python and an API

Anime and cartoon filters have taken over social media. The Ghibli-style filter alone generated millions of posts on Instagram and TikTok in 2026. If you want to add this feature to your own app, you can call a Photo to Anime API that handles everything server-side. No GPU, no TensorFlow, no model downloads.

What You Get

One endpoint, seven styles: Anime, 3D, Hand-drawn, Sketch, Art Style, Design, and Illustration. Send a photo, pick a style, get back a stylized version in 2 to 3 seconds.

Python Example

import requests

API_URL = "https://phototoanime1.p.rapidapi.com/cartoonize"
HEADERS = {
    "x-rapidapi-host": "phototoanime1.p.rapidapi.com",
    "x-rapidapi-key": "YOUR_API_KEY",
}

with open("photo.jpg", "rb") as f:
    response = requests.post(
        API_URL,
        headers=HEADERS,
        files={"image": f},
        data={"style": "anime"},
    )

result = response.json()
print(result["image_url"])
Enter fullscreen mode Exit fullscreen mode

The response:

{
  "image_url": "https://images.ai-engine.net/photo-to-anime-ai/uuid.jpg",
  "width": 1280,
  "height": 960,
  "size_bytes": 245678
}
Enter fullscreen mode Exit fullscreen mode

Generate All 7 Styles

from pathlib import Path

STYLES = ["anime", "3d", "handdrawn", "sketch", "artstyle", "design", "illustration"]

def cartoonize(image_path, style, output_dir="output"):
    Path(output_dir).mkdir(exist_ok=True)
    with open(image_path, "rb") as f:
        response = requests.post(
            API_URL, headers=HEADERS,
            files={"image": f}, data={"style": style},
        )
    url = response.json()["image_url"]
    img = requests.get(url).content
    out = f"{output_dir}/{style}.jpg"
    Path(out).write_bytes(img)
    return out

for style in STYLES:
    print(f"{style}: {cartoonize('photo.jpg', style)}")
Enter fullscreen mode Exit fullscreen mode

Flask Web App

from flask import Flask, request, jsonify
import requests

app = Flask(__name__)

@app.route("/cartoonize", methods=["POST"])
def cartoonize():
    image = request.files.get("image")
    style = request.form.get("style", "anime")
    if not image:
        return jsonify({"error": "No image"}), 400

    response = requests.post(
        API_URL, headers=HEADERS,
        files={"image": (image.filename, image.stream, image.content_type)},
        data={"style": style},
    )
    return jsonify(response.json())
Enter fullscreen mode Exit fullscreen mode

Use Cases

  • Social media avatars: users upload a selfie, get an anime profile picture, share it
  • Gaming: generate character portraits from player photos during onboarding
  • Marketing: convert product photos to illustration style for eye-catching ads
  • Event apps: live cartoon filters at conferences and parties

API vs Local AnimeGAN

Photo to Anime API Local AnimeGAN
Setup 5 minutes 1+ hours
GPU Not needed Required
Styles 7 built-in 1 per model
Cost (10K/mo) $12.99 $50-200 (GPU server)

For most apps, the API is the practical choice. Local models make sense only for offline processing or custom model fine-tuning.

👉 Read the full tutorial with all 7 style demos and deployment guide

Top comments (0)