3D Printer (Marlin, Klipper) + ASI Biont: AI That Watches Every Layer

A good slicer picks temperatures, speeds, and retraction for you. So why does a print still fail at hour six — a clogged nozzle, a shifted layer, filament runout — while you're asleep? The slicer has no idea what's happening on the machine. The fix is to treat the printer as a managed device with telemetry: Marlin reports status and accepts commands over serial and through OctoPrint's API; Klipper exposes a rich JSON API via Moonraker. Connect that stream to ASI Biont over MQTT or HTTP, and the agent watches nozzle and bed temperature, catches filament runout and layer shifts, pauses the job, sends an alert, and keeps a print log.

From printer telemetry to AI action
1
Marlin/Klipper
Serial or Moonraker API
2
ASI Biont
AI agent parses data
3
Anomaly detected
Temp drop or runout
4
Pause + alert
Telegram notification

The myth: a good slicer will pick the right parameters and you don't need to babysit the printer. The reality: the first layer, adhesion, temperature stability, and filament runout fail exactly where the slicer is blind — after the G-code is generated. A slicer optimizes the path; it does not observe the machine.

What Marlin and Klipper actually expose (and why it matters)

Marlin speaks a line-based protocol over USB serial (typically 115200 baud, though some boards use 250000). Send M105 and you get back something like ok T:210.3 /210.0 B:60.1 /60.0. Send M27 to poll SD print progress. M114 returns current coordinates. For control, M104 S0 turns the hotend off, M140 S0 turns the bed off, M25 pauses SD printing, M24 resumes. If the printer is connected to OctoPrint, you also get an HTTP API: GET /api/printer returns temperatures and state; POST /api/job with {"command":"pause"} pauses the job.

Klipper works differently: the real-time motion planner runs on the host (a Raspberry Pi or similar), and Moonraker sits in front of it with a WebSocket and HTTP API. You can subscribe to printer.objects.subscribe for extruder, heater_bed, print_stats, virtual_sdcard, and get a JSON object on every meaningful change. That makes Klipper a natural fit for event-driven automation — no polling required.

FirmwareTransportTelemetry exampleControl example
Marlin (serial)USB CDC / UARTM105 → ok T:210.3 /210.0 B:60.1 /60.0M104 S0 (hotend off), M25 (pause SD)
Marlin + OctoPrintHTTP RESTGET /api/printerPOST /api/job {"command":"pause"}
Klipper + MoonrakerHTTP / WebSocketprinter.objects.query for extruderprinter.print.pause

How ASI Biont connects to a 3D printer

ASI Biont doesn't ship a prebuilt "3D printer driver." Instead, the AI writes the integration code for your specific setup. You describe the printer in chat — firmware, port or IP, baud rate, API key — and the agent generates Python using pyserial, aiohttp, requests, or websockets. For serial connections, you download bridge.py from the ASI Biont dashboard (not from GitHub) and run it on a machine physically connected to the printer: python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 115200 --rate=10. The bridge relays commands via industrial_command(protocol='serial',...). More on the topic: “HM-10 and HC-05 with ASI Biont: Why Bluetooth UART Integration Silently Fails (and How to Wire It Right)”.

If your printer is on the network (OctoPrint or Moonraker), no bridge is needed — the agent talks HTTP directly. If you have a custom setup, execute_python lets the AI write a script that runs in a sandbox with preinstalled libraries; for anything not covered, the script runs on your machine with the necessary adapter.

Don't wait for an official plugin. ASI Biont connects to any device via execute_python: the AI writes the integration code itself. No developer ticket, no "add device" button. Describe what you need in chat and get working code.

A concrete scenario: auto-pause on filament runout

Imagine a farm of three Klipper printers running overnight. A spool runs out at 2 a.m. Without monitoring, the printer keeps executing G-code with no extrusion — you lose the part, the filament, and six hours of machine time. With ASI Biont, you subscribe to Moonraker's print_stats and extruder objects. When filament_runout sensor state changes to detected (or when extruder.temperature drops below a threshold while the heater is at 100%), the agent calls printer.print.pause, sends a Telegram message via requests.post to api.telegram.org, and logs the event with a timestamp. More on the topic: “ASI Biont LoRaWAN: How to Read Field Sensors Over a COM Port Without a Cloud Gateway”.

Here's the core of the Python script the AI would generate for a Moonraker-based printer:

import requests, time

MOONRAKER = "http://192.168.1.50:7125"
TG_TOKEN = "YOUR_BOT_TOKEN"
TG_CHAT = "YOUR_CHAT_ID"

def moonraker_get(path):
    r = requests.get(f"{MOONRAKER}{path}", timeout=5)
    r.raise_for_status()
    return r.json()

def send_telegram(text):
    requests.post(f"https://api.telegram.org/bot{TG_TOKEN}/sendMessage",
                  json={"chat_id": TG_CHAT, "text": text}, timeout=5)

# Query current print state and heater status
state = moonraker_get("/printer/objects/query?print_stats&extruder")
stats = state["result"]["status"]["print_stats"]
extruder = state["result"]["status"]["extruder"]

if stats["state"] == "printing" and extruder["temperature"] < 170:
    requests.post(f"{MOONRAKER}/printer/print/pause")
    send_telegram("Print paused: extruder temp below 170°C while printing.")

That script runs on demand or on a schedule. The AI can also generate a WebSocket subscriber for real-time events, but a simple poll every 10–30 seconds is often enough for runout and temperature anomalies.

For Marlin over serial, the logic is similar but uses industrial_command through the bridge:

from asibiont import industrial_command  # provided by the bridge runtime

resp = industrial_command(protocol='serial', command='M105', port='COM3', baud=115200)
# resp might be 'ok T:210.3 /210.0 B:60.1 /60.0'
if 'T:0' in resp or 'T:' not in resp:
    industrial_command(protocol='serial', command='M104 S0', port='COM3', baud=115200)
    # send alert via requests.post to Telegram

More scenarios you can wire up in chat

  • First-layer adhesion watch: poll bed temperature and first-layer progress; if bed temp deviates more than 3°C from target during the first layer, pause and alert.
  • Layer shift detection: compare M114 coordinates against expected G-code moves; a sudden offset triggers a pause.
  • Voice command: "Pause the print" — the agent parses intent, calls the pause endpoint, confirms in chat.
  • Print log: every completed or failed job gets a record with duration, max hotend temp, and filament used, exportable as CSV.

Tip: For Klipper, use Moonraker's /printer/objects/subscribe WebSocket to get push updates instead of polling. It reduces latency and network load.

Why this beats waiting for a vendor plugin

The integration cost is near zero: no custom firmware, no hardware mods. You describe the printer and the desired behavior in natural language, and the AI produces a working script in seconds. That script can run on a schedule, react to events, or be triggered by a chat command. The same agent can manage multiple printers from different vendors — Marlin, Klipper, RepRapFirmware — because each integration is just code.

And when something changes — a new printer, a different port, a firmware update — you tell the agent and it rewrites the script. No redeployment, no waiting for a release cycle.

Start now

Open asibiont.com, start a chat, and type: "Connect to my Klipper printer at 192.168.1.50:7125 and pause if the extruder temperature drops below 170°C while printing." The AI will ask for any missing details and generate the code. Try it with your own printer — the first integration takes less time than slicing a Benchy.

AssetMaterials for this article

A document from this article — download and apply it.

  • XLSXASI Biont Print-Monitor Setup Sheet Marlin Klipper Telemetry, Thresholds & Alert Rules.xlsxXLSX · 8.9 KBDownload
← All posts

Ask AI about this article

Ask a question about this article — ASI Biont will answer based on its text and the attached files.