查询模特场景模版接口
1. 接口地址
https://hidreamai.com/api-pub/ec/v3/template/model/scene
2. 请求方式
GET
3. 请求参数
Header
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
Authorization | string | 是 | 客户授权Token |
Query Params
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
page_size | int | 否 | 数据分页参数,每页最大数据量,默认20, 最大100 |
page_index | int | 否 | 数据分页参数, 当前页数, 默认1 |
curl示例
curl -H 'Authorization: Bearer {USER_Authorization}' -X GET
-v 'https://hidreamai.com/api-pub/ec/v3/template/model/scene'
Python示例
import pprint
import requests
import uuid
USER_Authorization = <token>
# 请求头
headers = {
'Authorization': f'Bearer {USER_Authorization}'
}
# 请求参数
params = {
"page_size": 50,
"page_index": 1
}
# 发送GET请求
url = 'https://hidreamai.com/api-pub/ec/v3/template/model/scene'
response = requests.get(url, headers=headers, params=params)
# 处理响应
if response.status_code == 200:
if response.json()['code'] == 0:
results = response.json()['result']
pprint.pprint(results['templates'], indent=4)
print(f"total count is: {results['total_count']}")
else:
print(response.json()['code'], response.json()['message'])
else:
print(response.status_code)
4. 返回参数
参数 | 类型 | 说明 |
---|---|---|
code | int | 返回状态码 |
message | string | 返回状态信息 |
request_id | string | 本次请求的ID |
result | dict | 返回结果 |
其中返回结果 result
字段具体为:
参数 | 类型 | 说明 |
---|---|---|
templates | list | 模版信息列表 |
total_count | int | 模版总数量 |
total_page | int | 按当前分页后的总页数 |
其中templates
字段具体为
参数 | 类型 | 说明 |
---|---|---|
name_zh | string | 中文名称 |
name_en | string | 英文名称 |
id | str | 模版ID,发送生图任务时使用 |
show_image | float | 模版封面图url。注:可在地址后拼接参数?width=512获取特定大小的图 |
scenes_type | string | 场景类型:outdoor scenes: 室外场景, indoor scenes: 室内场景 |
region | string | 区域,中英文对照见被页面末尾 |
template_type | string | 模版类型。 2: 通用场景,通过prompt生成的场景,体现prompt特征,但是现实世界不存在; 3: 固定场景,某个世界上实际存在的场景 |
示例:
{
"code": 0,
"message": "Success",
"request_id": "0bd4eb63-6b3f-4f51-b1db-9f1399ba4890",
"result": {
"page_index": 1,
"page_size": 2,
"templates": [
{
"id": "ad31ef57-b87c-4d45-8af4-d781543d4c52",
"name_en": "tea",
"name_zh": "草地上",
"region": "North America",
"scenes_type": "outdoor scenes",
"show_image": "https://storage.hidreamai.com/image/j_6c7c8fb3-fa56-40df-84e5-05629955a99e.jpg",
"template_type": 3
},
{
"id": "96640bf3-7296-41fd-bfd5-b04f2155f975",
"name_en": "meadow",
"name_zh": "牧场草地",
"region": "Oceania",
"scenes_type": "indoor scenes",
"show_image": "https://storage.hidreamai.com/image/j_e2a150b8-3285-4e6b-97c4-13a334716b07.jpg",
"template_type": 2
}
],
"total_count": 63,
"total_page": 16
}
}
附
区域中英文对照
[
{
"name_zh": "欧洲",
"name_en": "Europe"
},
{
"name_zh": "北美",
"name_en": "North America"
},
{
"name_zh": "南美",
"name_en": "South America"
},
{
"name_zh": "亚洲",
"name_en": "Asia"
},
{
"name_zh": "非洲",
"name_en": "Africa"
},
{
"name_zh": "大洋洲",
"name_en": "Oceania"
}
]