> **Reading as an AI agent?** This is the Markdown version of https://docs.meshy.ai/api/v2/model-edit, part of the Meshy API v2 docs.
>
> - v2 docs index: https://docs.meshy.ai/api/v2/llms.txt
> - All v2 pages in one file: https://docs.meshy.ai/api/v2/llms-full.txt
> - OpenAPI spec for v2: https://docs.meshy.ai/api/v2/openapi.yaml

---

# Model Edit API

Change the shape of a 3D model by describing the change in a sentence. Edit the whole model, or select the faces around which the change happens.

> **Note:** Moving from v1? The request is the same, and results are in `output`. See [what changed for the other endpoints](/api/migrate-to-v2/reference#other-endpoints).

---

## POST /openapi/v2/model-edit -- Create a Model Edit task

Creates a Model Edit task and returns the [task object](https://docs.meshy.ai/api/v2/tasks.md#the-task-object). The task reshapes a model as `prompt` describes, and returns an untextured GLB file with a preview image. With `selection_face_indices`, the change stays around the faces you select. Without it, any part of the model can change. To read the result, see [Get the result](#get-the-result).

Meshy checks the model while it handles your request, so a model it can't edit returns `400` before Meshy creates a task. The model must meet all of these requirements:
* **Source**: a task listed under `input_task_id`, or a GLB file you send as `model_url`
* **Texture**: none. A textured model returns `400`.
* **Size**: at most 4,000,000 faces and 4,000,000 vertices, and at most 134,217,728 bytes (128 MiB) of geometry, counted as 12 bytes per vertex plus 24 bytes per face. A `model_url` file over 4,000,000 faces returns `400`. An `input_task_id` model over the other two limits returns `400`. A `model_url` file over them, or an input task whose size Meshy has no record of, fails the task with the message `The source model is too large to edit`, and Meshy refunds its credits.
* **Watertight**: a `model_url` file, or the result of a Repair Printability task, must be a closed surface with no holes. A `model_url` file that isn't returns `400`. To fix it, run [Repair Printability](https://docs.meshy.ai/api/v2/repair-printability.md) on it, then send that task's `id` as `input_task_id`. A Repair Printability task whose model still has holes returns `400`, and Meshy can't edit that model. A model whose shape Meshy can't measure also returns `400`.

A task costs 20 credits. Meshy charges them when it creates the task, and refunds them if the task fails. See [Pricing](/api/pricing).

### Parameters

  - `input_task_id` · *string* · **required**

  Required unless you send `model_url`. The ID of a task whose GLB to edit. The task must be one you created with the API and have the status `SUCCEEDED`. It must be one of these:
  * A Text to 3D preview task (`mode: "preview"`), or an Image to 3D or Multi-Image to 3D task with `should_texture: false`, made with `meshy-6` or a Meshy 7 model, such as `meshy-7.1` or `latest`
  * A Remesh task made with `input_task_id` from a task in the first item, if it has no texture
  * A Repair Printability task
  * An earlier Model Edit task

  Meshy 6 Lite, Smart Topology (`meshy-t2` and `meshy-t2.5`), and `geometry_resolution: "4k"` models return `400`. A task of another kind, such as Retexture or a Text to 3D task made in one call, returns `400` too, except a Relief task, which returns `403`.

  - `model_url` · *string* · **required**

  Required unless you send `input_task_id`. The model to edit, as a public URL or a data URI (`data:model/gltf-binary;base64,...`). Sending both `input_task_id` and `model_url` returns `400`.

  The model must be a GLB file of at most 400 MB from an `http` or `https` URL whose path ends in `.glb`, or 100 MB as a data URI. It must not use Draco compression. To edit another format, run [Convert](https://docs.meshy.ai/api/v2/convert.md) to GLB first, download the GLB, and send it as `model_url`.

  - `prompt` · *string* · **required**

  The change to make, in one sentence, up to 600 characters. Describe a change of shape, such as adding, removing, enlarging, or reshaping a part, for example `Give the dog a pair of boots`. Longer text returns `400`.

  To change color or material, use [Retexture](https://docs.meshy.ai/api/v2/retexture.md).

  - `selection_face_indices` · *integer[]*

  The faces around which to make the change, as indices of the model's triangles. For how Meshy numbers the faces, see [Select faces](#select-faces). Leave it out to let any part of the model change.

  Send 1 to 500,000 indices, each from `0` to the model's face count minus 1. Order and repeats don't matter. An empty array, an index past the last face, or a selection too small to change returns `400`.

  - `reference_image_urls` · *string[]*

  Up to 5 images that show what the change should look like, each as a public URL or a data URI (`data:image/png;base64,...`). Each image must be a PNG, JPEG, or WebP file of at most 20 MB. More than 5 images returns `400`.

### Returns

`202 Accepted` with the [task object](https://docs.meshy.ai/api/v2/tasks.md#the-task-object). The task starts as `PENDING`, with your request in `input` and `output` set to `null`. `input.selection_face_indices` holds the indices as you sent them.

Two response headers help you read the task:
* `Location`: the task's URL on [Tasks](https://docs.meshy.ai/api/v2/tasks.md#how-a-task-runs)
* `Retry-After`: how many seconds to wait before you first read it

### Failure modes

  - `400 - Bad Request`

  The request can't run. For example:
  * Neither `input_task_id` nor `model_url` was sent, or `prompt` is only spaces. The code is `parameter_missing`.
  * Both `input_task_id` and `model_url` were sent. The code is `parameters_conflict`.
  * The request has a parameter the endpoint doesn't take. The code is `parameter_unknown`.
  * A value breaks a field rule: `prompt` is missing or over 600 characters, `selection_face_indices` has more than 500,000 indices or a negative one, or there are more than 5 `reference_image_urls`. The code is `request_invalid`, and the message names each problem.
  * The selection can't be used. The code is `parameter_out_of_range`. This covers these `selection_face_indices` problems:
* An empty array
* An index that isn't a face of the model, such as `selection_face_indices: face 5000 is out of range: the model has 3322 faces`. Number the faces as [Select faces](#select-faces) describes.
* Faces that cover no part of the model Meshy can change. Select a larger area.
  * The `model_url` file has holes, a texture, or more than 4,000,000 faces, or Meshy can't read or measure it. The code is `input_file_invalid`, and the message names the problem, for example `model_url: the model is not watertight; repair it with POST /openapi/v2/print/repair first`.
  * The `input_task_id` model has a texture or more than 4,000,000 faces, is over the size limits, or was made in a way this endpoint doesn't edit. The code is `input_task_unsupported`, for example with the message `Model editing requires an untextured model`. If Meshy can't read the input task's GLB, the code is `input_file_invalid`.
  * The `input_task_id` Repair Printability task's model still has holes, or Meshy can't measure it. The code is `input_task_unsupported`, for example with the message `input_task_id: the repaired model is still not watertight, so it cannot be edited`.
  * The input task hasn't succeeded. The code is `input_task_not_ready`.
  * The input task's model file is gone, for example after its `expires_at`. The code is `input_task_expired`, and the message is `Missing model file`. Create the input task again.
  * Meshy couldn't download `model_url` or a `reference_image_urls` image. The code is `input_download_failed`.
  * A `reference_image_urls` image is larger than 20 MB, or Meshy can't read it. The code is `input_file_invalid`.

  The error message says which problem it found. See [Errors](https://docs.meshy.ai/api/v2/errors.md#request-errors).

  - `401 - Unauthorized`

  The API key is missing or invalid. Check the `Authorization` header.

  - `402 - Payment Required`

  One of these applies:
  * The account doesn't have enough credits.
  * The account reached a credit limit.
  * The account is on the free plan.

  Check your credits and plan, then retry.

  - `403 - Forbidden`

  One of these applies:
  * Content moderation blocked the prompt or a reference image. The code starts with `moderation_blocked`. Change the input, then retry.
  * `input_task_id` is a bas-relief model, which this endpoint can't edit. The code is `input_task_unsupported`. Send a different model.

  - `404 - Not Found`

  One of these applies:
  * `input_task_id` doesn't match any of your tasks. The code is `input_task_not_found`.
  * Meshy removed the input task after its retention period. The code is `input_task_expired`. Create the input task again.

  - `429 - Too Many Requests`

  One of these limits was reached:
  * Meshy is converting too many selections. The code is `rate_limit_exceeded`, and the message is `Selection processing is busy; try again shortly`. Wait a few seconds, then retry.
  * You sent too many requests. Wait the number of seconds in `Retry-After`, then retry.
  * Too many of your tasks are queued or running. Wait for some to finish, then retry.
  * On an unlimited plan with no credits left, you reached the number of tasks that can run without credits. Wait for a task to finish, or add credits.

  - `503 - Service Unavailable`

  Meshy couldn't check whether the model is watertight. The code is `service_unavailable`. Wait a few seconds, then retry.

Meshy charges nothing for a request that returns an error.

**cURL**

```bash
# Edit the faces you selected on a Meshy task's model
curl https://api.meshy.ai/openapi/v2/model-edit \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "prompt": "Add a short horn to the top of the head",
    "selection_face_indices": [1204, 1205, 1206, 1311, 1312]
  }'

# Edit the whole model from a public GLB URL, with a reference image
curl https://api.meshy.ai/openapi/v2/model-edit \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "model_url": "https://example.com/models/dog.glb",
    "prompt": "Give the dog a pair of boots",
    "reference_image_urls": ["https://example.com/images/boots.png"]
  }'
```

```javascript
// Edit the faces you selected on a Meshy task's model
const response = await fetch("https://api.meshy.ai/openapi/v2/model-edit", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MESHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    input_task_id: "018a210d-8ba4-705c-b111-1f1776f7f578",
    prompt: "Add a short horn to the top of the head",
    selection_face_indices: [1204, 1205, 1206, 1311, 1312],
  }),
});
const task = await response.json();
console.log(task.id, task.status);
```

```python
import os
import requests

# Edit the faces you selected on a Meshy task's model
response = requests.post(
    "https://api.meshy.ai/openapi/v2/model-edit",
    headers={"Authorization": f"Bearer {os.environ['MESHY_API_KEY']}"},
    json={
        "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
        "prompt": "Add a short horn to the top of the head",
        "selection_face_indices": [1204, 1205, 1206, 1311, 1312],
    },
)
response.raise_for_status()
task = response.json()
print(task["id"], task["status"])
```

**Response**

```json
{
  "id": "019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07",
  "type": "model-edit",
  "status": "PENDING",
  "progress": 0,
  "created_at": 1796421600000,
  "started_at": null,
  "finished_at": null,
  "expires_at": null,
  "preceding_tasks": 1,
  "consumed_credits": 20,
  "task_error": null,
  "input": {
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "prompt": "Add a short horn to the top of the head",
    "selection_face_indices": [1204, 1205, 1206, 1311, 1312]
  },
  "output": null
}
```

---

## Select faces

`selection_face_indices` names faces by their index among the triangles of the GLB file that the task edits. That file is the `input_task_id` task's `output.model_urls.glb`, or your `model_url` file.

A model that Meshy generates is a single mesh, so face `i` is the triangle that indices `3i`, `3i + 1`, and `3i + 2` of its index buffer make.

### Get the indices from a 3D tool

A tool gives the same indices as Meshy when it keeps the file's triangle order. The following tools keep it for a single-mesh model:

* trimesh: load the file with `process=False`.
* Blender: import the file with the default glTF import settings.
* three.js: read `faceIndex` from a raycast hit on a model that `GLTFLoader` loads.

Any other tool that keeps the order gives the same indices. A step that changes the triangles renumbers the faces, for example merging triangles into quads, a game engine's mesh optimization, or exporting the file again.

### Files with more than one mesh

For a file with more than one mesh or primitive, Meshy numbers the triangles in this order:

1. The nodes of the file's default scene, depth first. Each node's own mesh comes before its children, and nodes come in the order the file lists them.
2. Within a mesh, each primitive whose mode is `TRIANGLES`, in order. Meshy doesn't number other primitives, such as triangle strips.
3. Within a primitive, its triangles in the order its index buffer stores them. A primitive without an index buffer makes a triangle of every three vertices, in order.

### How far an edit reaches

Meshy turns the selected faces into a grid of 16 × 16 × 16 cells over the model, the same way the model editor in the Meshy web app does. The edit works on those cells, so the change reaches about one sixteenth of the model's longest side around the faces you select, not only the faces themselves. Selecting one face selects its whole cell, so an edit can't target an area smaller than a cell. A selection that covers no cell returns `400`, so select a larger area.

Meshy regenerates the whole mesh, so the parts outside the selection aren't guaranteed to be identical to the input.

### Edit the result again

The edited model is a new mesh with new face indices. Before you edit it again, select the faces on the new model, then send the Model Edit task's `id` as `input_task_id`. An edit usually adds faces and vertices, so an edited model can be over the size limits even when its input wasn't.

You can also send the task's `id` as `input_task_id` to other endpoints, for example to texture the model with [Retexture](https://docs.meshy.ai/api/v2/retexture.md). An edited model usually has more triangles than [Rigging](https://docs.meshy.ai/api/v2/rigging.md) takes, so run [Remesh](https://docs.meshy.ai/api/v2/remesh.md) on it before you rig it.

**Select faces with trimesh**

```python
import os

import numpy as np
import requests
import trimesh

# Load the GLB as one mesh, keeping the file's face order
mesh = trimesh.load("model.glb", force="mesh", process=False)

# Select the faces whose center is in the top fifth of the model
# (glTF models are Y-up)
centers = mesh.triangles_center
top = mesh.bounds[1][1] - 0.2 * mesh.extents[1]
selection = np.flatnonzero(centers[:, 1] > top).tolist()

# A request takes 1 to 500,000 indices
assert 1 <= len(selection) <= 500_000, len(selection)

response = requests.post(
    "https://api.meshy.ai/openapi/v2/model-edit",
    headers={"Authorization": f"Bearer {os.environ['MESHY_API_KEY']}"},
    json={
        "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
        "prompt": "Add a short horn to the top of the head",
        "selection_face_indices": selection,
    },
)
response.raise_for_status()
print(response.json()["id"])
```

---

## Get the result
Read Model Edit tasks the same way as every other v2 task, through the [Tasks](https://docs.meshy.ai/api/v2/tasks.md) routes. To list only Model Edit tasks, filter by `type=model-edit`.

| To | Call |
| --- | --- |
| Get one task | [`GET /openapi/v2/tasks/{id}`](https://docs.meshy.ai/api/v2/tasks.md#get-a-task) |
| Wait for updates | [`GET /openapi/v2/tasks/{id}/stream`](https://docs.meshy.ai/api/v2/tasks.md#stream-a-task) or a [webhook](https://docs.meshy.ai/api/v2/webhooks.md) |
| List your tasks | [`GET /openapi/v2/tasks?type=model-edit`](https://docs.meshy.ai/api/v2/tasks.md#list-tasks) |
| Delete a task | [`DELETE /openapi/v2/tasks/{id}`](https://docs.meshy.ai/api/v2/tasks.md#delete-a-task) |

---

## Model Edit output
When the task succeeds, `output` holds these fields. The rest of the [task object](https://docs.meshy.ai/api/v2/tasks.md#the-task-object) is the same for every task type. The URLs in `output` stop working at `expires_at`. Meshy keeps the edited model for 3 days after the task finishes, like other task files. See [Asset retention](https://docs.meshy.ai/api/v2/asset-retention.md).

  - `model_urls` · *object*

  Signed URL to the edited model, under the `glb` key. The model has no texture, and its faces are numbered anew.

  - `thumbnail_url` · *string*

  Signed URL to a preview image of the edited model.

Model Edit output has no `texture_urls`.

A task that fails has a `task_error`. Two codes are specific to Model Edit:
* [`model_edit_no_shape_edit`](https://docs.meshy.ai/api/v2/errors.md#model-edit-no-shape-edit): the prompt doesn't change the model's shape
* [`model_edit_selection_failed`](https://docs.meshy.ai/api/v2/errors.md#model-edit-selection-failed): Meshy couldn't tell which part of the model to change

See [Errors](https://docs.meshy.ai/api/v2/errors.md#task-errors).

**Succeeded Model Edit task**

```json
{
  "id": "019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07",
  "type": "model-edit",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1796421600000,
  "started_at": 1796421605000,
  "finished_at": 1796421672000,
  "expires_at": 1796680872000,
  "preceding_tasks": 0,
  "consumed_credits": 20,
  "task_error": null,
  "input": {
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "prompt": "Add a short horn to the top of the head",
    "selection_face_indices": [1204, 1205, 1206, 1311, 1312]
  },
  "output": {
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/output/model.glb?Expires=***"
    },
    "thumbnail_url": "https://assets.meshy.ai/***/output/preview.png?Expires=***"
  }
}
```
