Meshy 3D — Generation + Printing
Directly communicate with the Meshy AI API to generate and print 3D assets. Covers the complete lifecycle: API key setup, task creation, exponential backoff polling, downloading, multi-step pipelines, and 3D print preparation with slicer integration.
SECURITY MANIFEST
Environment variables accessed:
- -
MESHY_API_KEY — API authentication token sent in HTTP Authorization: Bearer header only. Never logged, never written to any file except .env in the current working directory when explicitly requested by the user.
External network endpoints:
- -
https://api.meshy.ai — Meshy AI API (task creation, status polling, model/image downloads)
File system access:
- - Read:
.env in the current working directory only (API key lookup) - Write:
.env in the current working directory only (API key storage, only on user request) - Write:
./meshy_output/ in the current working directory (downloaded model files, metadata) - Read: files explicitly provided by the user (e.g., local images passed for image-to-3D conversion), accessed only at the exact path the user specifies
- No access to home directories, shell profiles, or any path outside the above
Data leaving this machine:
- - API requests to
api.meshy.ai include the MESHY_API_KEY in the Authorization header and user-provided text prompts or image URLs. No other local data is transmitted. Downloaded model files are saved locally only.
IMPORTANT: First-Use Session Notice
When this skill is first activated in a session, inform the user:
All generated files will be saved to meshy_output/ in the current working directory. Each project gets its own folder ({YYYYMMDD_HHmmss}_{prompt}_{id}/) with model files, textures, thumbnails, and metadata. History is tracked in meshy_output/history.json.
This only needs to be said once per session.
IMPORTANT: File Organization
All downloaded files MUST go into a structured meshy_output/ directory in the current working directory. Do NOT scatter files randomly.
- - Each project: INLINECODE13
- Chained tasks (preview → refine → rig) reuse the same INLINECODE14
- Track tasks in
metadata.json per project, and global INLINECODE16 - Auto-download thumbnails alongside models
IMPORTANT: Shell Command Rules
Use only standard POSIX tools. Do NOT use rg, fd, bat, exa/eza.
IMPORTANT: Run Long Tasks Properly
Meshy generation takes 1–5 minutes. Write the entire create → poll → download flow as ONE Python script and execute in a single Bash call. Use python3 -u script.py for unbuffered output. Tasks sitting at 99% for 30–120s is normal finalization — do NOT interrupt.
Step 0: API Key Detection (ALWAYS RUN FIRST)
Only check the current session environment and the .env file in the current working directory. Do NOT scan home directories or shell profile files.
CODEBLOCK0
Decision After Detection
- - Key found → Proceed to Step 1.
- Key NOT found → Go to Step 0a.
- Python requests missing → Run
pip install requests.
Step 0a: API Key Setup (Only If No Key Found)
Tell the user:
To use the Meshy API, you need an API key:
- 1. Go to https://www.meshy.ai/settings/api
- Click "Create API Key", name it, and copy the key (starts with
msy_) - The key is shown only once — save it somewhere safe
Note: API access requires a Pro plan or above. Free-tier accounts cannot create API keys.
Once the user provides the key, set it for the current session and optionally persist to .env:
CODEBLOCK1
To persist the key (current project only):
CODEBLOCK2
Security reminder: The key is stored only in .env in your current project directory. Never commit this file to version control. .env has been automatically added to .gitignore.
Step 1: Confirm Plan With User Before Spending Credits
CRITICAL: Before creating any task, present the user with a cost summary and wait for confirmation:
CODEBLOCK3
For multi-step pipelines (text-to-3d → rig → animate), show the FULL pipeline cost upfront.
Note: Rigging automatically includes walking + running animations at no extra cost. Only add Animate (3 credits) for custom animations beyond those.
Intent → API Mapping
| User wants to... | API | Endpoint | Credits |
|---|
| 3D model from text | Text to 3D | INLINECODE31 | 20 + 10 |
| 3D model from one image |
Image to 3D |
POST /openapi/v1/image-to-3d | 20–30 |
| 3D model from multiple images | Multi-Image to 3D |
POST /openapi/v1/multi-image-to-3d | 20–30 |
| New textures on existing model | Retexture |
POST /openapi/v1/retexture | 10 |
| Change mesh format/topology | Remesh |
POST /openapi/v1/remesh | 5 |
| Add skeleton to character | Auto-Rigging |
POST /openapi/v1/rigging | 5 |
| Animate a rigged character | Animation |
POST /openapi/v1/animations | 3 |
| 2D image from text | Text to Image |
POST /openapi/v1/text-to-image | 3–9 |
| Transform a 2D image | Image to Image |
POST /openapi/v1/image-to-image | 3–9 |
| Check credit balance | Balance |
GET /openapi/v1/balance | 0 |
| 3D print a model | → See Print Pipeline section | — | 20 |
Step 2: Execute the Workflow
Reusable Script Template
Use this as the base for ALL workflows. It loads the API key securely from environment or .env in the current directory only:
CODEBLOCK4
Text to 3D (Preview + Refine)
Append to the template above:
CODEBLOCK5
Note: Only previews from meshy-5 or latest support refine. meshy-6 previews do NOT (API returns 400).
Image to 3D
CODEBLOCK6
Multi-Image to 3D
CODEBLOCK7
Retexture
CODEBLOCK8
Remesh / Format Conversion
CODEBLOCK9
Auto-Rigging + Animation
When the user asks to rig or animate, the generation step MUST use pose_mode: "t-pose".
CODEBLOCK10
Text to Image / Image to Image
CODEBLOCK11
3D Printing Workflow
Trigger when the user mentions: print, 3d print, slicer, slice, bambu, orca, prusa, cura, figurine, miniature, statue, physical model, desk toy, phone stand.
Print Pipelines
Text-to-3D Print:
| Step | Action | Credits |
|---|
| 1 | Text to 3D (mode: "preview", no texture) | 20 |
| 2 |
Printability check (see checklist) | 0 |
| 3 | Download OBJ | 0 |
| 4 | Open in slicer (direct launch or manual import) | 0 |
| 5 (optional) | Retexture for multi-color | 10 |
Image-to-3D Print:
| Step | Action | Credits |
|---|
| 1 | Image to 3D with INLINECODE47 | 20 |
| 2 |
Printability check | 0 |
| 3 | Download OBJ | 0 |
| 4 | Open in slicer (direct launch or manual import) | 0 |
Print Download + Slicer Script
Append to the template after task SUCCEEDED:
CODEBLOCK12
INLINECODE48 : Default 75mm. Adjust based on user request (e.g. "print at 15cm" → 150.0).
Opening OBJ in slicer: When the user specifies a slicer (e.g. Bambu Studio, OrcaSlicer, Creality Print, PrusaSlicer, Cura), open the downloaded OBJ file directly:
- - macOS:
subprocess.run(["open", "-a", "<AppName>", obj_path]) — the OS resolves the app location automatically. - Windows / Linux: Use
shutil.which("<binary_name>") to find the executable in PATH, then subprocess.Popen([exe, obj_path]). If not found, print the file path and instruct manual open. - No slicer specified: Print the OBJ file path and instruct: File → Import / Open → select .obj file.
Printability Checklist (Manual Review)
Automated printability analysis API is coming soon.
| Check | Recommendation |
|---|
| Wall thickness | Min 1.2mm FDM, 0.8mm resin |
| Overhangs |
Keep below 45° or add supports |
| Manifold mesh | Watertight, no holes |
| Minimum detail | 0.4mm FDM, 0.05mm resin |
| Base stability | Flat base or add brim/raft in slicer |
| Floating parts | All parts connected or printed separately |
Multi-Color Printing (Manual Guidance)
Automated multi-color API is coming soon.
- 1. Use Retexture (10 credits) to apply distinct color regions
- Download OBJ
- In slicer's color painting tool, assign filament colors to regions
- Slice with multi-color setup (Bambu AMS, Prusa MMU)
Step 3: Report Results
After task succeeds:
- 1. Downloaded file paths and sizes
- Task IDs (for follow-up: refine, rig, retexture)
- Available formats (list
model_urls keys) - Credits consumed + current balance
- Suggested next steps:
- Preview done → "Want to refine (add textures)?"
- Model done → "Want to rig this character?"
- Rigged → "Want to apply a custom animation?"
- Any model → "Want to 3D print this?"
Error Recovery
| HTTP Status | Meaning | Action |
|---|
| 401 | Invalid API key | Re-run Step 0; ask user to check key |
| 402 |
Insufficient credits | Show balance, link https://www.meshy.ai/pricing |
| 422 | Cannot process | Explain (e.g., non-humanoid for rigging) |
| 429 | Rate limited | Auto-retry after 5s (max 3 times) |
| 5xx | Server error | Auto-retry after 10s (once) |
Task FAILED messages:
- -
"The server is busy..." → retry with backoff (5s, 10s, 20s) - INLINECODE56 → simplify prompt, retry once
Known Behaviors & Constraints
- - 99% stall: Normal finalization (30–120s). Do NOT interrupt.
- Asset retention: Files deleted after 3 days (non-Enterprise). Download immediately.
- PBR maps: Must set
enable_pbr: true explicitly. - Refine: Only
meshy-5 / latest previews support refine; meshy-6 does not. - Rigging: Humanoid bipedal only, polycount ≤ 300,000.
- OBJ for printing: Always download OBJ for slicer compatibility (3MF not yet available from API). If user specifies a slicer, try to open OBJ directly; otherwise print file path for manual import.
- Timestamps: All API timestamps are Unix epoch milliseconds.
Execution Checklist
- - [ ] Ran API key detection (Step 0) — checked env var and
.env only - [ ] API key verified (never printed in full)
- [ ] Presented cost summary and got user confirmation
- [ ] Wrote complete workflow as single Python script
- [ ] Ran with
python3 -u for unbuffered output - [ ] Reported file paths, formats, task IDs, and balance
- [ ] Suggested next steps
Additional Resources
For the complete API endpoint reference including all parameters, response schemas, and error codes, read reference.md.
Meshy 3D — 生成 + 打印
直接与 Meshy AI API 通信,生成并打印 3D 资源。涵盖完整生命周期:API 密钥设置、任务创建、指数退避轮询、下载、多步骤流水线以及集成切片器的 3D 打印准备。
安全声明
访问的环境变量:
- - MESHYAPIKEY — API 认证令牌,仅在 HTTP Authorization: Bearer 标头中发送。绝不记录,除非用户明确要求,否则绝不写入除当前工作目录中 .env 文件之外的任何文件。
外部网络端点:
- - https://api.meshy.ai — Meshy AI API(任务创建、状态轮询、模型/图像下载)
文件系统访问:
- - 读取:仅当前工作目录中的 .env(API 密钥查找)
- 写入:仅当前工作目录中的 .env(API 密钥存储,仅在用户请求时)
- 写入:当前工作目录中的 ./meshy_output/(下载的模型文件、元数据)
- 读取:用户明确提供的文件(例如,用于图像转 3D 的本地图像),仅访问用户指定的确切路径
- 无权访问主目录、shell 配置文件或上述路径之外的任何路径
离开本机的数据:
- - 对 api.meshy.ai 的 API 请求包含 Authorization 标头中的 MESHYAPIKEY 以及用户提供的文本提示或图像 URL。不传输其他本地数据。下载的模型文件仅保存在本地。
重要提示:首次使用会话通知
当此技能在会话中首次激活时,请告知用户:
所有生成的文件将保存到当前工作目录的 meshyoutput/ 中。每个项目都有自己的文件夹({YYYYMMDDHHmmss}{提示词}{ID}/),包含模型文件、纹理、缩略图和元数据。历史记录保存在 meshy_output/history.json 中。
此信息每个会话只需说明一次。
重要提示:文件组织
所有下载的文件必须放入当前工作目录中结构化的 meshy_output/ 目录中。请勿随意散放文件。
- - 每个项目:meshyoutput/{YYYYMMDDHHmmss}{提示词缩写}{任务ID前缀}/
- 链式任务(预览 → 细化 → 绑定)复用相同的 project_dir
- 每个项目在 metadata.json 中跟踪任务,全局在 history.json 中跟踪
- 自动随模型下载缩略图
重要提示:Shell 命令规则
仅使用标准 POSIX 工具。请勿使用 rg、fd、bat、exa/eza。
重要提示:正确运行长时间任务
Meshy 生成需要 1–5 分钟。将整个创建 → 轮询 → 下载流程编写为一个 Python 脚本,并在单个 Bash 调用中执行。使用 python3 -u script.py 实现无缓冲输出。任务在 99% 停留 30–120 秒是正常的最终化过程 — 请勿中断。
步骤 0:API 密钥检测(始终首先运行)
仅检查当前会话环境和当前工作目录中的 .env 文件。请勿扫描主目录或 shell 配置文件。
bash
echo === Meshy API 密钥检测 ===
1. 检查当前环境变量
if [ -n $MESHY
APIKEY ]; then
echo 环境变量: 已找到 (${MESHY
APIKEY:0:8}...)
else
echo 环境变量: 未找到
fi
2. 仅检查当前工作目录中的 .env
if [ -f .env ] && grep -q MESHY
APIKEY .env 2>/dev/null; then
echo DOTENV(.env): 已找到
export MESHY
APIKEY=$(grep ^MESHY
APIKEY= .env | head -1 | cut -d= -f2- | tr -d )
fi
3. 最终状态
if [ -n $MESHY
APIKEY ]; then
echo 就绪: 密钥=${MESHY
APIKEY:0:8}...
else
echo 就绪: 未找到密钥
fi
4. Python requests 检查
python3 -c import requests; print(PYTHON
REQUESTS: 正常) 2>/dev/null || echo PYTHONREQUESTS: 缺失 (运行: pip install requests)
echo === 检测完成 ===
检测后的决策
- - 找到密钥 → 继续执行步骤 1。
- 未找到密钥 → 转到步骤 0a。
- Python requests 缺失 → 运行 pip install requests。
步骤 0a:API 密钥设置(仅在未找到密钥时)
告知用户:
要使用 Meshy API,您需要一个 API 密钥:
- 1. 访问 https://www.meshy.ai/settings/api
- 点击 创建 API 密钥,为其命名,然后复制密钥(以 msy_ 开头)
- 密钥仅显示一次 — 请将其保存在安全的地方
注意: API 访问需要 Pro 计划或更高版本。免费层账户无法创建 API 密钥。
用户提供密钥后,为当前会话设置它,并可选择持久化到 .env:
bash
仅为当前会话设置
export MESHY
APIKEY=msy_在此粘贴密钥
验证密钥
STATUS=$(curl -s -o /dev/null -w %{http_code} \
-H Authorization: Bearer $MESHY
APIKEY \
https://api.meshy.ai/openapi/v1/balance)
if [ $STATUS = 200 ]; then
BALANCE=$(curl -s -H Authorization: Bearer $MESHYAPIKEY https://api.meshy.ai/openapi/v1/balance)
echo 密钥有效。$BALANCE
else
echo 密钥无效 (HTTP $STATUS)。请检查密钥并重试。
fi
持久化密钥(仅当前项目):
bash
写入当前工作目录的 .env
echo MESHY
APIKEY=msy_在此粘贴密钥 >> .env
echo 已保存到 .env
重要提示:将 .env 添加到 .gitignore 以避免泄露密钥
grep -q ^\.env .gitignore 2>/dev/null || echo .env >> .gitignore
echo .env 已添加到 .gitignore
安全提醒: 密钥仅存储在您当前项目目录的 .env 中。切勿将此文件提交到版本控制。.env 已自动添加到 .gitignore。
步骤 1:在消耗积分前与用户确认计划
关键:在创建任何任务之前,向用户展示费用摘要并等待确认:
我将使用以下计划生成 <提示词> 的 3D 模型:
1. 预览(网格生成)— 20 积分
2. 细化(PBR 纹理)— 10 积分
3. 下载为 .glb
总费用:30 积分
当前余额: 积分
是否继续?
对于多步骤流水线(文本转 3D → 绑定 → 动画),预先显示完整的流水线费用。
注意: 绑定自动包含行走 + 奔跑动画,无需额外费用。仅当需要超出这些的自定义动画时才添加 动画(3 积分)。
意图 → API 映射
| 用户想要... | API | 端点 | 积分 |
|---|
| 从文本生成 3D 模型 | 文本转 3D | POST /openapi/v2/text-to-3d | 20 + 10 |
| 从单张图像生成 3D 模型 |
图像转 3D | POST /openapi/v1/image-to-3d | 20–30 |
| 从多张图像生成 3D 模型 | 多图像转 3D | POST /openapi/v1/multi-image-to-3d | 20–30 |
| 为现有模型添加新纹理 | 重新纹理 | POST /openapi/v1/retexture | 10 |
| 更改网格格式/拓扑 | 重新网格化 | POST /openapi/v1/remesh | 5 |
| 为角色添加骨架 | 自动绑定 | POST /openapi/v1/rigging | 5 |
| 为绑定角色添加动画 | 动画 | POST /openapi/v1/animations | 3 |
| 从文本生成 2D 图像 | 文本转图像