# Melt3D Slicer API

> The most advanced nonplanar slicing as an API: slice 3D models (STL) into
> G-code for FDM 3D printers on Melt3D's servers, in flat layers or in conical
> layers that print overhangs without support, with PrusaSlicer, CuraEngine or
> OrcaSlicer, from your own app, printer farm, pipeline or AI agent. Pay per
> slice; new accounts start with 1 EUR of free credit.

You pay per slice that returns G-code.

Base URL: `https://api.melt3d.eu`. The machine-readable description is at
[`/v1/openapi.json`](https://api.melt3d.eu/v1/openapi.json) (OpenAPI 3.1). Using the API
means accepting the [API terms](https://melt3d.eu/api/terms).

## Getting a key

1. Sign in at [auth.melt3d.eu/developers](https://auth.melt3d.eu/developers)
   and accept the API terms.
2. Create a key (`m3d_live_…`). Your account starts with 1 EUR of free
   credit, no card needed.
3. Add a payment method before the credit runs out. Billing runs through
   Stripe, and you are invoiced monthly for what you used.

Keys are shown once: store them safely. Replacing a key revokes the old one.
Up to 3 keys per account. Treat a key as an opaque string and send it with
every request:

```
Authorization: Bearer m3d_live_…
```

## From an AI agent

The [MCP server](https://www.npmjs.com/package/@melt3d/nonplanar-slicer-mcp) lets
Claude, Cursor and other MCP clients slice STL files on your computer:

```sh
claude mcp add meltslicer --env MELT3D_API_KEY=m3d_live_… -- npx -y @melt3d/nonplanar-slicer-mcp
```

## Slicing a model

`POST /v1/slices` with an STL as the body (binary; ASCII works for flat
layers) and the print settings as query parameters. The answer is the G-code.

```sh
curl "https://api.melt3d.eu/v1/slices?layer_height=0.2&infill_density=20&filename=bracket.stl" \
  -H "Authorization: Bearer $MELT3D_API_KEY" \
  -H "Content-Type: model/stl" \
  -H "Idempotency-Key: $(uuidgen)" \
  --compressed \
  --data-binary @bracket.stl \
  -o bracket.gcode
```

| Parameter | Meaning |
|---|---|
| `engine` | `prusaslicer` (default), `curaengine` or `orcaslicer` |
| `filename` | The model's file name, used in the G-code's comments |
| `layer_height`, `first_layer_height` | mm, 0.01 to 2 |
| `perimeters` | count, 0 to 20 |
| `infill_density` | percent, 0 to 100 |
| `infill_pattern` | `grid`, `gyroid` or `honeycomb` |
| `nozzle_temp`, `bed_temp` | °C, 0 to 500 and 0 to 200 |
| `brim_width` | mm, 0 to 50 |
| `supports` | `none` or `bed` (supports from the bed) |
| `layers` | `planar` (default) or `conical`: see below |
| `cone_angle` | With `layers=conical`: degrees from horizontal, 5 to 85 either way (default 15) |

Leave a parameter out to use the engine's default. An unknown parameter, a
value that does not parse, or one outside its range is refused with 400, and
the message says which. The body may be gzipped (`Content-Encoding: gzip`),
up to 100 MiB once inflated.

Every answer is printable G-code, whichever key you use. The `X-Melt-Gcode`
header says how it was made: `full` (flat layers) or `mapped` (conical
layers, mapped back onto the bed).

## Nonplanar: conical layers

`layers=conical` slices the model in cones instead of flat layers. Each layer
leans `cone_angle` degrees from horizontal: positive leans it outwards, so an
overhang that widens upwards (a funnel, a bowl, a mushroom cap) prints on the
layer below it without support; negative leans it inwards. The server bends
the model, slices the bent shape with the engine, and maps every move of the
G-code back onto the bed, so what you get is ready to print.

```sh
curl "https://api.melt3d.eu/v1/slices?layers=conical&cone_angle=30" \
  -H "Authorization: Bearer $MELT3D_API_KEY" \
  --data-binary @funnel.stl -o funnel.gcode
```

The model is set on the bed (its lowest point at Z 0) and keeps its X and Y,
as in a flat slice. Conical layers need a binary STL, and take no
`supports`: support built under a bent part would bend with it. A conical
slice is billed at a price of its own, higher than a flat one's:
[melt3d.eu/api](https://melt3d.eu/api) lists both.

## What you pay for

One slice is billed when it returns G-code, at the flat or the conical
price by its `layers`. A request refused (4xx), turned
away because the servers are busy (503), or one whose slice fails is free.
Your free credit pays for the first slices; once it is used, keys get 402
until a payment method is on file.

Send an `Idempotency-Key` header (1 to 255 visible ASCII characters, such as
a UUID) to retry safely: the same request sent again with the same key
within 24 hours is billed once.

Your account has a monthly spending cap: 100 EUR unless you set another, from
5 to 2000 EUR, on the developers page. Once your usage reaches it, keys get
402 until the next billing period or until you raise it. The cap is
checked every couple of minutes, so usage can pass it by a little. Each time
your usage passes 20 EUR you are invoiced for it then, rather than at the end
of the month. A payment that fails stops your keys the same way until it is
paid.

## Limits

| Per key | |
|---|---|
| Slices at once | 4 |
| Requests a minute | 120 |
| Wait for a free server slot | up to 60 seconds |

Every answer to a request with an accepted key carries `RateLimit-Limit`,
`RateLimit-Remaining` and `RateLimit-Reset` (seconds). Past a limit you get
429 with `Retry-After`.
G-code over 512 MiB is refused.

The proxy in front of the servers waits 100 seconds for an answer, waiting
for a slot included, and answers 524 after that. Most slices take seconds;
for a very large or detailed model, slice it in parts or try again when the
servers are less busy. A job endpoint for long slices is planned.

## Errors

Every error is [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) problem
details (`application/problem+json`), with its reason in `code` and in the
`X-Melt-Error` header, and a message to show a person in `detail`.

| Status | `code` | What to do |
|---|---|---|
| 400 | `bad-request`, `out-of-range`, `bad-model`, `no-engine` | Fix the request |
| 401 | `signed-out` | The key is missing, wrong or revoked |
| 402 | `payment-required` | Free credit used with no payment method, a failed payment, or the spending cap reached: check your billing |
| 413 | `too-large` | The model is over 100 MiB |
| 422 | `no-output`, `engine-failed` | The model could not be sliced (often: outside the print volume) |
| 429 | `rate-limited` | Try again after `Retry-After` seconds |
| 503 | `busy` | Try again after `Retry-After` seconds |
| 504 | `timed-out` | The slice took too long |

## Versions

Within `/v1`, changes only add: new optional parameters, headers or error
codes. Ignore what you do not know. Anything that would break a working
client comes as `/v2`, announced ahead.
