首页
应用列表
解决方案
新闻动态
帮助文档
关于我们
立即体验
AIGCaaS 可查询历史记录与历史详情
首页
文章详情
Dec 27,2023
AIGCaaS 平台目前支持查询历史调用详情。尽管 AIGCaaS 已经提供了异步结果查询能力,但是异步结果查询只是工作态的查询(即有查询有效期,超过有效期之后即无法继续查询结果),而历史查询接口是当请求完成之后,数据入库之后,进行的历史存档查询;另外值得一提的是,异步查询结果接口只能查询某个时间段内的异步调用记录和结果,而当前的查询历史接口可以查询全部任务。 ## 查询历史详情 请求地址:`https://api.aigcaas.cn/v3/history` 请求方法:`GET` 请求参数: | 参数名 | 类型 | 位置 | 解释 | | --------- | ------ | ------ | --------------------------------------------------------- | | Nonce | string | header | **防重放配置** 随机字符串(最大长度20位)且10秒内不可重复 | | Timestamp | string | header | **发起请求时间戳** 与服务器时间差遭遇10秒 | | SecretID | string | header | **密钥信息** 密钥配置中的 secret_id 配置 | | Token | string | header | **签名结果** sha256(Timestamp, SecretKey, Nonce) | | RequestID | string | header | **要查询的 RequestID** | 以 Python 语言为例,示例代码: ```python import time import json import hashlib import random import requests # 签名对象 getSha256 = lambda content: hashlib.sha256(content.encode("utf-8")).hexdigest() secret_id = 'pyXtTxxxxxxxxxxx' # 密钥信息 secret_key = 'qBBsYGxxxxxxxxx' # 密钥信息 url = "https://api.aigcaas.cn/v3/history" # 构建请求头 nonce = str(random.randint(1, 10000)) timestamp = str(int(time.time())) token = getSha256(("%s%s%s" % (timestamp, secret_key, nonce))) headers = { 'SecretID': secret_id, 'RequestID': "04291db5-b9ee-4c81-a879-84512dc8e274", 'Nonce': nonce, 'Token': token, 'Timestamp': timestamp, 'Content-Type': 'application/json' } response = requests.request("GET", url, headers=headers, data=json.dumps({})) response_attr = json.loads(response.content.decode("utf-8")) print(json.loads(response.content.decode("utf-8"))) print(response.headers) ```
Tags :
平台
官方