---
tier: hero
reliability: 4.0 # LLM authors Manim scene .8 + manim-render cap (deterministic, MathTex/LaTeX) .9 + narration/score/mix .9; -.1 LLM-authored scene code can need one repair pass
---

# Doc → Manim Animation — broadcast-grade math, rendered from code ⭐

> Paste this whole file (with the BRIEF filled in) into Claude cowork, chat, or Code with the Storyboard MCP attached. Hand it a STEM concept or an equation — it writes a **Manim** scene, renders it on the **`manim-render`** cap into precise, beautiful mathematical animation (real MathTex equations, transforms, graphs, geometric proofs), then narrates + scores it.

## What you'll get

- A **20–60s animated math/diagram explainer** — true LaTeX equations that *transform*, axes + plots, tangent lines, geometric proofs, vector fields: the 3Blue1Brown look, from one prompt.
- Optional narration (your voice + language) + a music bed.
- The **Manim scene code** as a deliverable — tweak a constant and re-render.

**The wow:** this is the precise tier of doc-to-animation. `hyperframes-render` (HTML) is great for UI/text/charts; **`manim-render` is for math that has to be *exactly right* and *move*** — `\lim`, `\int`, a tangent line sweeping to its limit, squares rearranging into a proof. The cap is a deterministic executor: the agent writes a `Scene`, the container renders it.

## The marquee capability

**`manim-render`** (`kind: "tool"`, on tool-staging-1) — takes an LLM-authored Manim Community `Scene` (Python), renders to MP4 with `manim render`. Supports MathTex/LaTeX (minimal texlive baked into the image). Quality `low` (480p15) / `medium` (720p30, default) / `high` (1080p60). Sibling to `hyperframes-render`.

## The caps

| Step | Cap |
|---|---|
| (opt) ingest the source concept | `gemini-text` |
| Write the Manim scene + narration script | LLM (the agent) |
| **Render the scene → MP4** | **`manim-render`** |
| Narration | `gemini-tts` (named voice + tone) |
| Music bed | `sonilo-t2m` / `minimax-music` |
| Mix + finish | `ffmpeg` |

## Tell the agent about the animation

```yaml
concept:       # the math/STEM idea (e.g. "the derivative of x^2 as a tangent line")
equations:     # OPTIONAL specific equations to feature (LaTeX ok)
duration:      # target seconds
quality:       # low | medium | high  (medium = 720p30, the default)
voice:         # gemini-tts voice + tone (optional — omit for silent)
music_brief:   # bed mood (optional)
launch_slug:   # e.g. the-derivative
```

## How the agent should run this (interaction contract)

1. **DESIGN.** Turn the concept into a beat list + the key equations. Decide what *moves* (a transform, a limit, a sweep) — motion is the point of Manim. Show it; GATE.
2. **AUTHOR the scene.** Write ONE `Scene` subclass. Use only `manim` / `numpy` / `math` / `random` / `itertools` (the cap's safety scan rejects filesystem/network/process code). Prefer stable core API: `Text`, `MathTex`, `Axes`, `ax.plot`, `ValueTracker` + `always_redraw`, `Write`/`Create`/`Transform`/`FadeIn`. Keep the equation count tight and legible.
3. **RENDER.** `manim-render` with `{ code, scene_name?, quality }`. Heavy-ish (~1–4 min at 720p on the CPU tool-host) → direct-SDK with a long timeout if `create_media` reaps. **Look at the output** (render-and-look) — confirm the math reads correctly and the motion lands.
4. **REPAIR if needed.** If the cap returns a `manim render failed` stderr tail, fix the scene (a missing import, a LaTeX typo, an API change) and re-render. Budget one repair pass.
5. **NARRATE + SCORE + MIX.** `gemini-tts` (tone directive, verify with ASR), `sonilo-t2m` bed, ffmpeg mix.

## What can disappoint (cap ceilings)

- **LaTeX is minimal** — `texlive-latex-base/extra/recommended` + `texlive-science` are baked in; an exotic package (`\usepackage{...}`) may be missing. Stick to standard math (`amsmath`-level) or the render fails with a LaTeX log tail.
- **The CPU tool-host is small** — keep scenes to tens of seconds and default to `medium` (720p); `high` (1080p60) is slow. No 3D-heavy `ThreeDScene` marathons.
- **LLM-authored scene code occasionally needs one repair** — the cap returns the manim stderr tail; fix and re-render (don't loop blindly).
- **Safety scan** rejects `os`/`sys`/`subprocess`/`open`/`eval`/etc. — scenes are pure animation, not scripts.

## When you're done

```
✅ Animation: public/launches/{launch_slug}.html  +  {launch_slug}.mp4  +  the Manim scene.py
✅ Real MathTex, narrated + scored
Total spent: $X.XX
```

## What to do next
1. **Tweak a constant** — change `f(x)` or a range in the scene and re-render; it's code.
2. **Chain with hyperframes** — Manim for the math beats, hyperframes for the title/UI beats, ffmpeg-concat them.
3. **Localize** — swap the narration language; the math is universal.

---

## Notes for the agent (only read if a step fails)

**manim-render contract.** `POST /inference {"capability":"manim-render","params":{"code":"<scene.py source>","scene_name":"Main","quality":"medium"},"timeout":320}`. `scene_name` optional (defaults to the first `Scene` subclass). Returns the MP4 url (nested at `data.url` / `data.data.url` — extract recursively). Code must define `class X(Scene)` and use only the allowed modules.

**Minimal scene template.**
```python
from manim import *
class Main(Scene):
    def construct(self):
        eq = MathTex(r"a^2+b^2=c^2")
        self.play(Write(eq)); self.wait(1)
```

**Narration.** `gemini-tts` (`prompt` + named `voice`, tone directive interpreted not spoken). `sonilo-t2m` → `.m4a`.
