RGB to Depth
RGB2Depth converts one image into one grayscale heightmap PNG for relief work and height-field processing. Generation runs as an asynchronous task: submit the image, receive a task ID, query the task until it finishes, then download the result.
The image can be a public URL or the file_key returned by the upload API. The result is stored in the account's assets and can be found and downloaded from task history. Retention follows the account's asset retention rules.
The API base URL is https://api.triverse.ai/api/v1.
Create a Task
Endpoint
POST /tasks/rgb-to-depth
Authentication
Required (Bearer Token)
Request Parameters
Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
client_order_id | String | Yes | Caller-generated request ID, 1-64 characters, using letters, numbers, _, and -. Keep the same value and request body when retrying the same request. |
image_file | String | Yes | HTTP(S) URL of the image, or the full file_key returned by the upload API. After trimming whitespace it must not be empty, and it can be at most 8192 characters. |
name | String / Null | No | Display name, at most 255 characters. This is the task title. It is not the name of the downloaded file. |
is_public | Boolean / Null | No | Whether the result is public. When omitted, the account plan default is used. |
license | String / Null | No | Result license: cc-by-4.0 or proprietary. When omitted, it is determined from the plan and the public setting. |
Results generated on the Free plan are public and use the cc-by-4.0 license. Paid plans default to private results with the proprietary license. When a result is set to public, the license is always cc-by-4.0.
Image Requirements
| Item | Requirement |
|---|---|
| Format | Static PNG, JPEG, or WebP, determined from the actual file content. |
| File size | Default limit of 20 MiB (20,971,520 bytes). |
| Pixel count | Default limit of 40,000,000 pixels, calculated as width × height. |
| File integrity | The image must be complete and decodable, with both width and height greater than 0. |
| URL | A publicly readable HTTP(S) image address on port 80 or 443. A signature may be carried in the URL query parameters. |
| Upload reference | After a successful upload, pass data.file_key from the response unchanged. |
The image URL must stay reachable while the task is queued and processing. Fetching the image must not require a login, cookies, or custom request headers. Use a direct link to the image file, and confirm that the host allows server-side access.
The caller is responsible for the stability of external content. Each new task reads the image that the URL points to at execution time. To reuse the same image, use a URL with fixed content or upload the image to the platform first.
The upload API also accepts AVIF and files up to 50 MiB, and allows 10 uploads per 60 seconds, shared with model uploads. This endpoint still accepts only a static PNG, JPEG, or WebP within the limits above. A file outside those limits can upload and then be rejected when the task is created. An upload over the rate limit returns HTTP 429 / 2000.
Crop, contrast, and relief shape are fields of POST /tasks/relief. This endpoint rejects unknown fields.
Example Request
curl -X POST \
'https://api.triverse.ai/api/v1/tasks/rgb-to-depth' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"client_order_id": "rgb_example_001",
"image_file": "https://images.example.com/input.jpg",
"name": "Relief heightmap"
}'Replace image_file with the actual image address. When using a platform upload, use the full file_key from the upload response instead.
Example Response
{
"code": 0,
"message": "success",
"data": {
"task_uuid": "11111111-1111-4111-8111-111111111111",
"flow_name": "rgb-to-depth",
"status": "PENDING",
"created_at": "2026-10-26T00:00:00Z",
"cost_credits": 5
}
}HTTP 200 with code 0 means the task was accepted. During maintenance, HTTP 200 with code 2021 also means the task was accepted; generation continues after maintenance. Both responses include data.task_uuid. Any other non-zero code means the task was not accepted.
| Response field | Description |
|---|---|
code | 0 for normal acceptance. 2021 for acceptance during maintenance. |
data.task_uuid | Task ID, used for later status queries and downloads. |
data.flow_name | Task type. RGB2Depth returns rgb-to-depth. |
data.status | Current task status. Acceptance does not mean generation has finished. Status values and what to do next are in the table below. |
data.created_at | Creation time. |
data.cost_credits | Credit price fixed when this task was accepted. Credits are frozen on acceptance, settled on success, and released on failure. |
data.queue | Queue summary, when available. |
data.read_after_write_header | Present with code 2021. The header name to send on the following status read. The current value is X-Triverse-Read-Your-Writes. |
data.read_after_write_deadline_seconds | Present with the header name. During this many seconds, send that header with the value 1. |
The price is 5 credits per image. Before calling, use the pricing quote endpoint to check the latest price and available credits. The cost_credits in this response is the amount accepted for the task.
Retrying a Request
Save client_order_id, the full request JSON, and the returned task_uuid. If the create request times out or returns a service error, retry with the same ID and body. A request that was already accepted returns the original task, which avoids generating and charging twice.
Use a new client_order_id when changing the image or any other request field. Retrying a task that has already failed with the original request still returns the original task. To generate again, submit a new ID; it is billed as a new task.
Query Progress and Results
Use Task Status: GET /tasks/{task_uuid}.
data.status | Meaning | Next step |
|---|---|---|
PENDING | Accepted and waiting to be processed. | Keep querying. |
QUEUED | Waiting in the queue. | Keep querying. You can display the queue information in queue. |
RUNNING | Processing. | Keep querying. You can display progress. |
SUCCESS | Generation succeeded. | Get the download URL. |
FAILED | Generation failed. | Stop polling and read data.error. |
CANCELLED | The task was cancelled. | Stop polling. |
Query about every 3 to 5 seconds. When the create response includes read_after_write_header and read_after_write_deadline_seconds, send that header with the value 1 until the deadline passes. On a timeout, HTTP 5xx, or a top-level code=5003, increase the interval and keep querying the original task. When the client reaches its wait limit, save the task ID and query again later. The task can continue running on the server.
After success, data.output.assets contains the heightmap:
| Field | Description |
|---|---|
asset_id | Heightmap asset ID. |
role / kind / format | The primary result is primary / image / png. |
availability | AVAILABLE means the result is currently available. |
width / height | Pixel width and height of the original heightmap. |
bit_depth | Grayscale bit depth, 8 or 16. |
Download and Use the Heightmap
Call Download Assets: GET /tasks/url/{task_uuid}. Read data.download_url, then request that URL to download the original PNG. Do not send the API key to the file host. The download response also returns asset_id, preview_url, and an optional kind.
Signed download URLs expire. After expiry, request a new URL with the same task ID. Save the original PNG to your own storage when you need to keep the result.
Preserve the original bit depth when processing the heightmap. An 8-bit grayscale value is in the range 0-255, and a 16-bit value is in the range 0-65535. gray_value / (2^bit_depth - 1) gives a normalized value from 0 to 1, which you can then map to the height range your application needs.
Query Task History
Endpoint
GET /tasks/rgb-to-depth
Authentication
Required (Bearer Token)
Query Parameters
| Field | Type | Default | Description |
|---|---|---|---|
page_index | Integer | 1 | Page number, starting at 1. |
page_size | Integer | 20 | Items per page, from 1 to 100. |
curl -X GET \
'https://api.triverse.ai/api/v1/tasks/rgb-to-depth?page_index=1&page_size=20' \
-H 'Authorization: Bearer <YOUR_API_KEY>'The response is the paginated object itself. Unlike task creation, it is not wrapped in code, message, and data.
{
"records": [],
"total_records": 0,
"total_pages": 0,
"current_page": 1,
"page_size": 20
}| Field | Description |
|---|---|
records | Tasks on this page. |
total_records | Number of tasks that match the list. |
total_pages | Number of pages. |
current_page | Page requested in page_index. |
page_size | Page size requested. It is not the number of records returned on this page. |
Fields on each record in records are described in Task Status. The list is ordered by creation time, newest first, and includes RGB2Depth tasks created through the website and the API for the account, including heightmaps created with POST /tasks/relief and operation rgb-to-depth. This list does not refresh a running task. Running and failed tasks can be queried. After a successful result is deleted, expires, or becomes unavailable, its record may no longer appear. Query the latest progress of an active task through the status endpoint.
Error Handling
Request errors are returned with code, message, and an optional suggestion, for example:
{
"code": 1004,
"message": "One or more request parameters are invalid.",
"suggestion": "Review the parameter requirements (e.g. image sources, UUID format) and retry."
}| HTTP / business code | Meaning | What to do |
|---|---|---|
400 / 1004 | A parameter is invalid, an input reference is invalid, or the request ID conflicts with the original request body. Unknown fields are rejected. | Use message and suggestion to check the fields, the image source, and the saved original request. |
400 / 2008 | Content review rejected the image. | Use a different image. suggestion may include the review reason. |
401 / 1001 | The API key is invalid. | Check the key and the Authorization header, then retry. |
403 / 1005 | The key cannot access this resource, or the account is not allowed to create the task. | Check the key permission and the account from the response. |
403 / 2010 | Not enough available credits. The task was not created. | Add credits, then submit with a new client_order_id. |
404 / 1006 | The specified task was not found. | Check the task ID, account, and request URL. |
409 / 2005 | The result does not currently meet the download conditions. | Query the task status. Wait while it is processing. If it has already succeeded, retry the download later. Contact support if it stays unavailable. |
404 / 4042 | There is no downloadable output. | Check the task status and whether the result is still available. |
429 / 2000 | The number of concurrent generation tasks has reached the plan limit. | Wait for existing tasks to finish. If Retry-After is present, wait that long. Retry the same create body and client_order_id when no task ID was returned. |
200 / 2021 | The task was accepted during maintenance and is waiting for processing to resume. | Save data.task_uuid and keep querying. This is not a failure. |
503 / 5003 | The service is temporarily unavailable, and this request did not get a normal result. | Retry queries with backoff. Retry a create request with the original ID and body. |
data.status=FAILED means task execution failed. Stop polling and read data.error.code, message, and suggestion. Treat it as a terminal task status even when the error code inside it is 5003. 5005 is the generic processing-failure code. If the cause cannot be determined, give support the task ID, the time it happened, and the error response.
If an object-file download returns 403, request a new signed URL and download again. If it still fails, keep the task ID and contact support. When a result has been deleted or has expired, use the copy saved earlier.