A minimal, LLM-friendly CAD library in Python.
Documentation: https://llmcad.org
Source Code: https://github.com/llmcad/llmcad
llmcad is a Python CAD library designed from the ground up to be LLM-friendly. It wraps OpenCASCADE (via OCP) with a minimal, explicit API that makes 3D modeling predictable and debuggable — whether you're writing code yourself or letting an AI agent do it.
Developed by and powering BuildCAD AI — the #1 Text-to-CAD tool.
LLMs struggle with 3D spatial reasoning. Traditional CAD APIs make this worse with large surface areas, implicit state, and global coordinate math.
llmcad fixes this with three design principles:
- Named geometry: Every face and edge has a semantic name (
top,front,left_edge). No guessing indices or filtering by coordinates. - Face-local coordinates: Position things relative to faces using intuitive local offsets (
offset,inset). No global coordinate math. - Minimal API: ~28 core concepts. If an LLM can't hold the entire API in context, the API is too big.
- Shapes —
Box,Cylinder,Spherecentered at origin with named faces - Sketches —
Rect,Circle,Ellipse,Polygon,Text, and turtle-styleSketchbuilder - Operations —
extrude,revolve,loft,sweep,fillet,chamfer,shell,split,mirror - Assembly —
placeparts on faces,Assemblyfor multi-part models - Booleans —
+(union),-(cut),&(intersect) — operator syntax, no method chains - Visual debugging — Multi-view
snapshot()renders for LLM feedback loops - Export —
export_step,export_stl,export_glbfor CAD interchange, 3D printing, and web viewers - Immutable — Boolean ops return new bodies. No hidden mutation.
pip install llmcadRequires Python 3.10+. Dependencies (cadquery-ocp, numpy, Pillow, vtk) are installed automatically.
A mounting plate with a boss, through-hole, filleted edges, and corner mounting holes — in 15 lines:
from llmcad import Box, Rect, Circle, extrude, fillet
# Base plate
plate = Box(100, 60, 10, color="steel")
# Raised boss on top
boss = extrude(Rect(30, 30).place_on(plate.top), amount=20)
plate = plate + boss
# Through-hole in boss
hole = extrude(Circle(12).place_on(plate.top), through=True)
plate = plate - hole
# Fillet top edges
plate = fillet(plate.top.edges, radius=3)
# Corner mounting holes
for corner in plate.bottom.corners:
pos = corner.inset(dx=8, dy=8)
h = extrude(Circle(5).place_on(plate.bottom, at=pos), through=True)
plate = plate - hEvery shape comes with semantic face names. No need to filter by normal direction or index into face lists.
box = Box(60, 40, 20)
box.top # +Z face
box.bottom # -Z face
box.front # -Y face
box.back # +Y face
box.left # -X face
box.right # +X facePlace sketches and holes relative to faces using local coordinates. offset(dx, dy) moves in the face's local frame — dx is always "right" and dy is always "up", regardless of which face you're on.
# Hole offset 20mm to the right on the top face
pos = plate.top.center.offset(dx=20)
hole = extrude(Circle(5).place_on(plate.top, at=pos), through=True)
# Holes at each corner, inset 8mm from edges
for corner in plate.top.corners:
pos = corner.inset(dx=8, dy=8) # direction toward center is automaticCombine bodies with Python operators. Each operation returns a new body — the originals are unchanged.
base = Box(80, 60, 10)
boss = extrude(Rect(30, 30).place_on(base.top), amount=20)
result = base + boss # union
result = base - boss # cut
result = base & boss # intersectRender multi-view snapshots for visual verification — essential for LLM feedback loops.
from llmcad import snapshot
snapshot(plate, "plate") # saves plate.png with front, right, top, and iso viewsBox![]() |
Cylinder![]() |
Sphere![]() |
Plate with Hole![]() |
Filleted Edges![]() |
Chamfered Edges![]() |
Boolean Subtraction![]() |
Corner Holes![]() |
Stacked Boxes![]() |
See the full examples gallery for all 18 examples with code.
Export to STEP (CAD interchange), STL (3D printing), or GLB (web viewers):
from llmcad import Box, export_step, export_stl, export_glb
box = Box(50, 50, 50, color="steel")
export_step(box, "box.step") # exact B-Rep geometry
export_stl(box, "box.stl") # triangulated mesh
export_glb(box, "box.glb") # binary glTF 2.0 with PBR material| Category | Symbols |
|---|---|
| Shapes | Box, Cylinder, Sphere |
| Sketches | Rect, Circle, Ellipse, Polygon, Text, Sketch |
| Operations | extrude, revolve, loft, sweep, fillet, chamfer, shell, split, mirror |
| Assembly | place, Assembly, RevoluteJoint |
| Booleans | + (union), - (cut), & (intersect) |
| Debug | snapshot, show, show_faces, show_edges, measure |
| Export | export_step, export_stl, export_glb |
| Types | Body, FaceRef, EdgeRef, Position |
Full API reference: llmcad.org/api-reference
llmcad builds on:
- OCP — Python bindings for OpenCASCADE, the industry-standard open-source CAD kernel
- NumPy — array operations for tessellation and rendering
- Pillow — image output for snapshots
- VTK — offscreen multi-view rendering
This project is licensed under the terms of the MIT license.
Developed by and powering BuildCAD AI — the #1 Text-to-CAD tool.










