API Reference#

class csm.BackendClient(api_key=None, base_url='https://api.csm.ai')[source]#

A backend client class for raw GET/POST requests to the REST API.

Warning

This class should not be accessed directly. Instead, use CSMClient to interface with the API.

Parameters:
  • api_key (str, optional) – API key for the CSM account you would like to use. If not provided, the environment variable CSM_API_KEY is used instead.

  • base_url (str) – Base url for the API. In general this should not be modified; it is included only for debugging purposes.

create_image_to_3d_session(image_url, *, generate_preview_mesh=False, auto_refine=False, creativity='lowest', refine_speed='fast', polygon_count='high_poly', topology='tris', texture_resolution=2048, scaled_bbox=[], pivot_point=[0.0, 0.0, 0.0])[source]#
create_text_to_image_session(prompt, style_id='', guidance=6)[source]#
get_3d_preview(session_code, spin_url=None, scaled_bbox=[], pivot_point=[0.0, 0.0, 0.0])[source]#
get_3d_refine(session_code, scaled_bbox=[], pivot_point=[0.0, 0.0, 0.0])[source]#
get_image_to_3d_session_info(session_code)[source]#
get_text_to_image_session_info(session_code)[source]#
property headers#
class csm.CSMClient(api_key=None, base_url='https://api.csm.ai')[source]#

Core client utility for accessing the CSM API.

Parameters:
  • api_key (str, optional) – API key for the CSM account you would like to use. If not provided, the environment variable CSM_API_KEY is used instead.

  • base_url (str) – Base url for the API. In general this should not be modified; it is included only for debugging purposes.

image_to_3d(image, *, generate_spin_video=False, mesh_format='obj', output='./', timeout=200, verbose=True, scaled_bbox=[], pivot_point=[0.0, 0.0, 0.0], refine_speed='fast')[source]#

Generate a 3D mesh from an image.

The input image can be provided as a URL, a local path, or a PIL.Image.Image.

Parameters:

image (str or PIL.Image.Image) – The input image. May be provided as a url, a local path, or a PIL.Image.Image instance.

Returns:

Result object. Contains the local path of the generated mesh file.

Return type:

ImageTo3DResult

text_to_3d(prompt, *, style_id='', guidance=6, generate_spin_video=False, mesh_format='obj', output='./', timeout=200, verbose=True, scaled_bbox=[], pivot_point=[0.0, 0.0, 0.0], refine_speed='fast')[source]#

Generate a 3D mesh from a text prompt.

Parameters:

prompt (str) – The input text prompt.

Returns:

Result object. Contains the local path of the generated mesh file, as well as the image that was generated as part of the pipeline.

Return type:

TextTo3DResult

class csm.ImageTo3DResult(session_code: str, mesh_path: str)[source]#

Output class for image-to-3d generation.

Parameters:
  • session_code (str) – The image-to-3d session code.

  • mesh_path (str) – Local path of the generated mesh file.

mesh_path: str#
session_code: str#
class csm.TextTo3DResult(session_code: str, mesh_path: str, image_path: str)[source]#

Output class for text-to-3d generation.

Parameters:
  • session_code (str) – The image-to-3d session code.

  • mesh_path (str) – Local path of the generated mesh file.

  • image_path (str) – Local path of the image generated as part of text-to-3d.

image_path: str#
mesh_path: str#
session_code: str#