Send G-code to Printer
send_to_printerUse this when you need to upload a .gcode file (e.g. written by export with target: "model", format: "gcode") to a real network printer and, by default, start the print. protocol: 'octoprint' (POST /api/files/local with an X-Api-Key), 'moonraker' (Klipper's POST /server/files/upload), or 'bambu-lan' (Bambu Lab LAN-mode: FTPS implicit-TLS upload on port 990 as user 'bblp' with the printer's LAN access code, then an MQTT print-start command on port 8883 — requires access_code and, unless start_print is false, serial). bambu-lan uploads a .gcode.3mf print project (the printer prints 3MF projects, not bare G-code): the G-code goes in as Metadata/plate_1.gcode, inside the model 3MF from export format '3mf' when model_3mf_path is given (use options { arrange: 'plate', slicer: 'bambu' } so the printer shows the same named, coloured parts), else inside a minimal 3MF shell; the file name always ends in .3mf ('part.gcode' -> 'part.gcode.3mf'). Optional printer (a bundled profile id, the same ids as the export 3mf/gcode options.printer) is checked against protocol before anything is read or sent: an unknown id is refused with the list of valid ids, 'bambu-lan' needs a Bambu Lab profile and a Bambu Lab profile needs 'bambu-lan'. Pass { dry_run: true } to validate connectivity/authentication only, without uploading or starting a print. Never logs or echoes api_key/access_code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | Printer hostname or IP. | |
| port | No | Override the protocol default port. | |
| serial | No | Bambu printer serial number (required to start a print unless start_print is false). | |
| api_key | No | OctoPrint API key (Settings -> API). | |
| dry_run | No | Validate connectivity/auth only; never uploads or starts a print. | |
| printer | No | Printer profile id; checked against protocol before upload. List them with 'kernelcad print printers'. | |
| filename | No | Uploaded file name (default: 'kernelcad.gcode'; bambu-lan appends '.3mf'). | |
| protocol | Yes | ||
| gcode_path | Yes | Path to the .gcode file on disk. | |
| access_code | No | Bambu LAN-mode access code (printer settings -> LAN Only Mode). | |
| start_print | No | Start the print immediately after upload (default: true). | |
| model_3mf_path | No | bambu-lan only: model .3mf from export format '3mf' to package the G-code into (the uploaded .gcode.3mf). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||