lowpoly จะยุติการให้บริการในวันที่ 30 ต.ค. 2569 โปรดเปลี่ยนโมเดลก่อนวันที่เหล่านี้เพื่อหลีกเลี่ยงข้อผิดพลาดของคำขอ

เริ่มต้นอย่างรวดเร็ว

เริ่มต้นด้วยการสร้าง API คีย์ของคุณ

ทุกคำขอในคู่มือนี้ต้องใช้สิ่งนี้ การสร้างคีย์ใช้เวลาเพียงไม่กี่วินาที

สร้าง API คีย์ของคุณ

สี่ขั้นตอนสู่โมเดล 3D แรกของคุณ โดยใช้ Meshy REST API


1รับ API คีย์ของคุณ

สร้าง API คีย์ จากหน้า API Keys ใน Developer Platform — คุณจะไม่สามารถดูคีย์นี้ได้อีกหลังจากหน้าจอนี้ ดังนั้นควรเก็บไว้ในที่ปลอดภัย ทุกคำขอจะทำการยืนยันตัวตนด้วยโทเคน Bearer ใน header Authorization — ดู Authentication

เปิดหน้า API Keys ใน Developer Platform จากนั้นสร้างคีย์ของคุณ


2สร้างคำขอ Image-to-3D แรกของคุณ

Export คีย์ของคุณ จากนั้นสร้างงานแรกด้วย Image to 3D หากต้องการทำงานจาก prompt ข้อความหรือรูปภาพหลายรูปแทน ดู Text to 3D หรือ Multi-Image to 3D

Export your key

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

ตัวอย่างทั้งหมดด้านล่างนี้ใช้ภาพถ่ายนี้ — เปลี่ยนไปใช้ image_url ของคุณเองเพื่อลองสิ่งอื่น

Sample fantasy character illustration used as the Image to 3D input in this guide
Sample input

Request

POST
/openapi/v1/image-to-3d
curl https://api.meshy.ai/openapi/v1/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"
  }'

3ตรวจสอบสถานะของงาน

งานจะทำงานอยู่เบื้องหลังและมักใช้เวลาไม่กี่นาที ให้ทำการ poll เอนด์พอยต์เดิมซ้ำๆ จนกว่า status จะเป็น SUCCEEDED, FAILED หรือ CANCELED โดยแทนที่ <task_id> ด้านล่างด้วย ID ที่ได้รับในขั้นตอนที่ 2 สำหรับระยะเวลาโดยทั่วไปและควรรอนานแค่ไหน โปรดดู Task Lifecycle

Request

GET
/openapi/v1/image-to-3d/:id
curl https://api.meshy.ai/openapi/v1/image-to-3d/<task_id> \
  -H "Authorization: Bearer ${MESHY_API_KEY}"

Response — SUCCEEDED

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "status": "SUCCEEDED",
  "progress": 100,
  "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=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
  "task_error": {
    "message": ""
  }
}

4ดาวน์โหลดโมเดลของคุณ

นำโมเดลมาจาก model_urls ในคำตอบด้านบน แต่ละฟอร์แมต (GLB, FBX, OBJ, USDZ, STL) เป็น URL ที่มีการเซ็นชื่อและมีเวลาจำกัด — หรือจะข้ามขั้นตอนบรรทัดคำสั่งแล้ววาง URL ลงในแถบที่อยู่ของเบราว์เซอร์โดยตรงเพื่อดาวน์โหลดก็ได้

Download

model_urls.glb
curl -L "<model_urls.glb from the response above>" -o model.glb
The resulting 3D model generated from the sample fantasy character photo
Your result

รวมทุกอย่างเข้าด้วยกัน

อยากได้สคริปต์เดียวที่ทำทุกอย่าง — สร้าง, ตรวจสอบสถานะ, ดาวน์โหลด?

Full script

import axios from 'axios';
import fs from 'fs';

const headers = { Authorization: `Bearer ${process.env.MESHY_API_KEY}` };
const imageUrl = 'https://docs.meshy.ai/images/api/quick-start/source-photo.webp';

// 1. Create the task
const { data: created } = await axios.post(
  'https://api.meshy.ai/openapi/v1/image-to-3d',
  { image_url: imageUrl },
  { headers, timeout: 60_000 },
);
const taskId = created.result;

// 2. Poll until it finishes, for up to 60 minutes
const deadline = Date.now() + 60 * 60 * 1000;
let task;
while (true) {
  const { data, headers: resHeaders } = await axios.get(
    `https://api.meshy.ai/openapi/v1/image-to-3d/${taskId}`,
    { headers, timeout: 30_000 },
  );
  task = data;
  if (['SUCCEEDED', 'FAILED', 'CANCELED'].includes(task.status)) break;
  if (Date.now() > deadline) {
    // The task is still running. Check it again later with the same task ID instead of creating a new one.
    throw new Error(`Task ${taskId} is still ${task.status}; check it again later`);
  }
  const waitSeconds = Number(resHeaders['retry-after']) || 5;
  await new Promise((resolve) => setTimeout(resolve, waitSeconds * 1000));
}

// 3. Download the result (only if the task succeeded)
if (task.status !== 'SUCCEEDED') {
  throw new Error(`Task ${task.status}: ${task.task_error?.message || 'unknown error'}`);
}
const { data: model } = await axios.get(task.model_urls.glb, { responseType: 'arraybuffer' });
fs.writeFileSync('model.glb', model);
console.log('Saved model.glb');

สำรวจเวิร์กโฟลว์ที่ใช้งานบ่อย


ขั้นตอนถัดไป

  • ต้องการใช้ UI ใช่ไหม? เปิด Developer Platform — รันคำขอใน Playground ติดตามการใช้งานและบันทึกคำขอ และจัดการ webhooks
  • ดูข้อมูลทั้งหมดได้ที่ API reference สำหรับทุกเอนด์พอยต์
  • เรียนรู้จากตัวอย่างที่ใช้งานได้จริง: ทำตามสูตรทีละขั้นตอนใน Cookbook และอ่านบทแนะนำและเรื่องราวการพัฒนาใน Developer Blog
  • ตรวจสอบ ราคา, Rate Limits และ ข้อผิดพลาด ก่อนนำไปใช้งานจริง
  • ติดตาม บันทึกการเปลี่ยนแปลง สำหรับการอัปเดตและการแก้ไขบั๊ก
  • มีความคิดเห็นหรือพบปัญหาหรือไม่? เข้าร่วมคอมมูนิตี้ Discord ของเรา — เรายินดีรับฟังจากคุณ!