Create an Image-To-3D Session
Create a new Image-to-3D session by uploading an image and setting the desired parameters.
Request
POST https://api.csm.ai/image-to-3d-sessions
Parameters
image_url REQUIRED
type: string
in: body
description: URL of the image to be converted into 3D; can also be a base64 string of the image. If Base64, it must be prefixed with the MIME type, like data:<mediatype>
creativity OPTIONAL
type: string
in: body
default: "lowest"
example: "lowest"
description: Sets the creativity level for the session. Available options: highest, moderate, lowest
auto_refine OPTIONAL
type: boolean
in: body
default: false
description: Enables or disables automatic refinement.
refine_speed OPTIONAL
type: string
in: body
default: "slow"
example: "slow"
description: Sets the refinement speed for the session. Available options: fast, slow
preview_mesh OPTIONAL
type: string
in: body
default: "fast_sculpt"
example: "fast_sculpt"
description: Indicates the model used for the created session. Available options: fast_sculpt, turbo
topology OPTIONAL
type: string
in: body
default: "tris"
example: "tris"
description: Specifies the topology for enterprise users. Available options: tris, quads
Note: This option is available for enterprise users only.
resolution OPTIONAL
type: string
in: body
default: "high_poly"
description: Defines the resolution for enterprise users. Available resolutions: low_poly, high_poly
Note: This option is available for enterprise users only.
texture_resolution OPTIONAL
type: number
in: body
default: 2048
example: 2048
description: Sets the texture resolution for enterprise users. Available options: 128, 256, 512, 1024, 2048
Note: This option is available for enterprise users only.
scaled_bbox OPTIONAL
type: array
in: body
example: [1.0, 1.0, 1.0]
description: Scaled bounding box describing the target dimensions of the generated asset. This is a list of 3 float numbers: [width, height, depth]
.
Note: This option is available for enterprise users only.
pivot_point OPTIONAL
type: array
in: body
example: [0.0, 0.0, 0.0]
description: Sets the pivot point or origin of the exported mesh. The pivot point is specified as a list of 3 float values, representing the x, y, and z coordinates. Values range from
and are normalized to the mesh's bounding box dimensions. Examples:[-0.5, 0.5]
- Center of bounding box:
(default)[0, 0, 0]
- Left-bottom-back corner:
[-0.5, -0.5, -0.5]
- Center-bottom:
[0, -0.5, 0]
Note: This option is available for enterprise users only.
Code Snippets
Python
import requests
import json
url = "https://api.csm.ai/image-to-3d-sessions"
payload = json.dumps({
"image_url": "https://via.placeholder.com/300/09f/fff.png",
"refine_speed": "fast",
"creativity": "lowest",
})
headers = {
'x-api-key': '<X-API_KEY>',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Node.js
var request = require('request');
var options = {
method: 'POST',
url: 'https://api.csm.ai/image-to-3d-sessions',
headers: {
'x-api-key': '<X-API_KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"image_url": "https://via.placeholder.com/300/09f/fff.png",
"refine_speed": "fast",
"creativity": "lowest",
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Curl
curl -k --location 'https://api.csm.ai/image-to-3d-sessions' \
--header 'x-api-key: <X-API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"image_url": "https://via.placeholder.com/300/09f/fff.png",
"refine_speed": "fast",
"creativity": "lowest"
}'
Response
{
"error": "",
"message": "Created",
"statusCode": 201,
"data": {
"_id": "669924dCCCCCCCa04a493d12",
"user_id": "63XXXXXXXXXXXX0551638c",
"session_code": "SESSION_1721312476_7674068",
"image_url": "https://via.placeholder.com/300/09f/fff.png",
"texture_resolution": 2048,
"status": "spin_generate_processing",
"topology": "tris",
"source": "external",
"creativity": "lowest",
"refine_speed": "fast",
"created_at": "2024-07-18T14:21:18.050Z",
"updated_at": "2024-07-18T14:21:20.582Z"
}
}