> For the complete documentation index, see [llms.txt](https://on-premises.docs.hyper3d.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://on-premises.docs.hyper3d.ai/mesh-generation/workflow.md).

# Workflow

The Rodin Mesh Generation Workflow is designed to convert 2D images into 3D meshes. This process involves several stages, from image preprocessing to the final generation of 3D meshes.

{% @mermaid/diagram content="sequenceDiagram
participant User as User
participant PreprocessAPI as Image Preprocessing API
participant MeshAPI as Mesh Generation API
participant UpdateAPI as Update API
participant ConfirmAPI as Confirm API

```
User->>PreprocessAPI: POST /api/task/rodin_mesh_image_process with image and flag
Note right of PreprocessAPI: API: rodin_preprocess_image
PreprocessAPI-->>User: Response with preprocessed image and prompt
User->>MeshAPI: POST /api/task/rodin_mesh with preprocessed image and prompt
Note right of MeshAPI: API: rodin_mesh
MeshAPI-->>User: Response with UUID and status
loop Query Task Status via Socket.IO
    User->>MeshAPI: Connect Socket.IO
    MeshAPI-->>User: Status update via Socket.IO
end
alt Task Satisfactory
    User->>ConfirmAPI: POST /api/task/rodin_confirm with UUID
    Note right of ConfirmAPI: API: rodin_confirm
    ConfirmAPI-->>User: Final confirmation
else Task Not Satisfactory
    User->>UpdateAPI: POST /api/task/rodin_update with new parameters
    Note right of UpdateAPI: API: rodin_update
    UpdateAPI-->>User: Updated task initiated
    loop Query Updated Task Status via Socket.IO
        User->>MeshAPI: Connect Socket.IO
        MeshAPI-->>User: Status update via Socket.IO
    end
    User->>ConfirmAPI: POST /api/task/rodin_confirm with UUID
    ConfirmAPI-->>User: Final confirmation after update
end
```

" %}

#### Image Preprocessing

* **API Used**: [`rodin_preprocess_image`](#image-preprocessing)
* **Purpose**: To preprocess the image using the Rodin API, which includes image matting and optional prompt generation based on the image content.
* **Process**:
  * The image, along with a flag indicating whether to generate a prompt, is sent to the Rodin preprocessing endpoint.
  * A multipart HTTP request is constructed with the image and the prompt generation flag.
  * The response from this API includes preprocessed image data and, if requested, a generated prompt that will guide the mesh generation.

#### Mesh Generation

* **API Used**: [`rodin_mesh`](/mesh-generation/rodin-mesh.md)
* **Purpose**: To generate a 3D mesh from the preprocessed images.
* **Process**:
  * Preprocessed images are prepared for upload.
  * A multipart HTTP request is constructed with the images, a text prompt (if generated in the previous step or provided manually), settings for the mesh generation, and the name of the mesh.
  * The request is sent to the Rodin mesh generation endpoint.
  * The API response includes a UUID for the generated mesh and a status message indicating the initiation of the mesh generation process.
* **Query Task Status**: After starting the mesh generation, monitor the job status as detailed in the [Query Task Status ](/task/query-task-status.md)section to ensure smooth progression and successful execution of subsequent steps.

#### Redo (Optional)

* **API Used**: [`rodin_update`](/mesh-generation/redo.md)
* **Purpose**: To update the mesh generation task with new parameters such as a different prompt or settings if the initial results are not satisfactory.
* **Process**:
  * The task UUID of the mesh generation task is used along with new parameters such as prompt and settings.
  * A POST request is sent to the Rodin update endpoint with the updated parameters.
* **Query Task Status**: After starting the mesh generation, monitor the job status as detailed in the [Query Task Status ](/task/query-task-status.md)section to ensure smooth progression and successful execution of subsequent steps.

#### Confirm

* **API Used**: [`rodin_confirm`](#confirm)
* **Purpose**: To finalize and confirm the mesh generation results.
* **Process**:
  * The task UUID and other parameters such as the quality, symmetry, version, and whether to use advanced settings are specified.
  * A POST request is sent to the Rodin confirm endpoint with these parameters.
  * The response typically includes a job's subscription key, indicating that a final processing task has been initiated to finalize the mesh.
* **Query Task Status**: After starting the mesh generation, monitor the job status as detailed in the [Query Task Status ](/task/query-task-status.md)section to ensure smooth progression and successful execution of subsequent steps.
