Relief API
Turn one photo into a bas-relief 3D model and a 16-bit depth map, for 3D printing, laser engraving, and CNC carving.
Moving from v1? The request is the same, except that target_formats defaults to ["glb"]. To keep the STL file, send "target_formats": ["glb", "stl"]. model_urls, texture_urls, depth_map_url, and thumbnail_url are in output, where an empty depth_map_url or thumbnail_url is null.
Create a Relief task
Creates a Relief task and returns the task object. When it succeeds, the task produces the model in the formats in target_formats, a 16-bit grayscale depth map, and a preview image. To get only the depth map, set should_generate_model to false.
The task runs in the background. To read its result, see Get the result.
A Relief task can't be the input of another endpoint, such as Remesh, Convert, or Auto Split. Those requests return 403.
curl https://api.meshy.ai/openapi/v2/relief \
-X POST \
-H "Authorization: Bearer ${MESHY_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"image_url": "https://cdn.meshy.ai/webapp-assets/doc/try-it/v2/inputs/golden-puppy.0dedab91e14d.webp"
}'Parameters
- Name
- image_url
- Type
- string
- Required
- Description
The photo to turn into a relief, as a public URL or a data URI (
data:image/png;base64,...).The image must be a JPG, JPEG, PNG, or WebP file of at most 20 MB, and at least 32 × 32 pixels. Its longer side can be at most about 16 times its shorter side. Any other image returns
400. Meshy fills transparent areas with black before it builds the relief.
- Name
- variant
- Type
- string
- default low
- Description
The relief style. It shapes the depth map and sets the default
carving_depth_mm.Try and previewAvailable values:
high: deeper carving, for 3D-printed pieces.low: shallow carving, for laser engraving, CNC carving, and thin plaques.
Sending
nullor""is the same as leaving it out. Any other value returns400.
- Name
- should_generate_model
- Type
- boolean
- default true
- Description
Whether to build the relief model. Set it to
falsefor a depth-map-only task, with no model and no preview image. Meshy still checks the size, carving, base, bend, resolution, format, and color parameters, but doesn't use them. It doesn't change the credit cost.Try and preview
- Name
- size_mm
- Type
- number
- default 60
- Description
The length of the photo's longer side on the model, measured flat before any bend, from
20to250millimeters. Withremove_base, the model can be smaller.
- Name
- carving_mode
- Type
- string
- default emboss
- Description
Whether the subject stands out from the plate or is cut into it.
Try and previewAvailable values:
emboss: the nearer parts of the photo stand out.engrave: the depth is inverted, so the nearer parts are cut in.
The depth map is the same in both modes.
- Name
- carving_depth_mm
- Type
- number
- default 6 (high), 3 (low)
- Description
How deep the relief is carved, from
0to60millimeters. Withremove_baseset totrue,0leaves an empty model. The task still succeeds and costs 20 credits, and its model files have no geometry.
- Name
- remove_base
- Type
- boolean
- default false
- Description
Whether to cut away the background and build no base plate. When it's
true,removal_thresholdsets what counts as background. Meshy checksremoval_thresholdeither way.Try and preview
remove_base = true- Name
- removal_threshold
- Type
- number
- default 0.01
- Description
The depth below which Meshy cuts the background away, from
0.01to1, where the depth map runs from0to1. A high value can cut away the whole relief and leave an empty model, which still succeeds and is charged.
- Name
- base_thickness_mm
- Type
- number
- default 1, or 0 with remove_base
- Description
The thickness of the base plate, from
0.1to10millimeters. Whenremove_baseistrue, leave it out or send0.
- Name
- bend_mode
- Type
- string
- default off
- Description
Whether to bend the relief, and which way. When it isn't
off,bend_axisandbend_angleshape the bend. Meshy checks them either way.Try and previewAvailable values:
off: a flat relief.convex: the front bulges outward.concave: the front curves inward.
bend_mode = convex or concave- Name
- bend_axis
- Type
- string
- default xz
- Description
Which edges the bend curls.
Available values:
xz: the left and right edges.yz: the top and bottom edges.
- Name
- bend_angle
- Type
- number
- default 60
- Description
The arc the bend spans, from
0to360degrees. Below1, the relief stays flat.
- Name
- mesh_resolution
- Type
- integer
- default 1024
- Description
The number of mesh points along the photo's longer side, from
512to2048. A higher value keeps finer detail and makes larger files. At the default1024, the GLB file is about 40 to 50 MB and the STL file about 80 to 105 MB. A square photo gives the larger sizes. At2048, they are about 150 MB and 300 MB. A bend makes them larger: the STL file can reach about 800 MB at2048.Try and preview
- Name
- target_formats
- Type
- string[]
- default ["glb"]
- Description
The file formats to generate. Meshy generates and returns only the formats you list, which can shorten the task.
Try and previewAvailable values:
glbobjfbxstlusdz3mf
STL and 3MF files keep the relief's real size.
- Name
- color_mapping
- Type
- boolean
- default false
- Description
Whether to color the model with the photo. The GLB, OBJ, FBX, and USDZ files carry color. STL and 3MF files stay white. The task returns the texture in
texture_urls. It doesn't change the credit cost.Try and preview
Returns
202 Accepted with the task object. The task starts as PENDING, with your request in input and output set to null.
A Relief task costs 20 credits, refunded if it fails. For what a delete refunds, see Delete a task.
Two response headers help you read the task:
Location: the task's URL on TasksRetry-After: how many seconds to wait before you first read it
Failure modes
- Name
400 - Bad Request- Description
The request can't run. For example:
image_urlis missing.- A parameter has the wrong type, is outside its range, or isn't one of its available values. For example,
variantisn'thighorlow,mesh_resolutionisn't an integer from512to2048, ortarget_formatslists an unknown format. base_thickness_mmisn't0withremove_baseset totrue, or is below0.1without it.- The image can't be downloaded.
- The image isn't a JPG, JPEG, PNG, or WebP file, is over 20 MB, is smaller than 32 × 32 pixels, has too many pixels, or can't be read.
- The image's longer side is more than about 16 times its shorter side.
The error message says which problem it found. Meshy doesn't charge for a request that returns
400. See Errors.
- Name
401 - Unauthorized- Description
The API key is missing or invalid. Check the
Authorizationheader.
- Name
402 - Payment Required- Description
One of these applies:
- The account doesn't have enough credits.
- The account reached a credit limit.
- The account is on the free plan.
Check your credits and plan, then retry.
- Name
403 - Forbidden- Description
Content moderation blocked the image. Send a different image. See Errors.
- Name
429 - Too Many Requests- Description
One of these limits was reached:
- You sent too many requests. Wait the number of seconds in
Retry-After, then retry. - Too many of your tasks are queued or running. Wait for some to finish, then retry.
- On an unlimited plan with no credits left, you reached the number of tasks that can run without credits. Wait for a task to finish, or add credits.
- You sent too many requests. Wait the number of seconds in
If a safety check declines the image while the task runs, the task fails with task_error.type set to invalid_input and task_error.code set to provider_content_refused. Meshy refunds the task's credits. Send a different image. See Errors.
Get the result
Read Relief tasks the same way as every other v2 task, through the Tasks routes. To list only Relief tasks, filter by type=relief.
| To | Call |
|---|---|
| Get one task | GET /openapi/v2/tasks/{id} |
| Wait for updates | GET /openapi/v2/tasks/{id}/stream or a webhook |
| List your tasks | GET /openapi/v2/tasks?type=relief |
| Delete a task | DELETE /openapi/v2/tasks/{id} |
Relief output
When the task succeeds, output holds these fields. The rest of the task object is the same for every task type. The URLs in output stop working at expires_at.
curl https://api.meshy.ai/openapi/v2/tasks/01a1e97f-c63f-74c4-a236-3868003e7385 \
-H "Authorization: Bearer ${MESHY_API_KEY}"Loading…- Name
- model_urls
- Type
- object
- Description
Signed URLs to the relief model, one per format in
target_formats, keyed by format. Anobjcomes with anmtl. The GLB file's units are meters. The STL file is binary, and its units are millimeters, so it opens at the relief's real size, with Z up. The files can be large;mesh_resolutionlists typical sizes.{}for a depth-map-only task (should_generate_modelset tofalse).
- Name
- texture_urls
- Type
- array
- Description
The texture of a colored model, as one item with a signed URL to its
base_colormap. The other maps arenull. Present only when you sentcolor_mapping: true.
- Name
- depth_map_url
- Type
- string | null
- Description
Signed URL to the 16-bit grayscale depth map the relief is built from. Brighter pixels are higher. The values are relative heights, not millimeters. Laser engraving and CNC software can use it as a height map. The file is about 1 to 2 MB.
nullif there is none.
- Name
- thumbnail_url
- Type
- string | null
- Description
Signed URL to a preview image of the relief model, or
nullif none was rendered, including for a depth-map-only task.