# Generate Texture

## 贴图生成

{% openapi src="/files/5w81V2d3ohxMjZNUCiOF" path="/api/v2/rodin\_texture\_only" method="post" %}
[tmp.yaml](https://563398440-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwiMYwiLTHWAzkgBEpY5K%2Fuploads%2Fgit-blob-74b44ac4fa8f9db435ebd9d2d2be7fc11aca2bbd%2Ftmp.yaml?alt=media)
{% endopenapi %}

## 贴图生成

使用此API向我们的服务器提交异步任务。你将从API中获得一个任务UUID，该UUID可用于[ 检查进度 ](/zh_cn/api-specification/check-status_reset_v.md)和[ 下载结果 ](/zh_cn/api-specification/download-results_reset_v.md)。

#### 价格

每次调用该API生成需要消耗 0.5 credits。

#### Request

{% hint style="info" %}
**Note**: 所有到这个端点的请求都必须使用`multipart/form-data`发送，以正确处理文件上传以及网格和纹理生成过程所需的其他参数。
{% endhint %}

**Authentication**

此API使用密钥进行身份验证。您需要在所有请求的`Authorization`头中包含一个有效的密钥. 参阅[快速开始](/zh_cn/get-started/readme.md#authentication-for-rodin-api)获取您的账户的API生成密钥。

```
Authorization: Bearer RODIN_API_KEY
```

**Body**

<table data-full-width="true"><thead><tr><th>参数</th><th>类型</th><th>描述</th></tr></thead><tbody><tr><td>image</td><td>file/Binary</td><td><strong>必须</strong>. 上传一张图片文件作为生成贴图的图片参考。</td></tr><tr><td>prompt</td><td>string</td><td>可选的。一段描述贴图的文字，指导贴图生成。</td></tr><tr><td>model</td><td>file/Binary</td><td><strong>必须</strong>. 上传一个二进制的三维模型文件进行处理。</td></tr><tr><td>seed</td><td>number</td><td>可选的。网格生成中用于随机化的种子值，范围从0到65535(包括两者)。如果不提供，种子将随机生成。</td></tr><tr><td>reference_scale</td><td>number</td><td>可选的。表示纹理生成过程中的参考尺寸。</td></tr><tr><td>geometry_file_format</td><td>string</td><td>可选的。模型文件的格式。可能的值为<code>glb</code>，<code>usdz</code>，<code>fbx</code>，<code>obj</code>，<code>stl</code>。默认值为<code>glb</code>。</td></tr><tr><td>material</td><td>string</td><td>可选的。材质类型。可能的值为<code>PBR</code>和<code>Shaded</code>。默认值为<code>PBR</code>。</td></tr><tr><td>resolution</td><td>string</td><td>可选的。 输出贴图的分辨率。可能的值为<code>Basic</code> 和 <code>High</code>. 默认是<code>Basic</code>.</td></tr></tbody></table>

#### 样例

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

```bash
export RODIN_API_KEY="your api key"
curl https://api.hyper3d.com/api/v2/rodin_texture_only \
  -H "Authorization: Bearer ${RODIN_API_KEY}" \
  -F "image=@/path/to/your/image.jpg" \
  -F "model=@path/to/your/model.obj"  \
  -F "reference_scale=1.0" \
  -F "geometry_file_format=glb" \
  -F "material=PBR" \
  -F "resolution=High"
unset RODIN_API_KEY
```

{% endtab %}

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

```python
import requests

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

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

# Prepare the form data
files = {
    'image': (os.path.basename(IMAGE_PATH), image_data, 'image/jpeg'),
    'model': (os.path.basename(MODEL_PATH), model_data, 'model/obj'),
    'reference_scale': (None, 1.0),
    'geometry_file_format': (None, 'glb'),
    'material': (None, PBR),
    'resolution': (None, 'High'),
}

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

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

```

{% 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 %}


---

# 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/zh_cn/api-specification/generate-texture_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.
