Image to 3D

The base URL for sudoAI API endpoints is: https://platform.sudo.ai

Create a task

Used to create a task to generate 3D model from a single image.

Request : POST /api/v1/image-to-3d

Curl Request

curl https://platform.sudo.ai/api/v1/image-to-3d \
  -H "x-api-key: Your API Key" \
  -H 'Content-Type: application/json' \
  -d '{
    "image_url": "https://assets.sudo.ai/public/examples/example.png",
    "segm_mode": "auto"
  }'

Parameters

ParameterTypeRequiredDescription
image_urlStringYes
  • The image URL should be downloadable, sudoAI will download the image to generate 3D model. Or you can pass image in base 64 encoded format.
  • We support .jpg .jpeg .png .webp formats currently.
segm_modeStringYes
  • The segmentation mode should be either auto or manual.
  • In most cases, auto should be used. Use manual if the input image has been processed to contain only a single object and a transparent background.

Example: Request body with image URL (JSON)

{
  "image_url": "https://assets.sudo.ai/public/examples/example.png",
  "segm_mode": "auto"
}

Example: Uploading base 64 encoded image (Python)

import base64
import requests

# sudoAI API Key
api_key = "YOUR_SUDOAI_API_KEY"

def encode_image(image_path):
  with open(image_path, "rb") as image_file:
    return base64.b64encode(image_file.read()).decode('utf-8')

# Your local image path
image_path = "path_to_your_image.jpg"

# Encode the image to base64 string
base64_image = encode_image(image_path)

headers = {
  "Content-Type": "application/json",
  "x-api-key": f"{api_key}"
}

payload = {
  "image_url": f"data:image/jpeg;base64,{base64_image}",
  "segm_mode": "auto"
}

response = requests.post("https://platform.sudo.ai/api/v1/image-to-3d", headers=headers, json=payload)

print(response.json())

Response

NameDescription
idThe id of the task.

Example

{
  "id": "be64d0d8de624799a8394e68daaea6bc"
}

Retrieve a task

Used to retrieve the information of a 3D model generation task.

Request : GET /api/v1/image-to-3d/:id

Curl Request

curl https://platform.sudo.ai/api/v1/image-to-3d/:id \
  -H "x-api-key: Your API Key"

Parameters

nameDescription
idThe id of task returned from image-to-3d API.

Response

NameDescription
idThe id of the task.
statusThe status of a task should be one of the following: created, pending, processing, failed, or success.
thumbnailThe URL of thumbnail image for the generated model. It is only present if the task succeeds.
glbThe URL of generated glb model. It is only present if the task succeeds.
errorThe object contains error information, including the code and the message fields. It is only present if the task fails.

Error explanation

CodeMessage
10001Task failed due to unsupported image format or content.
10002Task failed due to the provided image being unable to be downloaded.
10003Task failed due to internal processing error.
10004Task failed due to segmentation error.

Example

Processing task

{
  "id": "be64d0d8de624799a8394e68daaea6bc",
  "status": "processing"
}

Succeeded task

{
  "id": "be64d0d8de624799a8394e68daaea6bc",
  "status": "success",
  "models": {
    "glb": "https://assets.sudo.ai/example.glb"
  },
  "thumbnail": "https://assets.sudo.ai/example.jpg"
}

Failed task

{
  "id": "be64d0d8de624799a8394e68daaea6bc",
  "status": "failed",
  "error": {
    "code": 10001,
    "message": "Task failed due to unsupported image format or content."
  }
}
Last Updated: