Retexture API
Generate new textures for an existing 3D model from a text prompt or a reference image.
Moving from v1? The main changes for Retexture:
texture_modelreplacesai_model, and every request sends it. It takesmeshy-7,meshy-n1, ormeshy-6-lite.texture_promptandtexture_image_urlreplacetext_style_promptandimage_style_url. A request with the old names returns400.uv_modereplacesenable_original_uv, and keeps usable UVs by default.hd_texturereturns400. Send"texture_resolution": "4k"for 4K textures.- Uploads, and models that get new UVs, keep their size.
target_formatsdefaults to GLB.- Results are in
output.
Create a Retexture task
Creates a Retexture task and returns the task object. The task runs in the background. To read its result, see Get the result. For how long a task usually takes, see Processing times.
curl https://api.meshy.ai/openapi/v2/retexture \
-X POST \
-H "Authorization: Bearer ${MESHY_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "01a1aeae-1d29-72f0-96ed-0ba2bda780ec",
"texture_prompt": "gingerbread cookie with white icing details",
"texture_model": "meshy-7"
}'Parameters
- Name
- input_task_id
- Type
- string
- Required
- Description
Required unless you send
model_url. The ID of a task that produced a 3D model to texture, for example a Text to 3D, Image to 3D, Remesh, or Retexture task. The task must be one you created with the API and have the statusSUCCEEDED. Meshy textures the task's GLB.With
meshy-n1, the task's model can have at most 7,999,999 faces, counted as triangles (a quad counts as 2).
- Name
- model_url
- Type
- string
- Required
- Description
Required unless you send
input_task_id. The model to texture, as a public URL or a data URI. Sending bothinput_task_idandmodel_urlreturns400.The model must be a GLB, glTF, OBJ, FBX, or STL file of at most 400 MB from a URL, or 100 MB as a data URI. A data URI must hold a GLB or glTF file (
data:model/gltf-binary;base64,...). A larger file returns400.A file over 100 MB must also follow these rules, or the request returns
400:- A GLB, glTF, FBX, or OBJ file can have at most 10,000,000 faces. Meshy counts faces as triangles, so a quad counts as 2, and a mesh drawn more than once counts once per copy.
- An FBX file must be binary FBX 7.1 or newer.
- A GLB or glTF file must not use Draco compression.
With
meshy-n1, the model can have at most 7,999,999 faces, counted as triangles (a quad counts as 2), whatever its file size.The result keeps the file's size. Meshy returns it as one centered mesh, without rigs or animations, so the model doesn't keep its position. See Model size.
Send one of these three texture inputs. Sending none, or more than one, returns 400.
- Name
- texture_prompt
- Type
- string
- Required
- Description
Required unless you send
texture_image_urlormultiview_image_urls. Text that describes the new texture, up to 800 characters. Longer text returns400. Withmeshy-n1, sending it returns400.Try and previewSend this or
texture_image_urlormultiview_image_urls. Picking a value here clears the others.
- Name
- texture_image_url
- Type
- string
- Required
- Description
Required unless you send
texture_promptormultiview_image_urls. An image whose style the texture follows, as a public URL or a data URI (data:image/png;base64,...). The texture might not fit well when the object in the image has a very different shape from the model. Withmeshy-n1, Meshy treats the image as the front view.Try and previewSend this or
texture_promptormultiview_image_urls. Picking a value here clears the others.The image must be a JPG, JPEG, PNG, or WebP file of at most 20 MB, and at least 32 pixels on each side.
- Name
- multiview_image_urls
- Type
- string[]
- Required
- Description
Required unless you send
texture_promptortexture_image_url. One to four reference images of the same object. The first image is the main (front) view. The order of the other views (left, back, right) doesn't matter. Each image follows the same format and size rules astexture_image_url. An empty array, or more than four images, returns400.multiview_image_urlsneedstexture_modelofmeshy-7ormeshy-n1. Withmeshy-6-lite, it returns400.
- Name
- texture_model
- Type
- string
- Required
- Description
The model that generates the texture.
Available values:
meshy-7: Meshy 7, with PBR maps, a text prompt, and textures up to 8Kmeshy-n1: Meshy N1, a 2K base color texture from reference images only. No text prompt, no PBR maps, no 4K or 8K. Up to 7,999,999 faces.meshy-6-lite: Meshy 6 Lite, a 2K texture
A request without
texture_modelreturns400, and so does any other value. The texture model doesn't change the credit cost. See Texture models.
- Name
- uv_mode
- Type
- string
- default auto
- Description
How to handle the model's UV layout.
Try and previewAvailable values:
auto: keep the model's UVs when they're usable, and generate new ones otherwise.preserve: keep the model's UVs. If they all fit in a box smaller than 5% of the UV square, the task fails withmodel_insufficient_uv. To get new UVs instead, useautoorregenerate.regenerate: always generate new UVs.
A model with no UVs gets new ones in every mode.
With
input_task_idand kept UVs, the mesh keeps its size and position. Otherwise, the mesh keeps its size, and Meshy centers it.
- Name
- enable_pbr
- Type
- boolean
- default false
- Description
Whether to also generate metallic, roughness, and normal maps.
falsegenerates only the base color texture. Withmeshy-n1,truereturns400.Try and preview
- Name
- texture_resolution
- Type
- string
- default 2k
- Description
Size of the base color texture.
Try and previewAvailable values:
2k4k8k
With
meshy-6-liteormeshy-n1,4kand8kreturn400.
- Name
- remove_lighting
- Type
- boolean
- default true
- Description
Whether to remove highlights and shadows from the base color texture. The texture models that
texture_modeltakes don't use this setting, so Meshy ignores it.
- Name
- target_formats
- Type
- string[]
- default ["glb"]
- Description
The file formats to generate. Meshy generates only the formats you list.
Available values:
glbobjfbxstlusdz3mf
For a model Meshy generated, Meshy scales STL and 3MF files down to at most 150 mm on the longest side. Uploaded models, and models you resized with
resize_heightorresize_longest_side, keep their own size. See Model size.
- Name
- thumbnail_resolution
- Type
- integer
- default 512
- Description
The width and height, in pixels, of the task's preview images:
512or1024. It applies tooutput.thumbnail_urland to any optional preview you request. Any other value returns400.
Returns
202 Accepted with the task object. The task starts as PENDING, with your request in input and output set to null.
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 - Both
input_task_idandmodel_urlwere sent - No texture input, or more than one, was sent
- A parameter Retexture doesn't define was sent, such as the v1 name
text_style_prompt texture_modelis missing or isn't a supported valuemultiview_image_urlswas sent withouttexture_modelofmeshy-7ormeshy-n1meshy-n1was sent withtexture_prompt,enable_pbr: true, or atexture_resolutionof4kor8k- With
meshy-n1, the 3D model has more than 7,999,999 triangles. Reduce the triangle count, or use anothertexture_model. - With
meshy-n1, themodel_urlfile is too complex for Meshy to count its triangles. Reduce the triangle count, then send the file again. - With
meshy-n1, counting the triangles of themodel_urlfile took too long. Retry, or reduce the model's size. - The input task hasn't succeeded
- The model or image can't be downloaded or is too large
- A model file over 100 MB has too many faces (
model has too many faces: <N> faces, the limit for files over 100 MB is <limit>) - An FBX file over 100 MB is ASCII (
ASCII FBX files over 100 MB are not supported; use binary FBX or GLB) - A file over 100 MB has a header that can't be read, for example a Draco-compressed GLB or glTF, or a binary FBX older than 7.1 (
invalid model file content) - A file over 100 MB has a header too complex to check (
model header is too complex to check for files over 100 MB) texture_resolutionisn't available for the model
With
meshy-n1, a model that Meshy can't check before the task starts, such as an STL file, isn't refused here. If it has more than 7,999,999 triangles, the task fails, and Meshy refunds its credits.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 an input image. Change the input, then retry.
input_task_idis a bas-relief model, which this endpoint can't retexture. 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.
- Name
429 - Too Many Requests- Description
One of these limits was reached:
- 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.
- You sent too many requests. Wait the number of seconds in
Get the result
Read Retexture tasks the same way as every other v2 task, through the Tasks routes. To list only Retexture tasks, filter by type=retexture.
| 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=retexture |
| Delete a task | DELETE /openapi/v2/tasks/{id} |
Retexture 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.
curl https://api.meshy.ai/openapi/v2/tasks/01a1af10-e500-71b1-baf3-5ab738f08780 \
-H "Authorization: Bearer ${MESHY_API_KEY}"Loading…- Name
- model_urls
- Type
- object
- Description
Signed URLs to the generated files, one per format in
target_formats, keyed by format. Anobjwith a base color texture also gets anmtlkey, with the URL of its material file.
- Name
- thumbnail_url
- Type
- string
- Description
Signed URL to a PNG preview of the retextured model, with a transparent background.
- Name
- texture_urls
- Type
- array
- Description
One item per texture set, with a signed URL for each of these maps:
base_colormetallicroughnessnormalmetallic_roughnessemission
A map that wasn't produced is
null.