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.
Moving from v1? The request is the same, and results are in output. See what changed for the other endpoints.
Create a Model Edit task
Creates a Model Edit task and returns 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.
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 asmodel_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_urlfile over 4,000,000 faces returns400. Aninput_task_idmodel over the other two limits returns400. Amodel_urlfile over them, or an input task whose size Meshy has no record of, fails the task with the messageThe source model is too large to edit, and Meshy refunds its credits. - Watertight: a
model_urlfile, or the result of a Repair Printability task, must be a closed surface with no holes. Amodel_urlfile that isn't returns400. To fix it, run Repair Printability on it, then send that task'sidasinput_task_id. A Repair Printability task whose model still has holes returns400, and Meshy can't edit that model. A model whose shape Meshy can't measure also returns400.
A task costs 20 credits. Meshy charges them when it creates the task, and refunds them if the task fails. See Pricing.
Request
# 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"]
}'
Response
{
"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
}
Parameters
- Name
- input_task_id
- Type
- string
- Required
- Description
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 statusSUCCEEDED. 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 withshould_texture: false, made withmeshy-6or a Meshy 7 model, such asmeshy-7.1orlatest - A Remesh task made with
input_task_idfrom 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-t2andmeshy-t2.5), andgeometry_resolution: "4k"models return400. A task of another kind, such as Retexture or a Text to 3D task made in one call, returns400too, except a Relief task, which returns403.- A Text to 3D preview task (
- Name
- model_url
- Type
- string
- Required
- Description
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 bothinput_task_idandmodel_urlreturns400.The model must be a GLB file of at most 400 MB from an
httporhttpsURL whose path ends in.glb, or 100 MB as a data URI. It must not use Draco compression. To edit another format, run Convert to GLB first, download the GLB, and send it asmodel_url.
- Name
- prompt
- Type
- string
- Required
- Description
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 returns400.To change color or material, use Retexture.
- Name
- selection_face_indices
- Type
- integer[]
- Description
The faces around which to make the change, as indices of the model's triangles. For how Meshy numbers the faces, see Select faces. Leave it out to let any part of the model change.
Send 1 to 500,000 indices, each from
0to 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 returns400.
- Name
- reference_image_urls
- Type
- string[]
- Description
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 returns400.
Returns
202 Accepted with 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 TasksRetry-After: how many seconds to wait before you first read it
Failure modes
- Name
400 - Bad Request- Description
The request can't run. For example:
- Neither
input_task_idnormodel_urlwas sent, orpromptis only spaces. The code isparameter_missing. - Both
input_task_idandmodel_urlwere sent. The code isparameters_conflict. - The request has a parameter the endpoint doesn't take. The code is
parameter_unknown. - A value breaks a field rule:
promptis missing or over 600 characters,selection_face_indiceshas more than 500,000 indices or a negative one, or there are more than 5reference_image_urls. The code isrequest_invalid, and the message names each problem. - The selection can't be used. The code is
parameter_out_of_range. This covers theseselection_face_indicesproblems:- 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 describes. - Faces that cover no part of the model Meshy can change. Select a larger area.
- The
model_urlfile has holes, a texture, or more than 4,000,000 faces, or Meshy can't read or measure it. The code isinput_file_invalid, and the message names the problem, for examplemodel_url: the model is not watertight; repair it with POST /openapi/v2/print/repair first. - The
input_task_idmodel 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 isinput_task_unsupported, for example with the messageModel editing requires an untextured model. If Meshy can't read the input task's GLB, the code isinput_file_invalid. - The
input_task_idRepair Printability task's model still has holes, or Meshy can't measure it. The code isinput_task_unsupported, for example with the messageinput_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 isinput_task_expired, and the message isMissing model file. Create the input task again. - Meshy couldn't download
model_urlor areference_image_urlsimage. The code isinput_download_failed. - A
reference_image_urlsimage is larger than 20 MB, or Meshy can't read it. The code isinput_file_invalid.
The error message says which problem it found. See Errors.
- Neither
- Name
401 - Unauthorized- Description
The API key is missing or invalid. Check the
Authorizationheader.
- Name
402 - Payment Required- Description
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.
- Name
403 - Forbidden- Description
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_idis a bas-relief model, which this endpoint can't edit. The code isinput_task_unsupported. Send a different model.
- Content moderation blocked the prompt or a reference image. The code starts with
- Name
404 - Not Found- Description
One of these applies:
input_task_iddoesn't match any of your tasks. The code isinput_task_not_found.- Meshy removed the input task after its retention period. The code is
input_task_expired. Create the input task again.
- Name
429 - Too Many Requests- Description
One of these limits was reached:
- Meshy is converting too many selections. The code is
rate_limit_exceeded, and the message isSelection 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.
- Meshy is converting too many selections. The code is
- Name
503 - Service Unavailable- Description
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.
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.
Select faces with trimesh
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 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
faceIndexfrom a raycast hit on a model thatGLTFLoaderloads.
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:
- 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.
- Within a mesh, each primitive whose mode is
TRIANGLES, in order. Meshy doesn't number other primitives, such as triangle strips. - 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. An edited model usually has more triangles than Rigging takes, so run Remesh on it before you rig it.
Get the result
Read Model Edit tasks the same way as every other v2 task, through the Tasks routes. To list only Model Edit tasks, filter by type=model-edit.
| To | Call |
|---|---|
| Get one task | GET /openapi/v2/tasks/{id} |
| Wait for updates | GET /openapi/v2/tasks/{id}/stream or a webhook |
| List your tasks | GET /openapi/v2/tasks?type=model-edit |
| Delete a task | DELETE /openapi/v2/tasks/{id} |
Model Edit output
When the task succeeds, output holds these fields. The rest of 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.
Succeeded Model Edit task
{
"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=***"
}
}
- Name
- model_urls
- Type
- object
- Description
Signed URL to the edited model, under the
glbkey. The model has no texture, and its faces are numbered anew.
- Name
- thumbnail_url
- Type
- string
- Description
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: the prompt doesn't change the model's shapemodel_edit_selection_failed: Meshy couldn't tell which part of the model to change
See Errors.