This tutorial uses the Photo to Anime API. See the docs, live demo, and pricing.
Anime and cartoon-style artwork has exploded in popularity across social media, gaming, and digital marketing. Creating it manually requires hours of skilled illustration work, but the Photo to Anime API transforms any photograph into a polished cartoon rendering in seconds, with 7 classic styles, a dedicated Studio Ghibli endpoint, and no GPU or model setup on your side.
This guide covers the whole workflow: your first call, the Ghibli filter, a script that generates every style from one photo, and a Flask endpoint you can drop into a web app.

7 Unique Cartoon Styles
The /cartoonize endpoint offers seven artistic styles through a single style parameter:
- anime: Japanese anime style with clean lines and vibrant colors
- 3d: smooth, Pixar-like 3D cartoon rendering
- handdrawn: organic, hand-drawn illustration feel
- sketch: monochrome pencil sketch with detailed lines
- artstyle: artistic painting with bold strokes and rich colors
- design: flat, modern graphic design aesthetic
- illustration: detailed, colorful digital illustration
The same API also exposes a premium endpoint, /cartoonize-pro, with six higher-quality portrait styles (cartoon, caricature, arcane, comic, pixar, illustration), sub-style variations through style_id, and an adjustable style_degree intensity from 0.0 to 1.0. The before-and-after cover above is the premium pixar style.
Getting Started
You need a free API key from the Photo to Anime API page (50 requests per month on the Basic plan) and, for Python, the requests library. The API accepts an image file or a public URL and returns JSON with a link to the processed JPEG.
cURL
# File upload with style
curl -X POST "https://phototoanime1.p.rapidapi.com/cartoonize" \
-H "x-rapidapi-key: YOUR_API_KEY" \
-H "x-rapidapi-host: phototoanime1.p.rapidapi.com" \
-F "image=@photo.jpg" \
-F "style=anime"
# JSON with image URL
curl -X POST "https://phototoanime1.p.rapidapi.com/cartoonize" \
-H "x-rapidapi-key: YOUR_API_KEY" \
-H "x-rapidapi-host: phototoanime1.p.rapidapi.com" \
-H "Content-Type: application/json" \
-d '{"image_url": "https://example.com/photo.jpg", "style": "3d"}'Python
import requests
API_URL = "https://phototoanime1.p.rapidapi.com/cartoonize"
HEADERS = {
"x-rapidapi-host": "phototoanime1.p.rapidapi.com",
"x-rapidapi-key": "YOUR_API_KEY",
}
# Option 1: Upload a file
with open("photo.jpg", "rb") as f:
response = requests.post(
API_URL,
headers=HEADERS,
files={"image": f},
data={"style": "anime"},
)
# Option 2: Pass an image URL
response = requests.post(
API_URL,
headers={**HEADERS, "Content-Type": "application/json"},
json={"image_url": "https://example.com/photo.jpg", "style": "3d"},
)
result = response.json()
print(result["image_url"]) # URL to the cartoon-styled JPEGJavaScript (Node.js)
const form = new FormData();
form.append("image", fileInput.files[0]);
form.append("style", "anime");
const response = await fetch(
"https://phototoanime1.p.rapidapi.com/cartoonize",
{
method: "POST",
headers: {
"x-rapidapi-host": "phototoanime1.p.rapidapi.com",
"x-rapidapi-key": "YOUR_API_KEY",
},
body: form,
}
);
const result = await response.json();
console.log(result.image_url); // URL to the cartoon-styled JPEGThe response contains the CDN URL of the processed image, plus dimensions and file size:
{
"image_url": "https://images.ai-engine.net/photo-to-anime-ai/uuid.jpg",
"width": 640,
"height": 960,
"size_bytes": 157251
}The URL is publicly accessible and expires after 24 hours, so download the image if you need to keep it.
Studio Ghibli Style (Dedicated Endpoint)
Beyond the 7 classic styles, the API ships a dedicated /ghibli endpoint that converts portraits and scenes into Studio Ghibli inspired artwork. It runs a separate model trained on the soft watercolor textures, painterly backgrounds, and warm palette that define the Ghibli look, plus a face enhancement pass so portraits keep their identity.

/ghibli endpoint.Most Ghibli filter tutorials tell you to install PyTorch, download a multi-gigabyte model, and fight with CUDA drivers. With the API it takes three lines:
import requests
response = requests.post(
"https://phototoanime1.p.rapidapi.com/ghibli",
headers={"x-rapidapi-key": "YOUR_API_KEY", "x-rapidapi-host": "phototoanime1.p.rapidapi.com"},
files={"image": open("my_photo.jpg", "rb")},
)
print(response.json()["image_url"])If the photo is already online, pass its URL as image_url instead of uploading a file, then download the result:
import requests
API_URL = "https://phototoanime1.p.rapidapi.com/ghibli"
HEADERS = {
"x-rapidapi-key": "YOUR_API_KEY",
"x-rapidapi-host": "phototoanime1.p.rapidapi.com",
}
response = requests.post(
API_URL,
headers={**HEADERS, "Content-Type": "application/json"},
json={"image_url": "https://example.com/my_photo.jpg"},
)
result = response.json()
with open("ghibli_output.jpg", "wb") as f:
f.write(requests.get(result["image_url"]).content)
print(f"Saved ghibli_output.jpg ({result['width']}x{result['height']})")Use the Ghibli endpoint when you want a more cinematic, illustrative result than the classic anime style. Typical uses: profile pictures for fan communities, couple and pet portraits, illustrated greeting cards, and personalized merchandise.
Build a Multi-Style Generator
Most anime filter apps let users compare several looks before picking one. This script sends one photo through all seven styles and saves each result:
import requests
from pathlib import Path
API_URL = "https://phototoanime1.p.rapidapi.com/cartoonize"
HEADERS = {
"x-rapidapi-host": "phototoanime1.p.rapidapi.com",
"x-rapidapi-key": "YOUR_API_KEY",
}
STYLES = ["anime", "3d", "handdrawn", "sketch", "artstyle", "design", "illustration"]
def cartoonize(image_path: str, style: str, output_dir: str = "output") -> str:
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},
)
image_url = response.json()["image_url"]
output_path = f"{output_dir}/{style}.jpg"
Path(output_path).write_bytes(requests.get(image_url).content)
return output_path
for style in STYLES:
print(f"{style}: saved to {cartoonize('photo.jpg', style)}")Each style counts as one request, so a full seven-style preview uses 7 of your monthly quota. For bulk jobs, run the calls in a thread pool: the API handles concurrent requests.
Add an Anime Filter to a Flask Web App
Most apps need a web endpoint, not a CLI script. This minimal Flask app accepts an image upload and a style, and returns the API response:
from flask import Flask, request, jsonify
import requests
app = Flask(__name__)
API_URL = "https://phototoanime1.p.rapidapi.com/cartoonize"
HEADERS = {
"x-rapidapi-host": "phototoanime1.p.rapidapi.com",
"x-rapidapi-key": "YOUR_API_KEY",
}
@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 provided"}), 400
response = requests.post(
API_URL,
headers=HEADERS,
files={"image": (image.filename, image.stream, image.content_type)},
data={"style": style},
)
return jsonify(response.json())
if __name__ == "__main__":
app.run(debug=True)Your frontend POSTs the photo to /cartoonize and shows the returned image_url. Keep the API key on the server, never in browser code.
API vs Local Model
The alternative is running AnimeGAN or a similar open-source model yourself. Here is how the two approaches compare:
| Criteria | Photo to Anime API | Local model |
|---|---|---|
| Setup | 5 minutes (get an API key, pip install requests) | 1+ hours (PyTorch, model weights, GPU drivers) |
| GPU required | No | Yes (or very slow CPU inference) |
| Styles | 7 classic + Ghibli + premium portrait styles | 1 per model (separate weights for each style) |
| Scaling | Handled by the API | You manage servers and GPU scaling |
| Cost | Free (50/month), then $12.99/month for 10K | Free software, but GPU hardware or rental |
Local models make sense when you need offline processing or want to fine-tune on a custom dataset. For a side-by-side test on the same portrait, see Photo to Anime API vs AnimeGAN.
Real-World Use Cases
1. Social Media Profile Generators
Let users upload a selfie and instantly receive an anime or Ghibli avatar. This is one of the most viral mechanics in consumer apps: users share before-and-after comparisons, and each share drives organic traffic back to your platform.
2. Marketing and Advertising Campaigns
Brands targeting younger audiences can turn product photography and campaign visuals into cartoon styles to stand out in crowded feeds. A fashion brand could render its seasonal lookbook in anime style, while a tech company might use the 3D style for a playful campaign.
3. Game and App Asset Creation
Game developers can generate character portraits from player photos during onboarding, or prototype character designs from reference photos. Pair this with AI image generation to create entirely new characters.
4. Personalized Merchandise and Photo Booths
Print-on-demand platforms can offer cartoon portraits on mugs, phone cases, and posters, and event apps can run a live cartoon booth: attendees take a photo, pick a style, and share the result a few seconds later. For more variety, combine with colorized vintage effects.
Tips and Best Practices
- Use clear, well-lit, front-facing photos. The model is face-aware and gives the most detailed output when the face is visible and not too small in the frame. Side profiles and extreme angles are less consistent.
- Match the style to the use case. Anime, 3D, and Ghibli work best for avatars, sketch for artistic prints, design and illustration for marketing material. Or let users try them all.
- Show a loading state. Processing takes 2 to 4 seconds; a message like "Creating your cartoon portrait..." keeps users engaged.
- Cache the results. Result URLs expire after 24 hours, so download the image to your own storage if users will view it again.
- Respect privacy. State in your terms how uploaded photos are used and stored, and consider limiting the feature to self-portraits.
- Clean up the input first if needed. Chaining the Background Removal API before the filter isolates the subject for a cleaner result.
With 7 classic styles, a dedicated Ghibli endpoint, and face-aware processing, the Photo to Anime API lets you ship an anime filter in an afternoon. Grab your free API key and start transforming.
Frequently Asked Questions
- How does AI turn photos into anime?
- The API uses a neural style transfer model trained on anime and cartoon artwork. It analyzes the input photo's structure (faces, edges, colors) and redraws it in the target style while preserving the subject's identity and pose. The result is a stylized version that looks hand-drawn.
- What anime and cartoon styles are available?
- The Photo to Anime API supports 7 classic styles via the /cartoonize endpoint (anime, 3d, handdrawn, sketch, artstyle, design, illustration), a dedicated Studio Ghibli style via the /ghibli endpoint with face enhancement, and premium portrait styles via /cartoonize-pro. You select the style with a parameter in the API call.
- Can I turn photos into Ghibli art for free?
- Yes. The Photo to Anime API includes a free tier with 50 requests per month, so you can transform 50 photos into Ghibli style every month at no cost. No credit card required.
- Do I need a GPU or PyTorch to build an anime filter?
- No. The model runs server-side, so there is no GPU, no AnimeGAN or PyTorch setup, and no model weights to manage. Your code only needs the requests library, and each filter is a single HTTPS request that returns a URL to the stylized image in 2 to 4 seconds.
- Does the anime conversion work on any photo?
- The API works on portraits, group photos, pets, and landscapes. Results are best with clear, well-lit photos where faces are visible. The AI preserves the original composition while applying the selected artistic style to the entire image.



