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.
Model Edit regenerates the model's geometry and returns an untextured GLB file with a preview image. To texture the edited model, send its task ID to the Retexture API.
Create a Model Edit task
Creates a Model Edit task, which reshapes a model as prompt describes. With selection_face_indices, the change stays around the faces you select. Without it, any part of the model can change.
Meshy checks the model while it handles your request, so a model it can't edit returns 400 before Meshy creates a task. The task then runs in the background, as described in Task lifecycle.
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/v1/model-edit \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"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/v1/model-edit \
-X POST \
-H "Authorization: Bearer ${YOUR_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
{
"result": "019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07"
}
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, or an Image to 3D or Multi-Image to 3D task with
should_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, returns400too, except a Relief task, which returns403.- A Text to 3D preview task, or an Image to 3D or Multi-Image to 3D task with
- 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. The result field of the response holds the ID of the new Model Edit task.
Failure modes
- Name
400 - Bad Request- Description
The request can't run. For example:
- Missing input: Neither
input_task_idnormodel_urlwas sent, orpromptis only spaces. - Invalid parameters: A value breaks a field rule.
promptis missing or longer than 600 characters,selection_face_indiceshas a negative index or more than 500,000 indices, or there are more than 5reference_image_urls. The message lists these rules:Invalid parameters: send a prompt of 1 to 600 characters, at most 500000 selection_face_indices of 0 or more, and at most 5 reference_image_urls. The v2 endpoint names each problem instead. See Model Edit API (v2). - Conflicting inputs: Both
input_task_idandmodel_urlwere sent. The message isProvide either input_task_id or model_url, not both. - Empty selection:
selection_face_indicesis an empty array. Leave it out to edit the whole model. - Face out of range: An index in
selection_face_indicesisn't a face of the model. For example, the message isselection_face_indices: face 5000 is out of range: the model has 3322 faces. Number the faces as Select faces describes. - Selection too small: The selected faces cover no part of the model that Meshy can change. Select a larger area.
- Not watertight: The
model_urlfile has holes. The message ismodel_url: the model is not watertight; repair it with POST /openapi/v1/print/repair first. Run Repair Printability on it, then send that task'sidasinput_task_id. - Still not watertight after repair: The
input_task_idRepair Printability task's model still has holes. The message isinput_task_id: the repaired model is still not watertight, so it cannot be edited. - Can't measure the model: Meshy can't measure the model's shape. For example, the message is
model_url: the model could not be measured, so it cannot be edited. - Textured model: The model has a texture. The message is
Model editing requires an untextured model. - Too many faces: The model has more than 4,000,000 faces.
- Model too large: The
input_task_idmodel is over the vertex or size limit. The message isThe source model is too large to edit. - Unreadable model: Meshy can't read the GLB file, for example because it uses Draco compression.
- Unsupported input task: The
input_task_idtask isn't one this endpoint edits, or hasn't succeeded. For example, the message isModel editing does not support Meshy 6 Lite models. - Input task files removed: Meshy deleted the
input_task_idtask's files after itsexpires_at. The message isMissing model file. Create the input task again. - Unreachable URL: Meshy can't download the
model_urlfile or areference_image_urlsimage. - Model file too large: The
model_urlfile is over 400 MB from anhttporhttpsURL, or over 100 MB as a data URI. - Unusable image: A
reference_image_urlsimage is larger than 20 MB, or Meshy can't read it.
Fix the request, then send it again. See Errors.
- Missing input: Neither
- Name
401 - Unauthorized- Description
The API key is missing or invalid. Check the
Authorizationheader.
- Name
402 - Payment Required- Description
For example:
- Insufficient credits: The account doesn't have enough credits for this task, or the account reached a credit limit. Check your credit balance, then retry.
- Free plan: Creating a task requires a paid plan. Upgrade your plan in your subscription settings, then retry.
- Name
403 - Forbidden- Description
One of these applies:
- Content moderation blocked the prompt or a reference image. Change the input, then retry.
input_task_idis a bas-relief model, which this endpoint can't edit. The message isThis model type does not support this operation. Send a different model.
- Name
404 - Not Found- Description
input_task_iddoesn't match any of your tasks. Check the task ID, then send the request again.
- Name
429 - Too Many Requests- Description
For example:
- Selection processing is busy: Meshy is converting too many selections. The message is
Selection processing is busy; try again shortly. Wait a few seconds, then retry. - Rate limit: You exceeded your rate limit, or you have too many pending tasks. Wait, then retry. See Rate limits.
- Selection processing is busy: Meshy is converting too many selections. The message is
- Name
503 - Service Unavailable- Description
Meshy couldn't check whether the model is watertight. The message is
Could not check whether the model is watertight; try again shortly. Wait a few seconds, then retry.
Meshy charges nothing for a request that returns an error. A task that Meshy created can still fail. For the reasons, see task_error in the Model Edit task object.
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 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 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/v1/model-edit",
headers={"Authorization": f"Bearer {YOUR_API_KEY}"},
json={
"input_task_id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"prompt": "Add a short horn to the top of the head",
"selection_face_indices": selection,
},
)
response.raise_for_status()
print(response.json())
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 a Model Edit task
Returns a Model Edit task by its ID.
Request
curl https://api.meshy.ai/openapi/v1/model-edit/019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
For an example response, see the example Model Edit task object.
Parameters
- Name
- id
- Type
- path
- Description
The task ID from the create response.
Returns
Delete a Model Edit task
Permanently deletes a Model Edit task, including its edited model. You can't undo a delete.
Request
curl https://api.meshy.ai/openapi/v1/model-edit/019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07 \
-X DELETE \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Task status
Deleting a PENDING task refunds the credits it used when you created it.
An IN_PROGRESS task can't be deleted. The request returns 409 Conflict,
and the task keeps running. Meshy doesn't refund a task that has started,
so deleting it would cost you both the credits and the result. Wait for it
to reach SUCCEEDED, FAILED, or CANCELED, then delete it.
Deleting a task in a final status (SUCCEEDED, FAILED, or CANCELED)
doesn't refund its credits.
List Model Edit tasks
Returns a list of your Model Edit tasks, newest first unless you set sort_by.
Request
curl "https://api.meshy.ai/openapi/v1/model-edit?page_num=1&page_size=10" \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Parameters
- Name
- page_num
- Type
- integer
- default 1
- Description
The page number to return, starting at
1.
- Name
- page_size
- Type
- integer
- default 10
- Description
The number of tasks per page, up to
100.
- Name
- sort_by
- Type
- string
- Description
The sort order.
Available values:
+created_at: oldest first-created_at: newest first
Returns
A list of Model Edit task objects. An empty page is an empty array.
Stream a Model Edit task
Streams a Model Edit task's updates as Server-Sent Events (SSE). To learn sooner that the task finished, use this endpoint instead of polling GET /openapi/v1/model-edit/:id.
Request
curl https://api.meshy.ai/openapi/v1/model-edit/019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-N
Parameters
- Name
- id
- Type
- path
- Description
The task ID from the create response.
Returns
A stream of Model Edit task objects as Server-Sent Events.
Each message event holds the full task object, in the same shape the Get endpoint returns. While the task is PENDING or IN_PROGRESS, its result fields don't have values yet. model_urls is empty, and thumbnail_url is "". To follow the task, watch status and progress.
The stream closes after the event of a task that reached SUCCEEDED, FAILED, or CANCELED. An error event ends the stream early, for example when the task isn't found.
The Model Edit task object
A Model Edit task object describes one edit of a 3D model. It holds the status, the progress, and the edited model when the task succeeds.
Example Model Edit Task Object
{
"id": "019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07",
"type": "model-edit",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07/output/model.glb?Expires=***"
},
"thumbnail_url": "https://assets.meshy.ai/***/tasks/019ad9e2-5b7c-7a41-9c3e-2f8d6b1a4e07/output/preview.png?Expires=***",
"texture_urls": null,
"progress": 100,
"status": "SUCCEEDED",
"created_at": 1796421600000,
"started_at": 1796421605000,
"finished_at": 1796421672000,
"expires_at": 1796680872000,
"task_error": null,
"consumed_credits": 20
}
- Name
- id
- Type
- string
- Description
The task ID. Treat it as an opaque string, and don't rely on its format.
- Name
- type
- Type
- string
- Description
The task type, always
model-edit.
- Name
- model_urls
- Type
- object
- Description
Signed download URLs for the edited model. Model Edit always returns a single
glbkey. The model has no texture, and its faces are numbered anew.
- Name
- thumbnail_url
- Type
- string
- Description
Signed download URL for a PNG preview image of the edited model.
- Name
- texture_urls
- Type
- array
- Description
Always
null. The edited model has no texture.
- Name
- progress
- Type
- integer
- Description
How much of the task is done, as a percentage from
0to100.
- Name
- status
- Type
- string
- Description
The task status, one of
PENDING,IN_PROGRESS,SUCCEEDED,FAILED, orCANCELED.
- Name
- preceding_tasks
- Type
- integer
- Description
The number of tasks ahead of this one in the queue. The value is meaningful only while the task is
PENDING. The field is left out when the value is0.
- Name
- created_at
- Type
- timestamp
- Description
Time the task was created, in Unix milliseconds.
- Name
- started_at
- Type
- timestamp
- Description
Time the task started, in Unix milliseconds. It's
0until the task starts.
- Name
- finished_at
- Type
- timestamp
- Description
Time the task finished, in Unix milliseconds. It's
0until the task finishes.
- Name
- expires_at
- Type
- timestamp
- Description
Time the signed download URLs expire, in Unix milliseconds. Meshy keeps the edited model for 3 days after the task finishes, so download it, or send the task to another endpoint, before then. See Asset retention.
- Name
- task_error
- Type
- object
- Description
The error details when the task fails, and
nullotherwise. 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.
- Name
- consumed_credits
- Type
- integer
- Description
The number of credits the task used, 20 for a Model Edit task. It's
0for aFAILEDtask, because Meshy refunds the credits when a task fails.