# Gen-2 Generation

{% openapi src="<https://3170127470-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fve7H9sNOF32Exg6OAhKo%2Fuploads%2Fgit-blob-1b1889266f089d9cdd86238f28fe566ff6c96e8b%2Ftmp_gen2.yaml?alt=media>" path="/api/v2/rodin" method="post" %}
[tmp\_gen2.yaml](https://3170127470-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fve7H9sNOF32Exg6OAhKo%2Fuploads%2Fgit-blob-1b1889266f089d9cdd86238f28fe566ff6c96e8b%2Ftmp_gen2.yaml?alt=media)
{% endopenapi %}

## Rodin Generation - Gen-2

### ***Post requests with 'tier=Gen-2' to invoke Gen-2 generation.***

Use this API to submit an asynchronous task to our server. You will get a task UUID from the API which can be used to [check the status ](https://developer.hyper3d.ai/api-specification/check-status_reset_v)of the the task and [download the result ](https://developer.hyper3d.ai/api-specification/download-results_reset_v)when the task is ready.

### Pricing

{% hint style="info" %}
**Note**: There are no additional fees for parameters. Only addons incur extra charges.
{% endhint %}

* **Base Cost**: 0.5 credit per generation.
* **Addons**:
  * `HighPack`: Additional 1 credit per generation.

### Request

{% hint style="info" %}
**Note**: All requests to this endpoint must be sent using `multipart/form-data` to properly handle the file uploads and additional parameters required for the mesh and texture generation process.
{% endhint %}

#### Authentication

This API uses bearer key for authentication. You need to include a valid token in the `Authorization` header for all requests.

```
Authorization: Bearer RODIN_API_KEY
```

#### **Body**

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>tier</strong></td><td>string</td><td><em><strong>Set the value to <code>Gen-2</code> to invoke Gen-2 generaion</strong></em>.<br>Required. Tier of generation.<br>The default value is <code>Regular</code>.</td></tr><tr><td>images</td><td>file/Binary</td><td>Images to be used in generation, up to 5 images. As the form data request will preserve the order of the images, the first image will be the image for material generation.<br>For Image-to-3D generation: required (one or more images are needed, maximum 5 images)<br>For Text-to-3D generation: null</td></tr><tr><td>prompt</td><td>string</td><td>A textual prompt to guide the model generation.<br>For Image-to-3D generation: optional (if not provided, an AI-generated prompt based on the provided images will be used)<br>For Text-to-3D generation: required</td></tr><tr><td>use_original_alpha</td><td>boolean</td><td>Default is <code>false</code>. If <code>True</code>, the original transparency channel of the images will be used when processing the image.</td></tr><tr><td>seed</td><td>number</td><td>Optional. A seed value for randomization in the mesh generation, ranging from 0 to 65535 (both inclusive). If not provided, the seed will be randomly generated.</td></tr><tr><td>geometry_file_format</td><td>string</td><td>Optional. The format of the output geometry file. Possible values are <code>glb</code>, <code>usdz</code>, <code>fbx</code>, <code>obj</code>, and <code>stl</code>. Default is <code>glb</code>.</td></tr><tr><td>material</td><td>string</td><td>Optional. The material type. Possible values are <code>PBR</code>, <code>Shaded</code> and <code>All</code>. Default is <code>PBR</code>.<br><code>PBR</code>: Physically Based Materials, including base color texture, metallicness texture, normal texture and roughness texture, providing high realism and physically accurate over dynamic lighting.<br><code>Shaded</code>: Only base color texture with baked lighting, providing stylized visuals.<br><code>All</code>: Both <code>PBR</code> and <code>Shaded</code> will be delivered.<br><code>None</code>: Asset without material.</td></tr><tr><td>quality</td><td>string</td><td>Optional. The generation quality.<br>Possible values are <code>high</code>, <code>medium</code>, <code>low</code>, and <code>extra-low</code>.<br>For <code>Raw</code>: <code>high</code>: 500k, <code>medium</code>: 150k, <code>low</code>: 20k, <code>extra-low</code>: 2k, Default is <code>high</code>.<br>For <code>Quad</code>: <code>high</code>: 50k, <code>medium</code>: 18k, <code>low</code>: 8k, <code>extra-low</code>: 4k, Default is <code>medium</code>.</td></tr><tr><td>quality_override</td><td>number</td><td>Optional. Customize poly count for generation, providing more accurate control over mesh face count.<br>When <code>mesh_mode</code> = <code>Raw</code>: Range from 500 to 1,000,000. Default is 500,000.<br>When <code>mesh_mode</code> = <code>Quad</code>: Range from 1,000 to 200,000. Default is 18,000.<br><strong>Recommend 150,000+ faces for Gen-2.</strong><br>This parameter is an advanced parameter of <code>quality</code>. When this parameter is invoked, the <code>quality</code> parameter will not take effect.</td></tr><tr><td>TAPose</td><td>bool</td><td>Optional. When generating the human-like model, this parameter control the generation result to T/A Pose.<br>When <code>true</code>, your model will be either T pose or A pose.</td></tr><tr><td>bbox_condition</td><td>Array of Integer</td><td>Optional. This is a controlnet that controls the maxmimum sized of the generated model.<br>This array must contain 3 elements, Width(Y-axis), Height(Z-axis), and Length(X-axis), in this exact fixed sequence (y, z, x).</td></tr><tr><td>mesh_mode</td><td>string</td><td>Optional. It controls the type of faces of generated models, Possible values are <code>Raw</code> and <code>Quad</code>. Default is <code>Quad</code>.<br>The <code>Raw</code> mode generates <strong>triangular face</strong> models.<br>The <code>Quad</code> mode generates <strong>quadrilateral face</strong> models.<br>When its value is <code>Raw</code>, <code>addons</code> will be fixed to <strong><code>[]</code></strong>.</td></tr><tr><td>addons</td><td>array of strings</td><td>Optional. The default is <code>[]</code>. Possible values is <code>HighPack</code>.<br>By selecting <code>HighPack</code>:<br>Generate 4K resolution texture instead of the default 2K.<br>If <code>Quad</code> mode, the number of faces will be <strong>~16 times</strong> of the number of faces selected in the <code>quality</code> parameter.</td></tr><tr><td>preview_render</td><td>bool</td><td>Optional. Default is <code>false</code>.<br>If <code>true</code>, an additional high-quality render image will be provided in the download list.</td></tr><tr><td>hd_texture</td><td>bool</td><td>Optional. Default is <code>false</code>.<br>If <code>true</code>, high-quality texture will be provided.</td></tr></tbody></table>

{% hint style="info" %}
Rodin provides two generation modes:

* **Image-to-3D**:

  This mode is automatically selected when you upload one or more `images` files.

  * Single Image: Upload **one** image file to generate a 3D model.
  * Multiple Images: When uploading multiple images, they are automatically treated as multi-view captures of a single object. **The first image in the upload order will be used for material generation**.

  **Important Note**: Form data requests preserve the order of uploaded images. Ensure your images are in the correct sequence for optimal multi-view processing.
* **Text-to-3D**:

  This mode is automatically selected when you **do not** upload any image files.

  * Required Parameter:

    `prompt`: You must provide a text description to guide the 3D model generation.
  * Important: **No image files** should be uploaded when using Text-to-3D mode.
    {% endhint %}

{% hint style="info" %}
**ControlNet**: ControlNet enhances model customization by providing finer control over the generated outputs. It adds several parameters on top of the original request, allowing users to manipulate aspects such as proportions, shapes, and structures of 3D models.

ControlNet introduces the following main parameters to provide advanced control over the model generation process:

* **BoundingBox ControlNet**: The BoundingBox ControlNet allows users to define the proportions of the generated model by specifying the length, width, and height through a draggable bounding box. This is particularly useful when you want the generated object to fit within specific dimensions or adhere to certain spatial constraints.
  * Example Representation:

    ```
    {
    "bbox_condition": [
          100,
          100,
          100
      ]
    }
    ```
  * **bbox\_condition**: An array that specifies the dimensions and scaling factor of the bounding box.

    * Elements:
      1. Width (Y-axis):`100` units.
      2. Height (Z-axis):`100` units.
      3. Length (X-axis):`100` uints.

    By setting the `bbox_condition`, you're instructing the model to generate an object that fits within a box of the specified dimensions.
  * **Bounding Box Axis**:

    ```
          World               

        +z(Height)                                                    
        |                                                
        |                                                        
        |______+y(Width)        
        /                  
       /                      
      /                          
      +x(Length)                        
    ```

{% endhint %}

### **Response**

{% hint style="info" %}
Use the `uuid` field instead of the `jobs.uuids` field for your requests to [Check Status ](https://github.com/Deemos-Technology/docs/blob/main/developer-apis/api-specification/check-status.md)and [Download Results](https://github.com/Deemos-Technology/docs/blob/main/developer-apis/api-specification/download-results.md) API endpoints.
{% endhint %}

<table data-full-width="true"><thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>error</td><td>enum</td><td>Error message, if any.</td></tr><tr><td>message</td><td>string</td><td>Success message or detailed error information.</td></tr><tr><td>uuid</td><td>string</td><td>Unique identifier for the generated task.</td></tr><tr><td>jobs</td><td>object</td><td>A job object, containing details of individual jobs executed as part of the generation process.</td></tr><tr><td>jobs.uuids</td><td>array of strings</td><td>UUIDs of the sub-jobs.</td></tr><tr><td>jobs.subscription_key</td><td>string</td><td>Subscription key associated with these jobs.</td></tr></tbody></table>

Possible Errors include:

<table data-full-width="true"><thead><tr><th>Error</th><th>Description</th></tr></thead><tbody><tr><td>NO_ACTIVE_SUBSCRIPTION</td><td>Does not have an active subscription or the subscription of your account already expired.</td></tr><tr><td>SUBSCRIPTION_PLAN_TOO_LOW</td><td>Bussiness subscription is required to use Rodin Gen-2 API.</td></tr><tr><td>INSUFFICIENT_FUND</td><td>The user‘s account balance is insufficient to complete the requested operation.</td></tr><tr><td>INVALID_REQUEST</td><td>The request is malformed, missing required parameters, or contains invalid values. Check <code>message</code> for additional information.</td></tr><tr><td>USER_NOT_FOUND</td><td>API KEY invalid or user not exist.</td></tr><tr><td>GROUP_NOT_FOUND</td><td>API KEY invalid or group not exist.</td></tr><tr><td>PERMISSION_DENIED</td><td>The authenticated user does not have permission to perform this action.</td></tr><tr><td>UNKNOWN</td><td>An unexpected error occurred. Check <code>message</code> for additional information.</td></tr></tbody></table>

### **Examples**

#### Minimal Rodin Gen-2 Generation(Image-to-3D)

{% tabs %}
{% tab title="Request with cURL" %}

```bash
export RODIN_API_KEY="your api key"
curl https://api.hyper3d.com/api/v2/rodin \
  -H "Authorization: Bearer ${RODIN_API_KEY}" \
  -F "images=@/path/to/your/image.jpg" \
  -F "tier=Gen-2" 
unset RODIN_API_KEY
```

{% endtab %}

{% tab title="Request with Python 3" %}

```python
import os
import requests

# Constants
ENDPOINT = "https://api.hyper3d.com/api/v2/rodin"
API_KEY = os.getenv("HYPER3D_API_KEY")
IMAGE_PATH = "/path/to/your/image.jpg"  # Replace with the path to your image

# Read the image file
with open(IMAGE_PATH, 'rb') as image_file:
    image_data = image_file.read()

# Prepare the multipart form data
files = {
    'images': (os.path.basename(IMAGE_PATH), image_data, 'image/jpeg'),
    'tier':(None, 'Gen-2'),
}

# Prepare the headers
headers = {
    'Authorization': f'Bearer {API_KEY}',
}

# Make the POST request
response = requests.post(ENDPOINT, files=files, headers=headers)

# Parse and return the JSON response
print(response.json())
```

{% endtab %}

{% tab title="Request with Go" %}

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "mime/multipart"
    "net/http"
    "os"
    "path/filepath"
)

const BaseURI = "https://api.hyper3d.com/api"

type CommonError struct {
    Error   *string `json:"error,omitempty"`
    Message *string `json:"message,omitempty"`
}

type JobSubmissionResponse struct {
    Uuids           []string `json:"uuids"`
    SubscriptionKey string   `json:"subscription_key"`
}

type RodinAllInOneResponse struct {
    CommonError
    Uuid *string                 `json:"uuid,omitempty"`
    Jobs JobSubmissionResponse   `json:"jobs,omitempty"`
}

func RunRodin(token string, filePath string) (*RodinAllInOneResponse, error) {
    var err error
    var buffer bytes.Buffer

    // Create the form data for Rodin API
    writer := multipart.NewWriter(&buffer)

    // Read the image
    image, err := os.ReadFile(filePath)
    if err != nil {
        return nil, err
    }

    // Add the image as a form entry
    fieldWriter, err := writer.CreateFormFile("images", filepath.Base(filePath))
    if err != nil {
        return nil, err
    }

    if _, err = fieldWriter.Write(image); err != nil {
        return nil, err
    }

    err = writer.Close()
    if err != nil {
        return nil, err
    }

    // Set the tier to Rodin Gen-2
    fieldWriter, err = writer.CreateFormField("tier")
    if err != nil {
        return nil, err
    }

    if _, err = fieldWriter.Write([]byte("Gen-2")); err != nil {
        return nil, err
    }

    err = writer.Close()
    if err != nil {
        return nil, err
    }

    // Create the request
    req, err := http.NewRequest("POST", fmt.Sprintf("%s/v2/rodin", BaseURI), &buffer)
    if err != nil {
        return nil, err
    }

    // Set headers
    req.Header.Set("Authorization", "Bearer "+token)
    req.Header.Set("Content-Type", writer.FormDataContentType())

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()

    var responseData RodinAllInOneResponse
    err = json.NewDecoder(resp.Body).Decode(&responseData)
    if err != nil {
        return nil, err
    }

    if responseData.Error != nil {
        return nil, fmt.Errorf("%s: %s", *responseData.Error, *responseData.Message)
    }

    return &responseData, nil
}

func main() {
        // Replace with your actual API key
    token := "your api key"
    // Replace with the path to your image
    resp, _ := RunRodin(token, "/path/to/your/image.jpg")
    fmt.Println(resp)
}
```

{% endtab %}

{% tab title="Response" %}

```json
{
  "error": null,
  "message": "Submitted.",
  "uuid": "123e4567-e89b-12d3-a456-426614174000",
  "jobs": {
      "uuids": ["job-uuid-1", "job-uuid-2"],
      "subscription_key": "sub-key-1"
  }
}
```

{% endtab %}
{% endtabs %}

#### Minimal Rodin Gen-2 Generation(Text-to-3D)

{% tabs %}
{% tab title="Request with cURL" %}

```bash
export RODIN_API_KEY="your api key"
curl https://api.hyper3d.com/api/v2/rodin \
  -H "Authorization: Bearer ${RODIN_API_KEY}" \
  -F "prompt=A 3D model of a futuristic robot" \
  -F "tier=Gen-2" 
unset RODIN_API_KEY
```

{% endtab %}

{% tab title="Response" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "error": null,
  "message": "Submitted.",
  "uuid": "123e4567-e89b-12d3-a456-426614174000",
  "jobs": {
      "uuids": ["job-uuid-1", "job-uuid-2"],
      "subscription_key": "sub-key-1"
  }
}
</code></pre>

{% endtab %}
{% endtabs %}

#### Minimal Rodin Gen-2 Generation(Image-to-3D with multi-view images)

{% tabs %}
{% tab title="Request with cURL" %}

```bash
export RODIN_API_KEY="your api key"
curl https://api.hyper3d.com/api/v2/rodin \
  -H "Authorization: Bearer ${RODIN_API_KEY}" \
  -F "images=@/path/to/your/image_0.jpg" \
  -F "images=@/path/to/your/image_1.jpg" \
  -F "tier=Gen-2"
unset RODIN_API_KEY
```

{% endtab %}

{% tab title="Request with Python 3" %}

```python
import os
import requests

# Constants
ENDPOINT = "https://api.hyper3d.com/api/v2/rodin"
API_KEY = os.getenv("HYPER3D_API_KEY")
IMAGE_PATH_0 = "/path/to/your/image_0.jpg"  # Replace with the path to your image_0
IMAGE_PATH_1 = "/path/to/your/image_1.jpg"  # Replace with the path to your image_1

# Read the image file
with open(IMAGE_PATH_0, 'rb') as image_file:
    image_data_0 = image_file.read()

with open(IMAGE_PATH_1, 'rb') as image_file:
    image_data_1 = image_file.read()

# Prepare the multipart form data
files = {
    'images': (os.path.basename(IMAGE_PATH_0), image_data_0, 'image/jpeg'),
    'images': (os.path.basename(IMAGE_PATH_1), image_data_1, 'image/jpeg'),
    'tier': (None, 'Gen-2'),
}

# Prepare the headers
headers = {
    'Authorization': f'Bearer {API_KEY}',
}

# Make the POST request
response = requests.post(ENDPOINT, files=files, headers=headers)

# Parse and return the JSON response
print(response.json())
```

{% endtab %}

{% tab title="Response" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "error": null,
  "message": "Submitted.",
  "uuid": "123e4567-e89b-12d3-a456-426614174000",
  "jobs": {
      "uuids": ["job-uuid-1", "job-uuid-2"],
      "subscription_key": "sub-key-1"
  }
}
</code></pre>

{% endtab %}
{% endtabs %}

#### Comprehensive Rodin Gen-2 Generation with All Parameters

{% tabs %}
{% tab title="Request with cURL" %}

```bash
export RODIN_API_KEY="your api key"
curl https://api.hyper3d.com/api/v2/rodin \
  -H "Authorization: Bearer ${RODIN_API_KEY}" \
  -F "images=@/path/to/your/image.jpg" \
  -F "tier=Gen-2" \
  -F "prompt=A 3D model of a futuristic robot" \
  -F "mesh_mode=Raw" \
  -F "seed=42" \
  -F "geometry_file_format=fbx" \
  -F "material=PBR" \
  -F "quality_override=500000" \
unset RODIN_API_KEY
```

{% endtab %}

{% tab title="Response" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "error": null,
  "message": "Submitted.",
  "uuid": "123e4567-e89b-12d3-a456-426614174000",
  "jobs": {
      "uuids": ["job-uuid-1", "job-uuid-2"],
      "subscription_key": "sub-key-1"
  }
}
</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.hyper3d.ai/api-specification/rodin-generation-gen2_reset_v.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
