Run Blender headless with a Python script
blender_run_pythonRun Python in headless Blender to build or edit scenes, set materials, cameras, and lights, render stills or animations, and export GLB/FBX/USD. Persist results in a .blend file.
Instructions
Run Blender in background mode (no window ever appears) and execute Python with the full bpy API: build or edit scenes, model, animate, set up materials, cameras and lights, render stills or frame sequences (bpy.ops.render.render(write_still=True) / animation=True), and export .glb/.fbx/.usd. Optionally open a .blend first; save with bpy.ops.wm.save_as_mainfile(filepath=...). Each call is a fresh Blender process: persist work in a .blend file. print() output is returned. Runs arbitrary Python as the user: only write files inside the job folder.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "blender_run_python"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory for relative paths, usually the job folder | |
| args | No | Extra arguments, readable in Python via sys.argv after '--' | |
| code | No | Python source to run (uses bpy). Give this or scriptPath. | |
| engine | No | Override the render engine for this run | default |
| blendFile | No | A .blend file to open first | |
| scriptPath | No | Path to a .py file to run instead of code | |
| factoryStartup | No | Ignore the user's Blender preferences and add-ons for reproducible results | |
| timeoutMinutes | No |