OpenAPI 参考
Modelink API · 管理接口
Modelink 管理接口,用于批量创建 API Key 和导出请求日志。管理接口包含敏感操作与数据,请仅在可信服务端使用。
版本 1.0.0
批量创建 API Key
一次创建 1~100 个 API Key。count 必须与 names 的元素数量一致,每个名称长度为 1~50 个字符。接口使用 AK/SK 请求签名鉴权;部分 Key 创建失败时,响应只包含成功创建的 Key。
认证方式
AK/SK 请求签名,格式为 Qiniu {AccessKey}:{EncodedSign}。签名串包含请求方法、路径、查询参数、Host、Content-Type、X-Qiniu- 请求头以及符合条件的请求体。
请求体
请求体属性
- countinteger, 必填
本次希望创建的 API Key 数量,必须等于
names的元素数量。minimum: 1; maximum: 100
- namesstring[], 必填
API Key 名称列表。
请求
curl https://api.qnaigc.com/v1/apikeys \
--request POST \
--header 'Authorization: YOUR_QINIU_AUTH' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"count": 2,
"names": [
"production-service",
"staging-service"
]
}'响应
创建完成,或请求被业务校验拒绝。请同时检查响应体中的 status。
响应体属性
- statustrue, 必填必填。
const: true
- keystring, 必填
新创建的 API Key。请安全保存,避免写入日志或公开仓库。
- namestring, 必填
API Key 名称。
- createdAtstring, 必填
创建时间。
- enabledboolean, 必填
API Key 是否已启用。
- statusfalse, 必填必填。
const: false
- errorstring, 必填
错误标识或错误描述。
响应
{
"status": true,
"data": {
"keys": [
{
"key": "sk-example-1",
"name": "production-service",
"createdAt": "2026-07-18 10:00:00",
"enabled": true
},
{
"key": "sk-example-2",
"name": "staging-service",
"createdAt": "2026-07-18 10:00:00",
"enabled": true
}
]
}
}导出请求日志
按时间、模型、状态码或 API Key 筛选请求日志,以统一响应结构返回 JSON。结果固定按 start_time 倒序排列。单次最多返回 500 条;当 start 和 end 同时传入时,时间跨度不得超过 35 天。
认证方式
在 Authorization 请求头中传入 Modelink API Key,格式为 Bearer {API_KEY}。
查询参数
- Name
- start
- Type
- string<date-time>
- Description
开始时间,RFC 3339 格式,作为左闭边界(大于等于)。
- Name
- end
- Type
- string<date-time>
- Description
结束时间,RFC 3339 格式,作为右开边界(小于)。与
start同时传入时,跨度不得超过 35 天。
- Name
- size
- Type
- integer, 必填
- Description
每页返回的日志数量。
- Name
- page
- Type
- integer
- Description
页码,从 1 开始;不传或小于等于 0 时按第 1 页处理。
- Name
- model
- Type
- string
- Description
按模型 ID 精确筛选。
- Name
- code
- Type
- integer
- Description
按上游 HTTP 状态码精确筛选;0 或不传表示不限制。
- Name
- apikey
- Type
- string
- Description
按 API Key 筛选,同时匹配带或不带
Bearer前缀的日志记录。
请求体
暂无请求体
请求
curl 'https://api.qnaigc.com/v2/stat/export_log?start={start}&end={end}&size={size}&page={page}&model={model}&code={code}&apikey={apikey}' \
--header 'Authorization: Bearer YOUR_BEARER_AUTH' \
--header 'Accept: application/json'响应
日志导出成功;使用 API Key 鉴权失败或发生内部错误时,也可能返回 HTTP 200 和 status: false。
响应体属性
- statustrue, 必填必填。
const: true
- idstring, 必填
日志记录 ID。
- model_idstring, 必填
请求使用的模型 ID。
- api_keystring, 必填
已脱敏的 API Key。
- start_timestring<date-time>, 必填
请求开始时间。
- end_timestring<date-time>, 必填
请求结束时间。
- server_typestring, 必填
服务类型,例如
chat、image或video。 - codeinteger, 必填
上游 HTTP 状态码。
- errorsstring[]
错误信息列表,无错误时为
null。 - statestring
请求状态标识。
- *number可选。
- *number可选。
- *number可选。
- statusfalse, 必填必填。
const: false
- errorstring, 必填
错误标识或错误描述。
响应
{
"status": true,
"data": [
{
"id": "65a1f2c3",
"model_id": "deepseek/deepseek-v3.1",
"api_key": "sk-***xxxx",
"start_time": "2026-07-18T10:00:00+08:00",
"end_time": "2026-07-18T10:00:02+08:00",
"server_type": "chat",
"code": 200,
"errors": null,
"state": "",
"usage": {
"input": 1024,
"output": 512
}
}
]
}导出请求日志为文件
使用与“导出请求日志”相同的筛选条件,将日志作为 logs.json 文件下载。成功响应体为日志对象裸数组,不包含 status 和 data 包裹。
认证方式
在 Authorization 请求头中传入 Modelink API Key,格式为 Bearer {API_KEY}。
查询参数
- Name
- start
- Type
- string<date-time>
- Description
开始时间,RFC 3339 格式,作为左闭边界(大于等于)。
- Name
- end
- Type
- string<date-time>
- Description
结束时间,RFC 3339 格式,作为右开边界(小于)。与
start同时传入时,跨度不得超过 35 天。
- Name
- size
- Type
- integer, 必填
- Description
每页返回的日志数量。
- Name
- page
- Type
- integer
- Description
页码,从 1 开始;不传或小于等于 0 时按第 1 页处理。
- Name
- model
- Type
- string
- Description
按模型 ID 精确筛选。
- Name
- code
- Type
- integer
- Description
按上游 HTTP 状态码精确筛选;0 或不传表示不限制。
- Name
- apikey
- Type
- string
- Description
按 API Key 筛选,同时匹配带或不带
Bearer前缀的日志记录。
请求体
暂无请求体
请求
curl 'https://api.qnaigc.com/v2/stat/export_log_file?start={start}&end={end}&size={size}&page={page}&model={model}&code={code}&apikey={apikey}' \
--header 'Authorization: Bearer YOUR_BEARER_AUTH' \
--header 'Accept: application/json'响应
JSON 文件下载成功;使用 API Key 鉴权失败或发生内部错误时,也可能返回统一错误 JSON。
响应体属性
- idstring, 必填
日志记录 ID。
- model_idstring, 必填
请求使用的模型 ID。
- api_keystring, 必填
已脱敏的 API Key。
- start_timestring<date-time>, 必填
请求开始时间。
- end_timestring<date-time>, 必填
请求结束时间。
- server_typestring, 必填
服务类型,例如
chat、image或video。 - codeinteger, 必填
上游 HTTP 状态码。
- errorsstring[]
错误信息列表,无错误时为
null。 - statestring
请求状态标识。
- *number可选。
- *number可选。
- *number可选。
- statusfalse, 必填必填。
const: false
- errorstring, 必填
错误标识或错误描述。
响应
[
{
"id": "65a1f2c3",
"model_id": "deepseek/deepseek-v3.1",
"api_key": "sk-***xxxx",
"start_time": "2026-07-18T10:00:00+08:00",
"end_time": "2026-07-18T10:00:02+08:00",
"server_type": "chat",
"code": 200,
"errors": null,
"state": "",
"usage": {
"input": 1024,
"output": 512
}
}
]