slice_model
Slices a model headlessly to G-code and returns the file path, print time, filament use and layer count, using installed profiles or a PrusaSlicer project's saved settings.
Instructions
Slice a model headlessly and return the G-code path plus print time, filament use and layer count. Uses the given installed profiles, or, for a PrusaSlicer project 3MF with no profiles given, the settings saved in the project. G-code is always written as text (not .bgcode).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"model_path": "<model_path>"
},
"name": "slice_model"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scale | No | Scale factor: 0.5 is half size, 2 is double. Not a percentage. Not with scale_to_fit. | |
| split | No | Separate unconnected solids into their own objects, which PrusaSlicer then arranges compactly on the bed. | |
| center | No | Move the model to the middle of the bed. Omit it to centre plain 3MF files, which are usually modelled around the origin and otherwise fail with 'All objects are outside of the print volume', and to leave PrusaSlicer projects (which hold their own layout) and STL/OBJ (which PrusaSlicer places itself) alone. true centres any model; false keeps a plain 3MF where it is stored. The result says whether it was centred. | |
| copies | No | Total number of objects to print, arranged automatically on the bed (3 prints three of this model). | |
| rotate_x | No | Degrees to rotate about the X axis. PrusaSlicer applies rotations in the fixed order X, then Y, then Z, whatever order you think of them. 90 or -90 stands a model that lies along Y upright, e.g. a Y-up scan (check with preview_model first). Exactly +-90 about Y combined with a Z rotation can come out differently from that order: preview_model shows what PrusaSlicer really does. | |
| rotate_y | No | Degrees to rotate about the Y axis (applied after rotate_x). | |
| rotate_z | No | Degrees to rotate about the vertical Z axis (applied last). | |
| overrides | No | Optional PrusaSlicer settings, e.g. {'fill_density': '25%', 'perimeters': '3'}. Keys are config option names (see PrusaSlicer --help-fff); options the server sets itself (profiles, output, binary_gcode, datadir, save) are rejected. | |
| model_path | Yes | Absolute path to an STL/3MF/OBJ file | |
| close_holes | No | Cap flat holes in the mesh before slicing, such as the missing base of a scan, which PrusaSlicer otherwise refuses with 'no extrusions in the first layer'. inspect_model says whether a model has such holes. Only simple, nearly flat holes are closed; bent holes, tiny gaps and open shells are left alone. PrusaSlicer slices a repaired copy in a temporary folder, so the model file is never changed. Not for PrusaSlicer projects, which would lose their saved settings. | |
| output_path | No | Where to write the G-code (default: <output dir>/<model>.gcode). Its folder is created if missing, but only that one level: the folder above it must already exist. | |
| scale_to_fit | No | [x, y, z] in mm: scale the model uniformly to fit inside this box, e.g. the bed size. Not with scale. | |
| print_profile | No | Exact print profile name, from list_profiles. All three profiles or none. | |
| printer_profile | No | Exact printer profile name, from list_printers. Give all three profiles, or none for a PrusaSlicer project (a .3mf saved from PrusaSlicer, see inspect_model's `project`), which is then sliced with its own saved settings (supports, brim, infill...). Giving profiles makes PrusaSlicer ignore those saved settings. | |
| material_profile | No | Exact filament profile name, from list_profiles. All three profiles or none. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stats | Yes | ||
| centered | Yes | ||
| warnings | Yes | ||
| gcode_path | Yes | ||
| holes_closed | No | ||
| settings_from | Yes |