# optimize_3d_model

Check discovery first: this tool is served only where it is enabled and priced. It rebuilds a
textured model at the triangle count you choose (1,000–200,000) and bakes new base-colour,
metal/roughness and normal textures so the lighter model still looks like the original from
every side. Use it when `simplify_3d_model` cannot reach the count without damaging the
original textures, e.g. a
1,000,000-face `create_3d_model` output for a phone or AR.

Input: one self-contained, uncompressed `.glb` with a single material, up to 2,000,000
triangles, as `upload_id`, a public HTTPS `url`, or `job_file` (e.g. `model.glb` of a
`create_3d_model` job). Options: `target_faces` (1000–200000, default 50000),
`texture_resolution` (1024 or 2048, default 2048), optional `seed` (0–4294967295).
`idempotency_key` is **required**: repeating the same request with the same key returns the
same job instead of paying again.

The job is accepted asynchronously with a one-hour deadline from creation, including queueing and execution. `wait_seconds` is at
most 45, so poll `get_job` with `wait_seconds: 45` until the status is final; the job
reports `workflow.stage` and `workflow.deadline`. Do not start the job again while it runs.
While the job advertises `capabilities.can_cancel`, `cancel_job` cancels and refunds it.

Outputs: `model.glb` (one mesh with normals and tangents, three embedded textures, the
input's coordinates and scale) and `generation.json` (options, input and output triangle
counts, texture layout, timings). The target is a reduction request; an input already below it
keeps its geometry and receives new textures. Read the actual output count. Fine detail can soften.

Price: read `pricing` in `GET /v1/tools` before starting the job. The charge is made once
the input passes validation; a job that fails or is canceled is refunded. Free limits: 20 jobs
per rolling 24 hours (3 until the account's first credit purchase), models up to 50 MB.

Without MCP, send the file as the request body with an `Idempotency-Key` header:

```bash
curl "https://api.mcpbytes.com/v1/tools/optimize_3d_model/jobs?filename=model.glb&target_faces=15000" \
  -H "Authorization: Bearer $MCPBYTES_API_KEY" \
  -H "Content-Type: application/octet-stream" \
  -H "Idempotency-Key: my-model-15k" \
  --data-binary @model.glb
```

Handle `invalid_mesh` (not a readable, self-contained GLB), `limit_exceeded` (more than
2,000,000 triangles; a file over the plan's upload size is refused at once with HTTP 413
`too_large`), `unsupported_feature` (skinned,
animated or morph-target models, several used materials, vertex colours without a base-colour texture: export one static
textured mesh) and `timeout`. A failed job is refunded. Do not repeat a failed input unchanged.
