Turn your text prompts into beautiful math & educational animations!
Manimate Backend is a FastAPI-powered service that transforms natural language prompts into stunning mathematical and educational animations using OpenAI's LLM and the Manim engine. Simply send a prompt, and receive a rendered video—perfect for educators, content creators, and anyone who wants to visualize concepts programmatically.
- 🚀 /generate API: Send a prompt, get a video URL back!
- 🤖 LLM Integration: Uses OpenAI to generate Manim code from your ideas.
- 🎥 Manim Rendering: Renders animations and manages output files.
- 📂 Static Video Hosting: Serves generated videos via
/videos
. - 🐳 Docker Support: Easy deployment anywhere.
- Python 3.10+
- Manim & system dependencies (see Dockerfile)
- OpenAI API key
All Python dependencies are in requirements.txt
.
Create a .env
file in the project root:
OPENAI_API_KEY=your_openai_api_key
OPENAI_BASE_URL=your_openai_base_url # Optional
- Clone the repo:
git clone https://github.com/nitindavegit/Manimate-backend.git cd Manimate-backend
- Install system dependencies:
sudo apt-get update && sudo apt-get install -y ffmpeg libcairo2-dev libpango1.0-dev texlive-full build-essential pkg-config
- Install Python dependencies:
python -m venv venv source venv/bin/activate pip install --upgrade pip pip install -r requirements.txt
- Set up your
.env
file (see above). - Run the server:
uvicorn app.main:app --reload
- Build the image:
docker build -t manimate-backend .
- Run the container:
docker run -p 8000:8000 --env-file .env manimate-backend
- POST
/generate/
- Request Body:
{ "prompt": "Show a diagram of a client-server API interaction" }
- Response:
{ "video_url": "/videos/output.mp4" }
- GET
/videos/{filename}
app/
config.py # Loads environment variables
llm_handler.py # Handles LLM prompt and Manim code generation
main.py # FastAPI app entry point
manim_runner.py # Runs Manim and manages output files
routes.py # API endpoints
generate/ # Stores generated videos and code
requirements.txt # Python dependencies
Dockerfile # Docker build instructions
Test Manim rendering without the API:
python app/test_debug.py
- 💡 Prompts should describe the animation you want. The LLM generates Manim code, which is rendered and returned as a video.
- 🎬 All generated videos are saved in the
generate/
directory and served via/videos
. - 🔒 For production, restrict CORS and secure your API keys.
MIT License