Can ChatGPT write G-code? What the tests show, and where it breaks

The short answer: yes, for simple parts. ChatGPT can write G-code that runs for facing, drilling and simple 3-axis pockets, and recent models do it far better than early ones. It is not a replacement for CAM on real parts, because it has no geometry kernel, does not know your machine, tools or stock, and cannot prove the program is safe. Use it to explain, check and learn. Generate production NC with something that computes toolpaths from the model and verifies them.

I run KinetiCAD, which generates NC without a language model. The tests below are other people's, linked so you can check them.

What the tests actually found

A peer-reviewed comparison (2025). Researchers at the University of Maribor asked ChatGPT-3.5 and GPT-4o to write ISO G-code for a sample 3-axis part, checked the output in Siemens NX, and asked both models to find and explain errors (Šket et al., Advances in Production Engineering & Management, June 2025).

  • GPT-3.5 produced partially functional code. It struggled with milling and did better on drilling.
  • GPT-4o produced functional G-code for the sample part, explained each line correctly, and found and fixed errors.
  • The authors' conclusion: it "cannot yet replace traditional CAM programming, especially for complex operations", and still requires expert supervision.
  • Not tested: free-form surfaces, complex toolpaths, multi-axis work and control-specific syntax.

A CAM instructor's test (Modern Machine Shop, December 2023). Mike Wearne of CAMInstructor tested GPT-3, 3.5 and 4 on facing, drilling and bolt circles, and plotted the results in CIMCO Edit (MMS).

  • Early models got the program structure right (units, absolute positioning) but left out tool changes and spindle speeds.
  • GPT-4 handled simple parts well, especially when given the print as an image, and was useful for explaining alarm codes.
  • Beyond simple parts and shapes, it fell short. A dynamic milling toolpath for a large pocket was judged out of reach.

Models have improved since both tests, and they will keep improving. The limits below are not about model size, though. They come from what the model is missing.

Why a language model is the wrong tool for production NC

1. It predicts text; it does not compute geometry. A toolpath is the result of offsetting surfaces by the tool radius, checking every move for gouges and collisions, and keeping engagement within limits. CAM systems do this with a geometry kernel. A language model writes the coordinates that look most likely. For a bolt circle that is fine; for a 3D surface or an adaptive pocket, it is guessing.

2. It does not know your shop. The program depends on your machine's travel and control dialect, the tools in the magazine and their stick-out, the stock size, the workholding, the work offsets and safe positions. Unless you type all of it in, the model assumes. CloudNC makes the same point in its own answer to this question.

3. Same question, different program. Ask twice and you can get two different programs. Production NC has to be repeatable: the same part, machine and tools should give the same program, so a proven program stays proven.

4. It cannot prove its output is safe. A wrong sign on a Z move or a missing tool length offset is one character. The program reads fine and crashes the machine. Checking that requires simulating the cut against the model and the stock, which a chat window does not do.

5. Long programs do not fit. Real programs run to thousands of blocks. The Maribor study names context window size as a limit for large files.

Where ChatGPT is genuinely useful in a CNC shop

  • Explaining a program line by line, especially one someone else wrote. This was GPT-4o's strongest result in the study.
  • Decoding alarms and looking up control-specific codes.
  • Drafting short, simple programs you will check anyway: facing, a drill pattern, a probing routine.
  • Writing and commenting macros, and converting between dialects as a starting point.
  • Learning G-code. It is a patient tutor.

In every case, a person who knows G-code reads the output, and it is simulated before it runs.

What to use instead for real parts

There are three ways to get production NC without writing it by hand:

  1. Classic CAM (Mastercam, Fusion, NX, hyperMILL and others): a programmer builds the toolpaths, and a post-processor writes the code for your control.
  2. AI inside CAM (CloudNC CAM Assist, Toolpath, Limitless, up2parts autoCAM): the tool proposes the strategies and toolpaths inside the CAM system, and a programmer reviews and posts. See AI CAM software in 2026, compared.
  3. Job preparation without a CAM seat (KinetiCAD): it reads the STEP model and the drawing, plans the operations across your machines from lathe to mill, generates the NC, and prices the job from the same plan.

How KinetiCAD generates NC without a language model

We took the opposite design choice to "ask a chatbot":

  • Deterministic strategy generators compute each operation's toolpath from the model, for the tool and machine it is assigned to. The same inputs give the same program.
  • Your shop data is an input, not something to type into a prompt: the machine list with controls, the tool magazines and the material library.
  • A release gate. Every program is cut in a material-removal simulation and compared with the CAD model. If the deviation is over the threshold, it is not released, and an operator approves every program before anything runs.

You can see the whole chain on a public test part in STEP file to G-code automatically: what has to happen.

If you want to see it on one of your own parts, send us a STEP file and its drawing.

Frequently asked questions

Can ChatGPT write G-code?

Yes, for simple parts. In a 2025 peer-reviewed study, GPT-4o produced functional ISO G-code for a basic 3-axis milling part, and GPT-3.5 produced partially functional code. The authors conclude it still requires expert supervision and cannot yet replace CAM programming for complex operations.

Is it safe to run ChatGPT G-code on a CNC machine?

Not without checking it. Treat it like code from an unknown programmer: read it, simulate it against the model with the real tool, stock and work offsets, and prove it out with single block and reduced rapids. Even small errors in G-code can damage the part, the tool or the spindle.

What is ChatGPT good for in CNC programming?

Explaining existing programs line by line, decoding alarms, drafting simple drilling or facing programs, writing macros, and teaching G-code. Tests found GPT-4 class models strong at explaining code and spotting errors in short programs.

Does KinetiCAD use a language model to write G-code?

No. KinetiCAD's NC programs come from deterministic strategy generators, and every program is simulated against the CAD model and approved by an operator before release. No language model writes the toolpaths.