APIMODELSAPIMODELS

Blender Python with Claude Code

TL;DR Claude Code works with Blender best through the command line: blender -b -P scene.py runs a Python script with no window, so Claude can write the bpy script, render a few small frames, look at the PNGs, fix what is wrong, and then render the full video with Blender’s own FFmpeg output. Everything, from geometry and materials to keyframes, camera and lights, is generated in code. On our Apple M4 with Blender 5.3, the test script below rendered three preview frames in about 26 seconds including start-up and a 72-frame 1280×720 MP4 in 77 seconds with EEVEE. Use Claude Fable 5.2 for the hardest scenes and Opus 5.5 or Sonnet 5.5 for quick iterations.

Some of the most widely shared Claude Fable 5.2 work after its 9 November 2026 launch was made in Blender without anyone touching Blender’s interface. The best documented is a photoreal pelican riding a bicycle: the published session trace shows Fable 5.2 in Claude Code writing the Blender scripts from scratch over about 2 hours 44 minutes and about 1.1 million output tokens, then rendering 444 frames with Cycles in about 56 minutes on an RTX 5080. Other creators used Fable 5.2 with Blender for a 90-second anime short drawn with frame-by-frame line art and for a sea serpent coiling around a ship.

This page turns that route into steps you can reuse. The script, the commands and the timings below come from our own run on Blender 5.3; they test the toolchain, not a model. We run apimodels.app, so the setup step points Claude Code at our endpoint, but everything here works with any Anthropic-compatible endpoint.

Install Blender and point Claude Code at a model

Install Blender from blender.org, or on macOS with brew install --cask blender. Claude needs the path to the executable: /Applications/Blender.app/Contents/MacOS/Blender on macOS, blender on most Linux installs, and blender.exe in the install folder on Windows. Put it in your project notes or in the skill file below so every session finds it.

Then set ANTHROPIC_BASE_URL=https://api.apimodels.app, your key in ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_MODEL to the model you want. Blender sessions re-read the same long script many times, so it pays to write the first version on the strongest model and switch to a less expensive one with /model for small tweaks.

Model idPrice per 1M tokens (input / output)Use it for
claude-fable-5-2$4.80 / $24Photoreal scenes, characters, anything that needs many render-and-fix rounds
claude-opus-5-5$2.40 / $12Most scenes and fix rounds
claude-sonnet-5-5$1.20 / $6Small changes: camera, lights, timing, materials

Why the command line, not the Blender window

blender -b runs Blender in background mode with no window, -P runs a Python script, and anything after -- is passed to the script in sys.argv. That gives Claude Code everything it needs: it writes scene.py, runs one command, and gets PNG or MP4 files it can open and inspect. The run is reproducible, the script lives in your repository, and nothing depends on what happened to be open in the interface.

A Blender MCP server is the alternative when you want Claude to operate a Blender window you are watching, and one creator used that route to build a game-ready creature. For anything that ends in a rendered video, the command line is simpler to set up and easier to rerun.

How a good scene script is structured

The script in Quick start follows the shape that works: start from an empty scene with read_factory_settings(use_empty=True) so nothing from a default file leaks in; build geometry and materials with small helper functions; compute every keyframe from the frame number so the animation is deterministic; add the camera, light and world last; and keep two modes, a quick preview and a final render, switched by an argument after --.

Ask Claude to generate everything in code, with no downloaded models, textures or HDRIs unless you supply them. It keeps the result redistributable, and it is how the public Fable 5.2 Blender work was made. For anything bigger than one object, ask for reusable generator functions first and assemble the scene from them.

Render small, look, fix, then render

The preview mode renders three key frames at a quarter of the final size, which took about 26 seconds on our machine including Blender’s start-up. Claude Code can open those PNGs and see what is wrong. Our own first preview showed exactly why this matters: at frame 18 the ball bounced so high that it left the top of the frame. Lowering the bounce and moving the camera took one edit and one more preview, instead of a wasted full render.

Tell Claude to measure the time per frame on the preview before it starts a long final render, and to say how long the full render will take. The pelican run above rendered 444 frames with Cycles for about 56 minutes on a desktop GPU; a mistake found after that costs an hour.

Video output in Blender 5

Blender can write the MP4 itself. In Blender 5.x, set the output’s media_type to VIDEO before setting file_format to FFMPEG, then choose the MPEG4 container and the H264 codec; the final mode of our script rendered 72 frames at 1280×720 into a 3-second H.264 file in 77 seconds with EEVEE on an Apple M4. If you prefer, render a PNG sequence and encode it with ffmpeg; that also lets you re-encode without re-rendering.

The Python API changes between versions, and that is the most common reason a script Claude remembers fails. In Blender 5.3 the EEVEE engine identifier is BLENDER_EEVEE, and Material.use_nodes and World.use_nodes are deprecated because node trees exist by default. Ask Claude to print bpy.app.version and the available engine names at the start of a session instead of relying on memory.

Save the rules as a Claude Code skill

Put the SKILL.md below in ~/.claude/skills/blender-scene/ for every project, or .claude/skills/blender-scene/ in one repository, and fill in your Blender path. Claude Code loads it whenever a request matches its description, so “make a 10-second Blender shot of a lighthouse at dusk” arrives with the command-line, procedural and preview-first rules already in place.

What a long Blender run costs

Output tokens dominate. The pelican session used about 1.1 million output tokens on Fable 5.2, which is about $26.40 of output at apimodels.app’s $24 per million, or $44 at Anthropic’s list price, before input and cache reads. Each turn re-reads the growing script, so cache reads at $0.12 per million keep that part small. Simple scenes like our test need a small fraction of that, and switching to Opus 5.5 for fix rounds halves the per-token price. Your console’s call records show the exact charge per request.

Where this route struggles

Character animation is the weak spot: code-built rigs tend to move stiffly, and creators have reported better motion after having Claude rebuild the rig once it saw the first attempt fail. Photoreal people are a job for a video model, not Blender scripts. Cycles on a CPU is slow, so long photoreal shots need a GPU. And if you need a specific licensed asset, supply the file yourself and tell Claude to load it, rather than asking it to recreate it.

Quick start

scene.py · empty scene to MP4, all in code (tested on Blender 5.3)

# scene.py: build a small animated scene entirely in code and render it.
# usage:
#   blender -b -P scene.py -- --preview      # 3 key frames at 25% size, as PNG
#   blender -b -P scene.py -- --final        # every frame at full size, as MP4
import sys, math, os
import bpy

args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
PREVIEW = "--preview" in args
OUT = os.path.abspath(os.path.join(os.path.dirname(__file__), "out"))

bpy.ops.wm.read_factory_settings(use_empty=True)  # start from an empty scene
scene = bpy.context.scene
scene.frame_start, scene.frame_end = 1, 72          # 3 seconds at 24 fps
scene.render.fps = 24

def material(name, rgb, rough=0.5, metal=0.0):
    m = bpy.data.materials.new(name)
    p = m.node_tree.nodes["Principled BSDF"]
    p.inputs["Base Color"].default_value = (*rgb, 1)
    p.inputs["Roughness"].default_value = rough
    p.inputs["Metallic"].default_value = metal
    return m

# ground and a bouncing ball, all generated in code
bpy.ops.mesh.primitive_plane_add(size=20)
bpy.context.object.data.materials.append(material("Ground", (0.08, 0.09, 0.12), rough=0.9))
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.6, segments=64, ring_count=32)
ball = bpy.context.object
bpy.ops.object.shade_smooth()
ball.data.materials.append(material("Ball", (0.95, 0.45, 0.15), rough=0.25))

# keyframes: three bounces, squashed on contact
for f in range(scene.frame_start, scene.frame_end + 1):
    t = (f - 1) / 24
    phase = (t % 1.0)
    height = 4 * phase * (1 - phase) * 2.0          # parabola per bounce
    ball.location = (t * 1.2 - 1.8, 0, 0.6 + height)
    squash = 1 - 0.25 * max(0.0, 1 - height / 0.4)
    ball.scale = (1 / math.sqrt(squash), 1 / math.sqrt(squash), squash)
    ball.keyframe_insert("location", frame=f)
    ball.keyframe_insert("scale", frame=f)

# light, camera, world
bpy.ops.object.light_add(type="SUN", location=(4, -4, 8))
bpy.context.object.data.energy = 3.0
bpy.context.object.rotation_euler = (math.radians(50), 0, math.radians(35))
bpy.ops.object.camera_add(location=(0, -10, 2.4), rotation=(math.radians(84), 0, 0))
scene.camera = bpy.context.object
scene.world = bpy.data.worlds.new("World")
scene.world.node_tree.nodes["Background"].inputs["Color"].default_value = (0.02, 0.025, 0.035, 1)

# render settings
scene.render.engine = "BLENDER_EEVEE"
scene.render.resolution_x, scene.render.resolution_y = 1280, 720
scene.render.resolution_percentage = 25 if PREVIEW else 100

if PREVIEW:
    scene.render.image_settings.file_format = "PNG"
    for f in (1, 18, 36):
        scene.frame_set(f)
        scene.render.filepath = os.path.join(OUT, f"preview_{f:03d}.png")
        bpy.ops.render.render(write_still=True)
else:
    scene.render.image_settings.media_type = "VIDEO"
    scene.render.image_settings.file_format = "FFMPEG"
    scene.render.ffmpeg.format = "MPEG4"
    scene.render.ffmpeg.codec = "H264"
    scene.render.filepath = os.path.join(OUT, "ball_")
    bpy.ops.render.render(animation=True)

Terminal · preview, then final (tested on Blender 5.3, Apple M4)

# macOS path; on Linux use "blender", on Windows the full path to blender.exe
BLENDER=/Applications/Blender.app/Contents/MacOS/Blender

$BLENDER -b -P scene.py -- --preview   # 3 frames at 25% size -> out/preview_*.png  (~26 s)
$BLENDER -b -P scene.py -- --final     # 72 frames at 1280x720 -> out/ball_0001-0072.mp4  (77 s, EEVEE)

~/.claude/skills/blender-scene/SKILL.md (ours)

---
name: blender-scene
description: Build, preview and render Blender scenes and animations with Python from the command line. Use when the user asks for a 3D scene, model, animation or rendered video made in Blender.
---

# Blender scenes from the command line

Blender: /Applications/Blender.app/Contents/MacOS/Blender   (edit for your machine)

1. Never open the Blender window. Run: BLENDER -b -P scene.py -- <args>.
2. At the start of a session, print bpy.app.version and the available render
   engines; do not rely on memory for API names.
3. Start from bpy.ops.wm.read_factory_settings(use_empty=True). Generate all
   geometry, materials, keyframes, camera and lights in code. No downloaded
   models, textures or HDRIs unless the user supplies them.
4. Compute every keyframe from the frame number so the animation is
   deterministic. Write reusable generator functions before assembling.
5. Keep two modes: --preview renders 3-6 key frames at 25% size as PNG;
   --final renders the whole animation.
6. After every change, run --preview, open the PNGs, list what looks wrong
   (out of frame, clipping, flat light, stiff motion), fix, and repeat.
7. Before --final, measure seconds per frame on the preview and tell the user
   how long the full render will take.
8. Video in Blender 5.x: image_settings.media_type = "VIDEO", then
   file_format = "FFMPEG", ffmpeg.format = "MPEG4", ffmpeg.codec = "H264".

Prompt template · Blender shot (ours)

Make a [length]-second Blender shot at [1280x720, 24fps]: [subject],
[camera move], [light and time of day], [mood].
Follow the blender-scene skill: command line only, everything generated in
code, deterministic keyframes. Show me the --preview frames and what you
fixed before you run --final, and tell me the expected render time first.

cURL

curl https://api.apimodels.app/v1/messages \
  -H "x-api-key: $APIMODELS_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-fable-5-2",
    "max_tokens": 64000,
    "messages": [{"role": "user", "content": "Write a Blender 5.3 Python script, run with blender -b -P, that builds a lighthouse at dusk entirely in code and renders 3 preview frames at 25% size."}]
  }'

FAQ

Can Claude Code use Blender?

Claude Code can drive Blender by writing a Python script and running it with blender -b -P scene.py, which needs no window. It then opens the rendered PNG or MP4 files to check the result. A Blender MCP server is an alternative when you want it to operate a Blender window you are watching.

How do I render a Blender animation from the command line?

Run blender -b -P scene.py, and in the script set the frame range, resolution and output, then call bpy.ops.render.render(animation=True). In Blender 5.x, set the output media_type to VIDEO before choosing FFMPEG to get an MP4 directly. Our 72-frame 1280×720 test rendered in 77 seconds with EEVEE on an Apple M4.

Why does a Blender script from Claude fail with an attribute error?

The usual cause is a Blender API change between versions: engine identifiers, output settings and node options move from release to release. Have Claude print bpy.app.version and the available engine names first, and on Blender 5.x leave out Material.use_nodes and World.use_nodes, which are deprecated because node trees exist by default.

Which Claude model is best for Blender?

Claude Fable 5.2 handled the most demanding public Blender work, such as a photoreal pelican on a bicycle built over almost three hours in Claude Code. For simpler scenes and fix rounds, Opus 5.5 at $2.40 / $12 per million tokens on apimodels.app is half Fable 5.2’s price, and Sonnet 5.5 at $1.20 / $6 covers small changes.

How much does it cost to make a Blender animation with Claude?

A long photoreal run can use about a million output tokens: the published pelican session used about 1.1 million on Fable 5.2, roughly $26.40 of output at apimodels.app prices before input and cache reads. Simple scenes cost a small fraction of that, and moving fix rounds to Opus 5.5 halves the per-token price.

Related

Featured on
APIMODELS on Product HuntAPIMODELS featured on ToolifyAPIMODELS featured on There's An AI For That