Create 3D Generation Project
AI 生成虚拟 3D 空间(如客厅、卧室等)
Endpoint
POST https://openapi.kujiale.com/v2/aholo/project/create-3d-gen
Content-Type: application/json
Authentication
需要签名认证 + appuid 参数。
Request
Query Parameter
| Parameter | Required | Type | Description |
|---|---|---|---|
| appuid | Yes | String | 第三方用户ID |
Request Body
json
{
"projectName": "我的客厅",
"cover": "https://cdn.kujiale.com/path/to/cover.jpg",
"accessLevel": 0,
"prompt": "生成客厅空间",
"resources": [
{
"name": "客厅.jpg",
"type": 0,
"url": "https://cdn.kujiale.com/path/to/input.jpg",
"meta": {
"width": 1920,
"height": 1080,
"duration": null
}
}
]
}
Fields
| Field | Required | Type | Description |
|---|---|---|---|
| projectName | Yes | String | 项目名称 |
| cover | No | String | 封面图 URL |
| accessLevel | No | Int | 访问级别,默认 0。0=公开, 1=私有 |
| prompt | No | String | AI 提示词,描述要生成的空间 |
| resources | No | Array | 输入资源列表(可选,纯文本生成时可不传) |
Resource Object
| Field | Required | Type | Description |
|---|---|---|---|
| name | Yes | String | 资源名称 |
| type | Yes | Int | 资源类型。0=图片 |
| url | Yes | String | 资源 URL,来自 Upload |
| meta | Yes | Object | 资源元信息 |
| meta.width | Yes | Int | 宽度(像素) |
| meta.height | Yes | Int | 高度(像素) |
| meta.duration | Yes | Int/null | 时长(视频用,图片为 null) |
Response
json
{
"c": "0",
"d": "3FO4K4WF1A22",
"m": null,
"f": ""
}
| Field | Type | Description |
|---|---|---|
| c | String | 状态码,"0" 表示成功 |
| d | String | 项目ID (projectId) |
Code Examples
Python
python
import requests
APPUID = "your_appuid"
BASE_URL = "https://openapi.kujiale.com/v2/aholo"
def create_3d_gen_project(image_url, project_name, prompt=None):
"""创建 3D 生成项目"""
payload = {
"projectName": project_name,
"cover": image_url,
"accessLevel": 0,
"resources": [
{
"name": "input.jpg",
"type": 0,
"url": image_url,
"meta": {
"width": 1920,
"height": 1080,
"duration": None
}
}
]
}
if prompt:
payload["prompt"] = prompt
response = requests.post(
f"{BASE_URL}/project/create-3d-gen",
params={"appuid": APPUID},
json=payload
# 注意:实际需添加签名认证
)
if response.json()["c"] != "0":
raise Exception("创建项目失败")
project_id = response.json()["d"]
print(f"✓ 项目创建成功: {project_id}")
return project_id
# 使用示例 - 从图片生成
project_id = create_3d_gen_project(
image_url="https://cdn.kujiale.com/path/to/image.jpg",
project_name="AI客厅",
prompt="现代简约风格的客厅,有沙发和电视"
)
# 使用示例 - 纯文本生成
def create_3d_gen_from_text(project_name, prompt):
"""纯文本生成 3D 空间"""
payload = {
"projectName": project_name,
"prompt": prompt
}
response = requests.post(
f"{BASE_URL}/project/create-3d-gen",
params={"appuid": APPUID},
json=payload
)
return response.json()["d"]
project_id = create_3d_gen_from_text(
"幻想森林",
"一个神秘的森林,有发光的蘑菇和萤火虫"
)
JavaScript
javascript
const APPUID = 'your_appuid';
const BASE_URL = 'https://openapi.kujiale.com/v2/aholo';
async function create3dGenProject(imageUrl, projectName, prompt = null) {
const payload = {
projectName: projectName,
cover: imageUrl,
accessLevel: 0,
resources: [
{
name: 'input.jpg',
type: 0,
url: imageUrl,
meta: {
width: 1920,
height: 1080,
duration: null
}
}
]
};
if (prompt) {
payload.prompt = prompt;
}
const response = await fetch(
`${BASE_URL}/project/create-3d-gen?appuid=${APPUID}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
}
);
const data = await response.json();
if (data.c !== '0') {
throw new Error('创建项目失败');
}
return data.d; // projectId
}
cURL
bash
curl -X POST "https://openapi.kujiale.com/v2/aholo/project/create-3d-gen?appuid=your_appuid" \
-H "Content-Type: application/json" \
-d '{
"projectName": "我的客厅",
"cover": "https://cdn.kujiale.com/path/to/cover.jpg",
"prompt": "生成客厅空间",
"resources": [
{
"name": "客厅.jpg",
"type": 0,
"url": "https://cdn.kujiale.com/path/to/input.jpg",
"meta": {"width": 1920, "height": 1080, "duration": null}
}
]
}'
Notes
- 项目类型: 生成项目 (
projectType=1) - 适用场景: AI 虚拟空间生成(客厅、卧室、办公室等)
- 对比重建: 重建项目从真实图片/视频恢复,生成项目可纯文本创建
Error Codes
| Code | Description |
|---|---|
| -1 | 调用失败 |