File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,19 @@ updatedAt: 2025-05-08
1313
1414## 请求
1515
16+ > [ !TIP]
17+ > ` {api_url} ` 为你实际使用的 API 节点,请根据实际情况填写。例如:
18+ > - ` www.dmxapi.cn `
19+ > - ` www.dmxapi.com `
20+ > - ` ssvip.dmxapi.com `
21+
22+
1623- 请求方式: GET
1724
1825- 请求地址: ` API对应请求接口/{task_id} `
19- - 例如 ` https://{api_url}/kling/v1/images/generations/{task_id} `
26+ - 例如针对 [ 生成图像 API] ( ./generate-image.md ) :
27+ - ` https://{api_url}/kling/v1/images/generations/{task_id} `
28+
2029
2130## 请求参数
2231
@@ -48,4 +57,4 @@ updatedAt: 2025-05-08
4857> 深色背景为可以修改的参数,非必选参数已经注释,可以按照自己的需求启用。
4958
5059
51- <<< @/zh/snippets/query-api.py{5-6,21-25,44 }
60+ <<< @/zh/snippets/query-api.py{5-6,22,42 }
Original file line number Diff line number Diff line change @@ -18,11 +18,8 @@ def query_kling_image_url(task_id):
1818 成功时: 返回生成图像的URL地址
1919 任务未完成或失败: 返回None
2020 """
21- action = "images"
22- action2 = "generations"
23-
2421 # 根据请求接口,构建完整的查询路径,包含task_id参数
25- query_path = f"/kling/v1/{ action } / { action2 } /{ task_id } "
22+ query_path = f"/kling/v1/images/generations /{ task_id } "
2623 # 构建请求头,包含鉴权消息
2724 headers = {
2825 'Authorization' : f'Bearer { DMX_API_TOKEN } '
@@ -35,7 +32,8 @@ def query_kling_image_url(task_id):
3532 # print(json_data)
3633 # 检查任务状态,如果成功则返回第一张图像的URL,否则返回None
3734 if json_data ['data' ]['task_status' ] == "succeed" :
38- return json_data ['data' ]['task_result' ]['images' ][0 ]['url' ]
35+ image_urls = [image ['url' ] for image in json_data ['data' ]['task_result' ]['images' ]]
36+ return image_urls
3937 else :
4038 return None
4139
You can’t perform that action at this time.
0 commit comments