> **Reading as an AI agent?** This is the Markdown version of https://docs.meshy.ai/api/retexture.
>
> - Full docs index: https://docs.meshy.ai/llms.txt
> - Single-fetch full content: https://docs.meshy.ai/llms-full.txt
> - Tool-calling access via MCP server: https://docs.meshy.ai/api/ai

---
# Retexture API

Generate new textures for an existing 3D model from a text prompt or reference images. The model can come from another Meshy task or from a model file.

---

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

Creates a Retexture task. The task runs in the background. 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. If you send both, Meshy uses `input_task_id`.

  The model must be a GLB, glTF, OBJ, FBX, or STL file of at most 400 MB from an `http` or `https` URL, or 100 MB as a data URI. For a data URI, use the MIME type `application/octet-stream`, for example `data:application/octet-stream;base64,<your base64-encoded model data>`.

  A file over 100 MB must also follow these rules:
  * 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.

Send one of these three style inputs.

  - `text_style_prompt` · *string* · **required**

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

  - `image_style_url` · *string* · **required**

  Required unless you send `text_style_prompt` or `multiview_image_urls`. A 2D image whose style the texture follows, as a public URL or a data URI (`data:image/jpeg;base64,<your base64-encoded image data>`). If you send both `text_style_prompt` and `image_style_url`, Meshy uses `image_style_url`.

  The image must be a `.jpg`, `.jpeg`, `.png`, or `.webp` file of at most 20 MB, and at least 32 pixels on each side.

  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.

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

  Required unless you send `text_style_prompt` or `image_style_url`. One to four images of the same object from different views. The first image is the main (front) view. The order of the other views (left, back, right) doesn't matter. An empty array, or more than four images, returns `400`.

  Each image follows the same format and size rules as `image_style_url`, at most 20 MB per image. You can't combine `multiview_image_urls` with `text_style_prompt` or `image_style_url`.

  `multiview_image_urls` needs an explicit `ai_model` of `meshy-7` or `meshy-n1`. Any other `ai_model`, including the default `latest`, returns `400`.

  - `ai_model` · *string* · default: `latest`

  The AI model that generates the texture.

  Available values:
  * `meshy-6-lite`
  * `meshy-6`
  * `meshy-7`
  * `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.
  * `latest`: Meshy 7

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

  Whether to keep the model's UV layout instead of generating a new one.

  * For a model Meshy generated, from `input_task_id` or a `model_url` that points to a Meshy output, use `true` to reuse its optimized UV layout.
  * For a model you uploaded from elsewhere, use `true` to keep UVs that are already good. Leave it `false` to let Meshy generate new UVs, which suits a model without proper UV mapping.

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

  Whether to also generate PBR maps (metallic, roughness, and normal) with the base color. With `meshy-6`, Meshy also generates an emission map, except at a `texture_resolution` of `8k`. `meshy-6-lite`, `meshy-7`, and `latest` don't generate an emission map. With `meshy-n1`, `true` returns `400`.

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

  The size of the base color texture. Higher resolutions capture more surface detail.

  Available values:
  * `2k`: 2048 × 2048 pixels
  * `4k`: 4096 × 4096 pixels
  * `8k`: 8192 × 8192 pixels

  `4k` and `8k` need an `ai_model` of `meshy-6`, `meshy-7`, or `latest`. With `meshy-6-lite` or `meshy-n1`, they return `400`. At `8k`, Meshy doesn't generate an emission map.

  - `hd_texture` · *boolean* · default: `false` · **deprecated**

  Use `texture_resolution` instead. `true` is the same as `texture_resolution: "4k"`. If you send both, Meshy uses `texture_resolution`.

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

  Whether to remove highlights and shadows from the base color texture. The result works better under your own lighting.

  Meshy applies it only with `meshy-6`, at a `texture_resolution` of `2k` or `4k`. With `meshy-7` or `latest`, or at `8k`, Meshy accepts it and ignores it. With `meshy-6-lite` or `meshy-n1`, sending it with any value returns `400`.

  - `target_formats` · *string[]*

  The file formats to generate. Meshy generates only the formats you list, which can shorten the task. If you leave it out, Meshy generates every format except `3mf`.

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

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

  Whether to also render a preview with a transparent background (RGBA), returned in `alpha_thumbnail_url` when you get the task. `thumbnail_url` doesn't change.

### Returns

The `result` field of the response holds the ID of the new Retexture task.

### Failure modes

  - `400 - Bad Request`

  The request can't run. The error message says which problem it found. For example:
  * **Missing parameter**: Neither `model_url` nor `input_task_id` was sent.
  * **Missing style**: None of `text_style_prompt`, `image_style_url`, and `multiview_image_urls` was sent.
  * **Conflicting style inputs**: `multiview_image_urls` was sent with `text_style_prompt` or `image_style_url`.
  * **Unsupported model for multi-view**: `multiview_image_urls` was sent without an explicit `ai_model` of `meshy-7` or `meshy-n1`.
  * **Unsupported option for Meshy N1**: `meshy-n1` was sent with `enable_pbr: true`, `remove_lighting`, a `texture_resolution` of `4k` or `8k`, `hd_texture: true` without `texture_resolution`, or `text_style_prompt` without `image_style_url`.
  * **Too many triangles for Meshy N1**: With `meshy-n1`, the 3D model has more than 7,999,999 triangles. Reduce the triangle count, or use another `ai_model`.
  * **Model too complex for Meshy N1**: 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.
  * **Triangle count timed out**: With `meshy-n1`, counting the triangles of the `model_url` file took too long. Retry, or reduce the model's size.
  * **Invalid input task**: `input_task_id` isn't a successful task of a supported type.
  * **Invalid model format**: The `model_url` file has an unsupported extension.
  * **Unreachable URL**: Meshy can't download the `model_url` file, the `image_style_url` image, or a `multiview_image_urls` image.
  * **Model file too large**: The `model_url` file is over 400 MB from an `http` or `https` URL, or over 100 MB as a data URI.
  * **Too many faces**: The `model_url` file is over 100 MB and has more than 10,000,000 faces. Reduce the face count, then send the file again.
  * **ASCII FBX over 100 MB**: The `model_url` file is an ASCII FBX over 100 MB. Send it as binary FBX or GLB.
  * **Unreadable model file**: The `model_url` file is over 100 MB, and Meshy can't read its header. For example, it's a Draco-compressed GLB or glTF, or a binary FBX older than 7.1.
  * **Model header too complex**: The `model_url` file is over 100 MB, and its header has too many meshes, nodes, or records to check. Reduce the number of objects in the file, then send it again.
  * **Image too large**: The `image_style_url` image or a `multiview_image_urls` image is over 20 MB.

  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.

  Fix the request, then send it again. See [Errors](/api/errors#request-errors).

  - `401 - Unauthorized`

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

  - `402 - Payment Required`

  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](https://www.meshy.ai/settings/subscription), 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. Check the task ID, then send the request again.

  - `429 - Too Many Requests`

  You exceeded your rate limit. Wait, then retry. See [Rate limits](/api/rate-limits).

**cURL**

```bash
# Retexture with text prompt
curl https://api.meshy.ai/openapi/v1/retexture \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "text_style_prompt": "red fangs, Samurai outfit that fused with japanese batik style",
    "enable_original_uv": true,
    "enable_pbr": true
  }'

# Retexture with image style and PBR
curl https://api.meshy.ai/openapi/v1/retexture \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "image_style_url": "<your publicly accessible image url or base64-encoded data URI>",
    "ai_model": "latest",
    "enable_pbr": true,
    "enable_original_uv": true
  }'

# Retexture with Meshy N1 from front and back views
curl https://api.meshy.ai/openapi/v1/retexture \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "ai_model": "meshy-n1",
    "multiview_image_urls": [
      "<your front view image url or data URI>",
      "<your back view image url or data URI>"
    ]
  }'
```

```javascript
import axios from 'axios'

const headers = { Authorization: `Bearer ${YOUR_API_KEY}` };

// Retexture with text prompt
const payload = {
  model_url: 'https://cdn.meshy.ai/model/example_model_2.glb',
  text_style_prompt:
    'red fangs, Samurai outfit that fused with japanese batik style',
  enable_original_uv: true,
  enable_pbr: true,
};

try {
  const response = await axios.post(
    'https://api.meshy.ai/openapi/v1/retexture',
    payload,
    { headers }
  );
  console.log(response.data);
} catch (error) {
  console.error(error);
}

// Retexture with image style and PBR
const imageStylePayload = {
  model_url: 'https://cdn.meshy.ai/model/example_model_2.glb',
  image_style_url: '<your publicly accessible image url or base64-encoded data URI>',
  ai_model: 'latest',
  enable_pbr: true,
  enable_original_uv: true,
};

try {
  const response = await axios.post(
    'https://api.meshy.ai/openapi/v1/retexture',
    imageStylePayload,
    { headers }
  );
  console.log(response.data);
} catch (error) {
  console.error(error);
}

// Retexture with Meshy N1 from front and back views
const meshyN1Payload = {
  model_url: 'https://cdn.meshy.ai/model/example_model_2.glb',
  ai_model: 'meshy-n1',
  multiview_image_urls: [
    '<your front view image url or data URI>',
    '<your back view image url or data URI>',
  ],
};

try {
  const response = await axios.post(
    'https://api.meshy.ai/openapi/v1/retexture',
    meshyN1Payload,
    { headers }
  );
  console.log(response.data);
} catch (error) {
  console.error(error);
}
```

```python
import requests

headers = {
    "Authorization": f"Bearer {YOUR_API_KEY}"
}

# Retexture with text prompt
payload = {
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "text_style_prompt": "red fangs, Samurai outfit that fused with japanese batik style",
    "enable_original_uv": True,
    "enable_pbr": True
}

response = requests.post(
    "https://api.meshy.ai/openapi/v1/retexture",
    headers=headers,
    json=payload,
)
response.raise_for_status()
print(response.json())

# Retexture with image style and PBR
image_style_payload = {
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "image_style_url": "<your publicly accessible image url or base64-encoded data URI>",
    "ai_model": "latest",
    "enable_pbr": True,
    "enable_original_uv": True
}

response = requests.post(
    "https://api.meshy.ai/openapi/v1/retexture",
    headers=headers,
    json=image_style_payload,
)
response.raise_for_status()
print(response.json())

# Retexture with Meshy N1 from front and back views
meshy_n1_payload = {
    "model_url": "https://cdn.meshy.ai/model/example_model_2.glb",
    "ai_model": "meshy-n1",
    "multiview_image_urls": [
        "<your front view image url or data URI>",
        "<your back view image url or data URI>"
    ]
}

response = requests.post(
    "https://api.meshy.ai/openapi/v1/retexture",
    headers=headers,
    json=meshy_n1_payload,
)
response.raise_for_status()
print(response.json())
```

**Response**

```json
{
  "result": "018a210d-8ba4-705c-b111-1f1776f7f578"
}
```

---

## GET /openapi/v1/retexture/:id -- Get a Retexture task

Returns a Retexture task by its ID.

### Parameters

  - `id` · *path*

  The task ID from the create response.

### Returns

The [Retexture task object](#the-retexture-task-object).

**cURL**

```bash
curl https://api.meshy.ai/openapi/v1/retexture/018a210d-8ba4-705c-b111-1f1776f7f578 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"
```

```javascript
import axios from 'axios'

const taskId = '018a210d-8ba4-705c-b111-1f1776f7f578';
const headers = { Authorization: `Bearer ${YOUR_API_KEY}` };

try {
  const response = await axios.get(
    `https://api.meshy.ai/openapi/v1/retexture/${taskId}`,
    { headers }
  );
  console.log(response.data);
} catch (error) {
  console.error(error);
}
```

```python
import requests

task_id = "018a210d-8ba4-705c-b111-1f1776f7f578"
headers = {
    "Authorization": f"Bearer {YOUR_API_KEY}"
}

response = requests.get(
    f"https://api.meshy.ai/openapi/v1/retexture/{task_id}",
    headers=headers,
)
response.raise_for_status()
print(response.json())
```

**Response**

```json
{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "retexture",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
    "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.obj?Expires=***",
    "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***",
    "mtl": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.mtl?Expires=***",
    "stl": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.stl?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
  "text_style_prompt": "red fangs, Samurai outfit that fused with japanese batik style",
  "texture_image_url": "",
  "progress": 100,
  "started_at": 1692771667037,
  "created_at": 1692771650657,
  "expires_at": 1692771679037,
  "finished_at": 1692771669037,
  "status": "SUCCEEDED",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
      "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
      "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
      "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
    }
  ],
  "task_error": null,

  "consumed_credits": 10
}
```

---

## DELETE /openapi/v1/retexture/:id -- Delete a Retexture task

Permanently deletes a Retexture task, including its models and data. You can't undo a delete.

### Path parameters

  - `id` · *path*

  The ID of the task to delete.

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

### Returns
`200 OK` when the task is deleted, or `409 Conflict` when the task is
`IN_PROGRESS`.

  **cURL**

  ```bash
  curl --request DELETE \
    --url https://api.meshy.ai/openapi/v1/retexture/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
    -H "Authorization: Bearer ${YOUR_API_KEY}"
  ```

  ```javascript
  import axios from 'axios'

  const taskId = 'a43b5c6d-7e8f-901a-234b-567c890d1e2f'
  const headers = { Authorization: `Bearer ${YOUR_API_KEY}` }

  try {
    await axios.delete(
      `https://api.meshy.ai/openapi/v1/retexture/${taskId}`,
      { headers }
    )
  } catch (error) {
    console.error(error)
  }
  ```

  ```python
  import requests

  task_id = "a43b5c6d-7e8f-901a-234b-567c890d1e2f"
  headers = {
      "Authorization": f"Bearer {YOUR_API_KEY}"
  }

  response = requests.delete(
      f"https://api.meshy.ai/openapi/v1/retexture/{task_id}",
      headers=headers,
  )
  response.raise_for_status()
  ```

**Response**

```json
// 200 OK on success, with an empty body.
//
// 409 Conflict when the task is IN_PROGRESS. The task keeps running:
{
  "message": "Task is IN_PROGRESS and cannot be deleted. Credits for a task the worker has already started are not refundable; wait for it to reach SUCCEEDED, FAILED or CANCELED, then delete it."
}
```

---

## GET /openapi/v1/retexture -- List Retexture tasks

Returns a list of your Retexture tasks.

### Parameters

  - `page_num` · *integer* · default: `1`

  The page number to return, up to `255`. A larger value returns `400`.

  - `page_size` · *integer* · default: `10`

  The number of tasks per page, up to `100`.

  - `sort_by` · *string*

  The sort order.

  Available values:
  * `+created_at`: oldest first
  * `-created_at`: newest first

### Returns

A paginated list of [Retexture task objects](#the-retexture-task-object).

  **cURL**

  ```bash
  curl https://api.meshy.ai/openapi/v1/retexture?page_size=10 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"
  ```

  ```javascript
  import axios from 'axios'

  const headers = { Authorization: `Bearer ${YOUR_API_KEY}` };

  try {
   const response = await axios.get(
     `https://api.meshy.ai/openapi/v1/retexture?page_size=10`,
     { headers }
   );
   console.log(response.data);
  } catch (error) {
   console.error(error);
  }
  ```

  ```python
  import requests

  headers = {
      "Authorization": f"Bearer {YOUR_API_KEY}"
  }

  response = requests.get(
      "https://api.meshy.ai/openapi/v1/retexture",
      headers=headers,
      params={"page_size": 10}
  )
  response.raise_for_status()
  print(response.json())
  ```

**Response**

```json
[
  {
    "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "type": "retexture",
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***"
    },
    "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
    "text_style_prompt": "red fangs, Samurai outfit that fused with japanese batik style",
    "progress": 100,
    "started_at": 1692771667037,
    "created_at": 1692771650657,
    "expires_at": 1692771679037,
    "finished_at": 1692771669037,
    "status": "SUCCEEDED",
    "texture_urls": [
      {
        "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
        "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
        "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
        "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
      }
    ],
    "task_error": null,

    "consumed_credits": 10
  }
]
```

---

## GET /openapi/v1/retexture/:id/stream -- Stream a Retexture task

Streams a Retexture task's updates as Server-Sent Events (SSE).

### Parameters

  - `id` · *path*

  The task ID from the create response.

### Returns

A stream of [Retexture task objects](#the-retexture-task-object) as Server-Sent Events.

Each 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.

  **cURL**

  ```bash
  curl -N https://api.meshy.ai/openapi/v1/retexture/018a210d-8ba4-705c-b111-1f1776f7f578/stream \
  -H "Authorization: Bearer ${YOUR_API_KEY}"
  ```

  ```javascript
  const response = await fetch(
    'https://api.meshy.ai/openapi/v1/retexture/018a210d-8ba4-705c-b111-1f1776f7f578/stream',
    {
      headers: { Authorization: `Bearer ${YOUR_API_KEY}` }
    }
  );

  const reader = response.body.getReader();
  const decoder = new TextDecoder();
  let buffer = '';

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;

    buffer += decoder.decode(value, { stream: true });
    const lines = buffer.split('\n');
    buffer = lines.pop();

    for (const line of lines) {
      if (line.startsWith('data:')) {
        const data = JSON.parse(line.slice(5));
        console.log(data);

        if (['SUCCEEDED', 'FAILED', 'CANCELED'].includes(data.status)) {
          reader.cancel();
        }
      }
    }
  }
  ```

  ```python
  import requests
  import json

  headers = {
      "Authorization": f"Bearer {YOUR_API_KEY}",
      "Accept": "text/event-stream"
  }

  response = requests.get(
      'https://api.meshy.ai/openapi/v1/retexture/018a210d-8ba4-705c-b111-1f1776f7f578/stream',
      headers=headers,
      stream=True
  )

  for line in response.iter_lines():
      if line:
          if line.startswith(b'data:'):
              data = json.loads(line.decode('utf-8')[5:])
              print(data)

              if data['status'] in ['SUCCEEDED', 'FAILED', 'CANCELED']:
                  break

  response.close()
  ```

**Response Stream**

```javascript
// Error event example
event: error
data: {
  "status_code": 404,
  "message": "Task not found"
}

// Message event examples illustrate task progress.
// These examples are shortened. Each event holds the full task object.
event: message
data: {
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "progress": 50,
  "status": "IN_PROGRESS"
}

event: message
data: {
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "retexture",
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1692771650657,
  "started_at": 1692771667037,
  "finished_at": 1692771669037,
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
    "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.obj?Expires=***",
    "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***",
    "mtl": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.mtl?Expires=***",
    "stl": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.stl?Expires=***"
  },
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
      "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
      "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
      "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
    }
  ],
  "task_error": null,

  "consumed_credits": 10
}
```

---

## The Retexture task object
A Retexture task object describes one retexture of a 3D model. It holds the status, the progress, and the model and texture files when the task succeeds.

### Properties

- `id` · *string*

  The task ID. Treat it as an opaque string, and don't rely on its format.

- `type` · *string*

  The task type, always `retexture`.

- `model_urls` · *object*

  Download URLs for the textured 3D model, one per file format.

  - `glb` · *string*

  The GLB file.

  - `fbx` · *string*

  The FBX file.

  - `obj` · *string*

  The OBJ file.

  - `usdz` · *string*

  The USDZ file.

  - `mtl` · *string*

  The MTL file. Meshy returns it with the OBJ file when the model has textures.

  - `stl` · *string*

  The STL file.

  - `3mf` · *string*

  The 3MF file. Present only when `target_formats` includes `3mf`.

- `text_style_prompt` · *string*

  The text prompt you created the task with.

- `image_style_url` · *string*

  The style image you created the task with.

- `multiview_image_urls` · *string[]*

  Download URLs for the multi-view reference images you created the task with. Present only when you created the task with `multiview_image_urls`.

- `thumbnail_url` · *string*

  Download URL for a thumbnail image of the model.

- `alpha_thumbnail_url` · *string*

  Download URL for a version of `thumbnail_url` with a transparent background (RGBA). Present only when you created the task with `alpha_thumbnail: true` and Meshy rendered the transparent preview.

- `progress` · *integer*

  How much of the task is done, as a percentage. It's `0` until the task starts and `100` when it succeeds.

- `started_at` · *timestamp*

  Time the task started, in Unix milliseconds. It's `0` until the task starts.

- `created_at` · *timestamp*

  Time the task was created, in Unix milliseconds.

- `expires_at` · *timestamp*

  Time the task's results expire, in Unix milliseconds.

- `finished_at` · *timestamp*

  Time the task finished, in Unix milliseconds. It's `0` until the task finishes.

- `status` · *string*

  The task status, one of `PENDING`, `IN_PROGRESS`, `SUCCEEDED`, `FAILED`, or `CANCELED`.

- `texture_urls` · *array*

  Download URLs for the generated textures, as an array of objects. The array usually holds one object. Each object has these fields:

  - `base_color` · *string*

  Download URL for the base color map.

  - `metallic` · *string*

  Download URL for the metallic map. Meshy leaves this field out when you create the task with `enable_pbr: false`.

  - `normal` · *string*

  Download URL for the normal map. Meshy leaves this field out when you create the task with `enable_pbr: false`.

  - `roughness` · *string*

  Download URL for the roughness map. Meshy leaves this field out when you create the task with `enable_pbr: false`.

  - `emission` · *string*

  Download URL for the emission map. Meshy leaves this field out when you create the task with any of these:
* `enable_pbr: false`
* an `ai_model` of `meshy-6-lite`, `meshy-7`, or `latest`
* `texture_resolution: 8k`

- `preceding_tasks` · *integer*

  The number of tasks ahead of this one in the queue. Present only while the task is `PENDING`; the field is left out when the value is `0`.

- `task_error` · *object*

  The error details when the task fails. See [Errors](/api/errors#task-errors).

- `consumed_credits` · *integer*

  The number of credits the task used. Present when the status is `PENDING`, `IN_PROGRESS`, or `SUCCEEDED`. It's `0` for a `FAILED` task, because Meshy refunds the credits when a task fails.

<span id="example-retexture-task-object" />

**Example Retexture Task Model**

```json
{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "retexture",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
    "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
    "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***"
  },
  "text_style_prompt": "red fangs, Samurai outfit that fused with japanese batik style",
  "image_style_url": "https://assets.meshy.ai/***/image/example_image.jpg?Expires=***",
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
  "progress": 100,
  "started_at": 1692771667037,
  "created_at": 1692771650657,
  "expires_at": 1692771679037,
  "finished_at": 1692771669037,
  "status": "SUCCEEDED",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
      "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
      "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
      "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
    }
  ],
  "task_error": null,

  "consumed_credits": 10
}
```
