text-to-manim

An LLM pipeline that turns a topic into a multi-scene Manim animation, from generated code to rendered video.

Read the code on GitHub →
Year
2025
Status
Public on GitHub
Built with
Python, Streamlit, Groq, Llama 3.3 70B, manimlib
app.py, condensed
completion = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{
        "role": "user",
        "content": (
            "Generate an extensive ManimLib code in the style of 3Blue1Brown "
            "that explains the following topic as if it were a multi-Scene video:"
            f"\n\n{prompt}\n\n"
            "Please output only valid Python code ..."
        ),
    }],
    max_completion_tokens=32768,
    stream=True,
)

Llama 3.3 70B on Groq streams out a complete manimlib script with several scenes. Models wrap code in markdown fences and polite chatter, so a cleaner strips both and trims everything above the first real line of Python before the file is written and rendered.

When a render fails, the error points back at the generated file, so you can fix one line instead of generating the whole thing again.