> **Reading as an AI agent?** This is the Markdown version of https://docs.meshy.ai/api/v2/retexture, 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

---

# Retexture API

Generate new textures for an existing 3D model from a text prompt or a reference image.

> **Note:** Moving from v1? The main changes for Retexture:
>   * `texture_model` replaces `ai_model`, and every request sends it. It takes `meshy-7`, `meshy-n1`, or `meshy-6-lite`.
>   * `texture_prompt` and `texture_image_url` replace `text_style_prompt` and `image_style_url`. A request with the old names returns `400`.
>   * `uv_mode` replaces `enable_original_uv`, and keeps usable UVs by default.
>   * `hd_texture` returns `400`. Send `"texture_resolution": "4k"` for 4K textures.
>   * Uploads, and models that get new UVs, keep their size.
>   * `target_formats` defaults to GLB.
>   * Results are in `output`.
>
>   See [what changed for Retexture](/api/migrate-to-v2/reference#retexture).

---

## POST /openapi/v2/retexture -- Create a Retexture task

Creates a Retexture task and returns the [task object](https://docs.meshy.ai/api/v2/tasks.md#the-task-object). The task runs in the background. To read its result, see [Get the result](#get-the-result). For how long a task usually takes, see [Processing times](/api/task-lifecycle#processing-times).

### Parameters

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

  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 status `SUCCEEDED`. 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).

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

  Required unless you send `input_task_id`. The model to texture, as a public URL or a data URI. Sending both `input_task_id` and `model_url` returns `400`.

  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 returns `400`.

  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](/api/migrate-to-v2/reference#model-size).

Send one of these three texture inputs. Sending none, or more than one, returns `400`.

  - `texture_prompt` · *string* · **required**

  Required unless you send `texture_image_url` or `multiview_image_urls`. Text that describes the new texture, up to 800 characters. Longer text returns `400`. With `meshy-n1`, sending it returns `400`.

  - `texture_image_url` · *string* · **required**

  Required unless you send `texture_prompt` or `multiview_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. With `meshy-n1`, Meshy treats the image as the front view.

  The image must be a JPG, JPEG, PNG, or WebP file of at most 20 MB, and at least 32 pixels on each side.

  - `multiview_image_urls` · *string[]* · **required**

  Required unless you send `texture_prompt` or `texture_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 as `texture_image_url`. An empty array, or more than four images, returns `400`.

  `multiview_image_urls` needs `texture_model` of `meshy-7` or `meshy-n1`. With `meshy-6-lite`, it returns `400`.

  - `texture_model` · *string* · **required**

  The model that generates the texture.

  Available values:
  * `meshy-7`: Meshy 7, with PBR maps, a text prompt, and textures up to 8K
  * `meshy-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_model` returns `400`, and so does any other value. The texture model doesn't change the credit cost. See [Texture models](https://docs.meshy.ai/api/v2/image-to-3d.md#texture-models).

  - `uv_mode` · *string* · default: `auto`

  How to handle the model's UV layout.

  Available 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 with [`model_insufficient_uv`](https://docs.meshy.ai/api/v2/errors.md#model-insufficient-uv). To get new UVs instead, use `auto` or `regenerate`.
  * `regenerate`: always generate new UVs.

  A model with no UVs gets new ones in every mode.

  With `input_task_id` and kept UVs, the mesh keeps its size and position. Otherwise, the mesh keeps its size, and Meshy centers it.

  - `enable_pbr` · *boolean* · default: `false`

  Whether to also generate metallic, roughness, and normal maps. `false` generates only the base color texture. With `meshy-n1`, `true` returns `400`.

  - `texture_resolution` · *string* · default: `2k`

  Size of the base color texture.

  Available values:
  * `2k`
  * `4k`
  * `8k`

  With `meshy-6-lite` or `meshy-n1`, `4k` and `8k` return `400`.

  - `remove_lighting` · *boolean* · default: `true`

  Whether to remove highlights and shadows from the base color texture. The texture models that `texture_model` takes don't use this setting, so Meshy ignores it.

  - `target_formats` · *string[]* · default: `["glb"]`

  The file formats to generate. Meshy generates only the formats you list.

  Available values:
  * `glb`
  * `obj`
  * `fbx`
  * `stl`
  * `usdz`
  * `3mf`

  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_height` or `resize_longest_side`, keep their own size. See [Model size](/api/migrate-to-v2/reference#model-size).

  - `thumbnail_resolution` · *integer* · default: `512`

  The width and height, in pixels, of the task's preview images: `512` or `1024`. It applies to `output.thumbnail_url` and to any optional preview you request. Any other value 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`.

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
  * Both `input_task_id` and `model_url` were 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_model` is missing or isn't a supported value
  * `multiview_image_urls` was sent without `texture_model` of `meshy-7` or `meshy-n1`
  * `meshy-n1` was sent with `texture_prompt`, `enable_pbr: true`, or a `texture_resolution` of `4k` or `8k`
  * With `meshy-n1`, the 3D model has more than 7,999,999 triangles. Reduce the triangle count, or use another `texture_model`.
  * With `meshy-n1`, the `model_url` file 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 the `model_url` file 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_resolution` isn'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](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 an input image. Change the input, then retry.
  * `input_task_id` is a bas-relief model, which this endpoint can't retexture. The message is `This model type does not support this operation`. Send a different model.

  - `404 - Not Found`

  `input_task_id` doesn't match any of your tasks.

  - `429 - Too Many Requests`

  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.

**cURL**

```bash
# Retexture a model file from a text prompt: a textured GLB
curl https://api.meshy.ai/openapi/v2/retexture \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "texture_model": "meshy-7",
    "texture_prompt": "weathered bronze with green patina"
  }'

# Retexture a Meshy task from a reference image, keep its UVs, add PBR maps and an FBX
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": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "texture_model": "meshy-7",
    "texture_image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    "uv_mode": "preserve",
    "enable_pbr": true,
    "target_formats": ["glb", "fbx"]
  }'

# Retexture a model file with Meshy N1 from front and back views: a base color texture only
curl https://api.meshy.ai/openapi/v2/retexture \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "texture_model": "meshy-n1",
    "multiview_image_urls": [
      "<your front view image URL or data URI>",
      "<your back view image URL or data URI>"
    ]
  }'
```

```javascript
// Retexture a model file from a text prompt: a textured GLB
const response = await fetch("https://api.meshy.ai/openapi/v2/retexture", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MESHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model_url: "https://cdn.meshy.ai/model/example_model_2.glb",
    texture_model: "meshy-7",
    texture_prompt: "weathered bronze with green patina",
  }),
});
const task = await response.json();
console.log(task.id, task.status);
```

```python
import os
import requests

# Retexture a model file from a text prompt: a textured GLB
response = requests.post(
    "https://api.meshy.ai/openapi/v2/retexture",
    headers={"Authorization": f"Bearer {os.environ['MESHY_API_KEY']}"},
    json={
        "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
        "texture_model": "meshy-7",
        "texture_prompt": "weathered bronze with green patina",
    },
)
response.raise_for_status()
task = response.json()
print(task["id"], task["status"])
```

**Response**

```json
{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "retexture",
  "status": "PENDING",
  "progress": 0,
  "created_at": 1790640079880,
  "started_at": null,
  "finished_at": null,
  "expires_at": null,
  "preceding_tasks": 3,
  "consumed_credits": 10,
  "task_error": null,
  "input": {
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "texture_model": "meshy-7",
    "texture_prompt": "weathered bronze with green patina"
  },
  "output": null
}
```

---

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

| 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=retexture`](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) |

---

## Retexture 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`.

  - `model_urls` · *object*

  Signed URLs to the generated files, one per format in `target_formats`, keyed by format. An `obj` with a base color texture also gets an `mtl` key, with the URL of its material file.

  - `thumbnail_url` · *string*

  Signed URL to a PNG preview of the retextured model, with a transparent background.

  - `texture_urls` · *array*

  One item per texture set, with a signed URL for each of these maps:
  * `base_color`
  * `metallic`
  * `roughness`
  * `normal`
  * `metallic_roughness`
  * `emission`

  A map that wasn't produced is `null`.

**Succeeded Retexture task**

```json
{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "retexture",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1790640079880,
  "started_at": 1790640079892,
  "finished_at": 1790640141381,
  "expires_at": 1790899341381,
  "preceding_tasks": 0,
  "consumed_credits": 10,
  "task_error": null,
  "input": {
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "texture_model": "meshy-7",
    "texture_prompt": "weathered bronze with green patina"
  },
  "output": {
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/output/model.glb?Expires=***"
    },
    "thumbnail_url": "https://assets.meshy.ai/***/output/preview.png?Expires=***",
    "texture_urls": [
      {
        "base_color": "https://assets.meshy.ai/***/output/texture_0.png?Expires=***",
        "metallic": null,
        "roughness": null,
        "normal": null,
        "metallic_roughness": null,
        "emission": null
      }
    ]
  }
}
```
