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

---

# Quickstart

> **Start by creating your API key:** Every request in this guide needs one. Creating a key takes seconds.
>
> [Create your API key](https://www.meshy.ai/developers/keys)

Make your first 3D model with Meshy API v2 in four steps. You get an API key, create a task, follow it on the Tasks route, and download the result.

> **Note:** Moving from v1? See [Migrate to API v2](/api/migrate-to-v2) instead.

---

## 1. Get your API key
[Create an API key](https://www.meshy.ai/developers/keys) on the **API Keys** page of the [Developer Platform](https://www.meshy.ai/developers). You can't view the key again after you leave that screen, so store it somewhere safe. Send it in every request as a `Bearer` token in the `Authorization` header. See [Authentication](/api/authentication).

You need a paid plan to create and manage API keys. On the Free plan, you can't create keys of your own, and the Playground uses a built-in key for testing.

![Open the API Keys page in the Developer Platform, then create your key](/images/api/quick-start/api-key-settings.webp)

Store the key in an environment variable instead of pasting it into your code. Run this in your terminal:

**Export your key**

```bash
export MESHY_API_KEY="<your-api-key>"
```

The JavaScript examples use `fetch`, which is built into Node.js 18 and later. The Python examples use [`requests`](https://pypi.org/project/requests/) (`pip install requests`).

---

## 2. Create an Image to 3D task
Send an image to [Image to 3D](https://docs.meshy.ai/api/v2/image-to-3d.md). To start from a text prompt or several photos instead, use [Text to 3D](https://docs.meshy.ai/api/v2/text-to-3d.md) or [Multi-Image to 3D](https://docs.meshy.ai/api/v2/multi-image-to-3d.md). Every endpoint works the same way from here.

The following examples all use this photo and texture the model with Meshy 7, which `texture_model` picks. To try another image, change `image_url`. To pick another texture model, see [Texture models](https://docs.meshy.ai/api/v2/image-to-3d.md#texture-models).

![Sample fantasy character illustration used as the Image to 3D input in this guide](https://docs.meshy.ai/images/api/quick-start/source-photo.webp)

**cURL**

```bash
curl https://api.meshy.ai/openapi/v2/image-to-3d \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    "texture_model": "meshy-7"
  }'
```

```javascript
const headers = {
  Authorization: `Bearer ${process.env.MESHY_API_KEY}`,
  "Content-Type": "application/json",
};

const res = await fetch("https://api.meshy.ai/openapi/v2/image-to-3d", {
  method: "POST",
  headers,
  body: JSON.stringify({
    image_url: "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    texture_model: "meshy-7",
  }),
});
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).message}`);
const task = await res.json();
console.log("Task created:", task.id);
```

```python
import os
import requests

headers = {"Authorization": f"Bearer {os.environ['MESHY_API_KEY']}"}

response = requests.post(
    "https://api.meshy.ai/openapi/v2/image-to-3d",
    headers=headers,
    json={"image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp", "texture_model": "meshy-7"},
)
response.raise_for_status()
task = response.json()
print("Task created:", task["id"])
```

The response is `202 Accepted` with the [task object](https://docs.meshy.ai/api/v2/tasks.md#the-task-object). Keep its `id`, because every next step needs it. The `Location` header gives the path to read the task from.

**Response: 202 Accepted**

```json
{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "image-to-3d",
  "status": "PENDING",
  "progress": 0,
  "created_at": 1791846275575,
  "started_at": null,
  "finished_at": null,
  "expires_at": null,
  "preceding_tasks": 1,
  "consumed_credits": 30,
  "task_error": null,
  "input": {
    "image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    "texture_model": "meshy-7"
  },
  "output": null
}
```

---

## 3. Get the task until it finishes
The task runs in the background and usually takes about 2 minutes. Get it from `/openapi/v2/tasks/<task_id>` until `status` is `SUCCEEDED`, `FAILED`, or `CANCELED`. Between requests, wait the number of seconds in the `Retry-After` header.

The same route works for tasks from every endpoint. For typical processing times, and how long to wait before you give up, see [Processing times](/api/task-lifecycle#processing-times) and [How long to wait](/api/task-lifecycle#how-long-to-wait).

**cURL**

```bash
curl https://api.meshy.ai/openapi/v2/tasks/<task_id> \
  -H "Authorization: Bearer ${MESHY_API_KEY}"
```

```javascript
let current;
while (true) {
  const res = await fetch(`https://api.meshy.ai/openapi/v2/tasks/${task.id}`, { headers });
  if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).message}`);
  current = await res.json();
  if (["SUCCEEDED", "FAILED", "CANCELED"].includes(current.status)) break;
  console.log(current.status, current.progress);
  const waitSeconds = Number(res.headers.get("retry-after")) || 5;
  await new Promise((resolve) => setTimeout(resolve, waitSeconds * 1000));
}
```

```python
import time

while True:
    response = requests.get(
        f"https://api.meshy.ai/openapi/v2/tasks/{task['id']}",
        headers=headers,
    )
    response.raise_for_status()
    current = response.json()
    if current["status"] in ("SUCCEEDED", "FAILED", "CANCELED"):
        break
    print(current["status"], current["progress"])
    time.sleep(int(response.headers.get("Retry-After", 5)))
```

**Response: SUCCEEDED**

```json
{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "image-to-3d",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1791846275575,
  "started_at": 1791846275578,
  "finished_at": 1791846334536,
  "expires_at": 1792105534536,
  "preceding_tasks": 0,
  "consumed_credits": 30,
  "task_error": null,
  "input": {
    "image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    "texture_model": "meshy-7"
  },
  "output": {
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***"
    },
    "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
    "thumbnail_urls": null,
    "texture_urls": [
      {
        "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
        "metallic": null,
        "roughness": null,
        "normal": null,
        "metallic_roughness": null,
        "emission": null
      }
    ]
  }
}
```

If the task fails, `status` is `FAILED`, and `task_error` says why. Fix the input or create another task. See [Errors](https://docs.meshy.ai/api/v2/errors.md#task-errors).

> **Note:** To get notified when the task finishes instead of polling, [stream the task](https://docs.meshy.ai/api/v2/tasks.md#stream-a-task) or use a [webhook](https://docs.meshy.ai/api/v2/webhooks.md).

---

## 4. Download your model
The files are in `output`. `output.model_urls.glb` is a signed URL that works until `expires_at`. You can also paste it into your browser to download the file.

Image to 3D returns only a GLB file, unless you list other formats in `target_formats` when you create the task.

**cURL**

```bash
curl -L "<output.model_urls.glb from the response above>" -o model.glb
```

```javascript

const file = await fetch(current.output.model_urls.glb);
await writeFile("model.glb", Buffer.from(await file.arrayBuffer()));
```

```python
file = requests.get(current["output"]["model_urls"]["glb"])
file.raise_for_status()

with open("model.glb", "wb") as f:
    f.write(file.content)
```

![The resulting 3D model generated from the sample fantasy character photo](/images/api/quick-start/image-to-3d-output.webp)

> **Note:** On every plan except Enterprise, Meshy keeps the files for 3 days. Download the files you need before then. See [Asset retention](https://docs.meshy.ai/api/v2/asset-retention.md).

---

## Put it all together
This script creates the task, waits for it to finish, and downloads the model.

```javascript

const API = "https://api.meshy.ai/openapi/v2";
const headers = {
  Authorization: `Bearer ${process.env.MESHY_API_KEY}`,
  "Content-Type": "application/json",
};

async function call(path, init = {}) {
  const res = await fetch(`${API}${path}`, {
    ...init,
    headers,
    signal: AbortSignal.timeout(init.method === "POST" ? 60_000 : 30_000),
  });
  if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).message}`);
  return { body: await res.json(), retryAfter: Number(res.headers.get("retry-after")) || 5 };
}

// 1. Create the task
let { body: task, retryAfter } = await call("/image-to-3d", {
  method: "POST",
  body: JSON.stringify({
    image_url: "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    texture_model: "meshy-7",
  }),
});

// 2. Get the task until it finishes, for up to 60 minutes
const deadline = task.created_at + 60 * 60 * 1000;
while (!["SUCCEEDED", "FAILED", "CANCELED"].includes(task.status)) {
  if (Date.now() > deadline) {
    // The task is still running. Check it again later with the same ID instead of creating a new one.
    throw new Error(`Task ${task.id} is still ${task.status}; check it again later`);
  }
  await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
  ({ body: task, retryAfter } = await call(`/tasks/${task.id}`));
}

// 3. Download the model (only if the task succeeded)
if (task.status !== "SUCCEEDED") {
  throw new Error(`Task ${task.status}: ${task.task_error?.message ?? "unknown error"}`);
}
const file = await fetch(task.output.model_urls.glb);
await writeFile("model.glb", Buffer.from(await file.arrayBuffer()));
console.log("Saved model.glb");
```

```python
import os
import time
import requests

API = "https://api.meshy.ai/openapi/v2"
headers = {"Authorization": f"Bearer {os.environ['MESHY_API_KEY']}"}

# 1. Create the task
response = requests.post(
    f"{API}/image-to-3d",
    headers=headers,
    json={"image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp", "texture_model": "meshy-7"},
    timeout=60,
)
response.raise_for_status()
task = response.json()

# 2. Get the task until it finishes, for up to 60 minutes
deadline = task["created_at"] / 1000 + 60 * 60
while task["status"] not in ("SUCCEEDED", "FAILED", "CANCELED"):
    if time.time() > deadline:
        # The task is still running. Check it again later with the same ID instead of creating a new one.
        raise SystemExit(f"Task {task['id']} is still {task['status']}; check it again later")
    time.sleep(int(response.headers.get("Retry-After", 5)))
    response = requests.get(f"{API}/tasks/{task['id']}", headers=headers, timeout=30)
    response.raise_for_status()
    task = response.json()

# 3. Download the model (only if the task succeeded)
if task["status"] != "SUCCEEDED":
    error = task["task_error"] or {}
    raise SystemExit(f"Task {task['status']}: {error.get('message') or 'unknown error'}")
file = requests.get(task["output"]["model_urls"]["glb"], timeout=300)
file.raise_for_status()
with open("model.glb", "wb") as f:
    f.write(file.content)
print("Saved model.glb")
```

---

## Explore common workflows

  - [Game-ready character](https://docs.meshy.ai/api/v2/rigging.md): Rig a humanoid model with a skeleton so it's ready to animate in Unity or Unreal.
  - [Smart Topology mesh](https://docs.meshy.ai/api/v2/image-to-3d.md): Set `ai_model` to `meshy-smart-topology-latest` on Image to 3D for a clean, game-ready triangle mesh.
  - [3D print model](https://docs.meshy.ai/api/v2/multi-color-print.md): Turn a finished model into a multi-color 3MF file, ready to slice and print.

---

## Next steps
- Learn the [task object and the Tasks routes](https://docs.meshy.ai/api/v2/tasks.md) that every endpoint shares.
- Browse every endpoint in the [API v2 overview](https://docs.meshy.ai/api/v2.md).
- Check [Pricing](/api/pricing), [Rate limits](https://docs.meshy.ai/api/v2/rate-limits.md), and [Errors](https://docs.meshy.ai/api/v2/errors.md) before you go to production.
- Prefer a UI? The [Developer Platform](/api/developer-platform) lets you run requests in the Playground, track usage and request logs, and manage webhooks.
- Follow step-by-step recipes in the [Cookbook](https://www.meshy.ai/developers/cookbook/), and read tutorials on the [Developer Blog](https://www.meshy.ai/developers/blog/).
- Have feedback or a problem? Join the Meshy [Discord](https://discord.com/invite/KgD5yVM9Y4) community.
