平台管理
Usage Detail
请求说明
- 基本信息
查询APIKEY对应项目的使用情况
请求地址:https://www.sophnet.com/api/open-apis/projects/usage_detail
请求方式:GET
- Path参数:
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| beginTime | String | 是 | 起始日期,格式为"yyyy-MM-dd",例如"2025-07-01" |
| endTime | String | 是 | 终止日期,格式为"yyyy-MM-dd",例如"2025-07-31" |
- Header参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | String | 是 | "Bearer" + Apikey |
响应说明
- 响应头参数
| 名称 | 值 | 描述 |
|---|---|---|
| Content-Type | application/json |
- 响应体参数
| 名称 | 类型 | 描述 |
|---|---|---|
| status | int | 请求状态 |
| message | string | 请求信息 |
| result.service | array(object) | 服务列表 |
| result.dates | array(string) | 日期列表 |
| result.invokeDetails | object | 各个服务的请求数 |
| result.invokeSummary | integer | 所有服务的总请求数 |
| result.costDetails | object | 各个服务的费用 |
| result.costSummary | number | 所有服务的总费用 |
| result.tokenDetails | object | 各个服务的Token用量 |
| result.tokenSummary | integer | 所有服务的Token总用量 |
| result.latency90Details | object | 90%的请求完成响应所需的时间 |
| result.latency50Details | object | 50%的请求完成响应所需的时间 |
| result.latency99Details | object | 99%的请求完成响应所需的时间 |
Balance Query
请求说明
- 基本信息
查询APIKEY对应项目所属组织的余额信息
请求地址:https://www.sophnet.com/api/open-apis/projects/balance
请求方式:GET
- Header参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | String | 是 | "Bearer" + Apikey |
响应说明
- 响应头参数
| 名称 | 值 | 描述 |
|---|---|---|
| Content-Type | application/json |
- 响应体参数
| 名称 | 类型 | 描述 |
|---|---|---|
| status | int | 请求状态 |
| message | string | 请求信息 |
| result.currentBalance | number | 余额 |
| result.currentBalanceWithoutGift | number | 充值余额 |
| result.currentGiftBalance | number | 赠送余额 |
| result.balanceThreshold | number | 余额提醒阈值 |
Model Pricing Query
请求说明
- 基本信息
查询当前组织可用模型的定价与折扣信息
请求地址:https://www.sophnet.com/api/open-apis/v1/models/pricing
请求方式:GET
- Header参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | String | 是 | "Bearer" + Apikey |
响应说明
- 响应头参数
| 名称 | 值 | 描述 |
|---|---|---|
| Content-Type | application/json |
- 响应体参数
| 名称 | 类型 | 描述 |
|---|---|---|
| orgId | number | 组织ID |
| models | array(object) | 组织可用模型列表 |
| models[].modelFamily | string | 模型标识 |
| models[].displayName | string | 模型展示名 |
| models[].price | object | 模型价格(阶梯价格) |
| models[].price.currency | string | 币种,CNY 或 USD |
| models[].price.rules | array(object) | 价格规则(阶梯档位)列表 |
| models[].price.rules[].maxInputTokens | number | 输入 token 上限,0 / null / 负数表示不限 |
| models[].price.rules[].maxOutputTokens | number | 输出 token 上限,0 / null / 负数表示不限 |
| models[].price.rules[].startTime | string | 生效起始时间,格式 HH:mm,null 表示全天 |
| models[].price.rules[].endTime | string | 生效结束时间,格式 HH:mm,null 表示全天,endTime 早于 startTime 表示跨零点 |
| models[].price.rules[].inputCostPerThousandTokens | number | 每千输入 token 价格 |
| models[].price.rules[].inputCostPerThousandCachedTokens | number | 每千缓存命中输入 token 价格 |
| models[].price.rules[].inputCostPerThousandExplicitCachedTokens | number | 每千显式缓存输入 token 价格 |
| models[].price.rules[].inputCostPerThousandCacheCreationTokens | number | 每千缓存创建输入 token 价格 |
| models[].price.rules[].outputCostPerThousandTokens | number | 每千输出 token 价格 |
| models[].price.rules[].outputCostPerThousandReasoningTokens | number | 每千思考(reasoning)token 价格 |
| models[].price.rules[].outputCostPerThousandImageTokens | number | 每千图像 token 价格 |
| models[].discount | number | 费率系数:<1 打折(如 0.8 表示 8 折)、>1 加价、null 无折扣 |
| aigcModels | array(object) | 组织可用 AIGC 模型列表(图片/视频/语音) |
| aigcModels[].modelFamily | string | 模型标识:图片/视频为 externalId,语音为 modelFamily |
| aigcModels[].displayName | string | 模型展示名 |
| aigcModels[].category | string | 子类型:IMAGE_GENERATOR / VIDEO_GENERATOR / AUDIO_TTS / AUDIO_ASR |
| aigcModels[].billingType | string | 计费类型(如 PER_IMAGE、DURATION_RESOLUTION);语音模型为 null |
| aigcModels[].price | object | AIGC 价格,结构见下方补充说明 |
| aigcModels[].discount | number | 费率系数,同 models[].discount;语音模型恒为 null(语音无折扣机制) |
补充说明:
- 所有单价单位为每千 token。
- 档位规则:按输入 / 输出 token 上限选「最小可覆盖」档(0 / null 表示不限);分时段档优先,未命中回退全天档。
- discount 为费率系数:0.8 表示 8 折,null 表示无折扣;最终费用 = 价格 × 用量 × discount。
aigcModels为 AIGC 模型(图片/视频/语音)的价格列表,与models平行返回,结构不同:- 图片/视频条目:
price.rules为计费档位数组(原样透出计费规则),每条含conditions(档位条件,如taskType/resolution)、price、priceUnit(PER_IMAGE 按张 / PER_SECOND 按秒 / FIXED 固定价 / PER_CREDIT 按积分 / PER_MILLION_TOKENS 按百万 token / VIDEO_COMPOSITE 视频合成 / PER_MILLION_MULTI_TOKENS 多维 token,复合计费的额外字段:inputPrice每张输入参考图、inputFreeCount免费参考图张数、outputSecondPrice/inputVideoSecondPrice每秒价、prices多维单价映射);discount为组织折扣,与实际扣费一致。 - 语音条目:价格为扁平结构,TTS 用
price.inputPricePerTenThousandChar(每万字符,CNY),ASR 用price.inputPricePerHour(每小时,CNY);billingType与discount恒为 null(语音无折扣机制)。
- 图片/视频条目:
请求示例
curl --location -g --request GET 'https://www.sophnet.com/api/open-apis/v1/models/pricing' \
--header "Authorization: Bearer <API_KEY>"响应示例
{
"orgId": 1024,
"models": [
{
"modelFamily": "qwen3.5",
"displayName": "Qwen3.5",
"price": {
"currency": "CNY",
"rules": [
{
"maxInputTokens": 128000,
"maxOutputTokens": 16000,
"startTime": null,
"endTime": null,
"inputCostPerThousandTokens": 0.012,
"inputCostPerThousandCachedTokens": 0.004,
"inputCostPerThousandExplicitCachedTokens": 0.004,
"inputCostPerThousandCacheCreationTokens": 0.03,
"outputCostPerThousandTokens": 0.03,
"outputCostPerThousandReasoningTokens": 0.03,
"outputCostPerThousandImageTokens": 0.03
}
]
},
"discount": 0.8
}
],
"aigcModels": [
{
"modelFamily": "Qwen-Image",
"displayName": "Qwen Image",
"category": "IMAGE_GENERATOR",
"billingType": "PER_IMAGE",
"price": {
"currency": "CNY",
"rules": [
{
"conditions": {},
"price": 0.25,
"priceUnit": "PER_IMAGE"
}
]
},
"discount": 0.8
},
{
"modelFamily": "cosyvoice-v1",
"displayName": "CosyVoice v1",
"category": "AUDIO_TTS",
"billingType": null,
"price": {
"currency": "CNY",
"inputPricePerTenThousandChar": 2.0
},
"discount": null
}
]
}请将 <API_KEY> 替换为你的 API Key。该接口无需其他请求参数。
批量导出脚本:curl_query_model_price.sh —— 输出按模型/档位整理的价格表:
SOPH_API_KEY=<你的_API_KEY> ./curl_query_model_price.shUsage Detail Export
请求说明
- 基本信息
导出组织用量明细(行级请求记录,用于对账)。单次时间窗上限 7 天(带 projectId / model 过滤时 1 小时),每页最多 100 条;配套批量导出脚本见下方「批量导出脚本」
请求地址:https://www.sophnet.com/api/open-apis/usages/detail
请求方式:GET
- Path参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| requestId | String | 否 | 请求 ID 精确查单条;提供时忽略时间与过滤参数 |
| projectId | Long | 否 | 项目过滤;与 model 同时提供时时间窗上限降为 1 小时 |
| model | String | 否 | 模型过滤 |
| beginTime | String | 否 | 起始时间(ISO 8601,如 2026-09-01T00:00:00.000Z);缺省为当前时间前 10 分钟 |
| endTime | String | 否 | 结束时间(ISO 8601);缺省为当前时间;必须晚于 beginTime |
| page | int | 否 | 页码,0 起,默认 0,最大 100 |
| size | int | 否 | 每页条数,默认 10,最大 100 |
- Header参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | String | 是 | "Bearer" + Apikey,需为组织管理员身份的 Apikey |
响应说明
- 响应头参数
| 名称 | 值 | 描述 |
|---|---|---|
| Content-Type | application/json |
- 响应体参数
| 名称 | 类型 | 描述 |
|---|---|---|
| status | int | 请求状态 |
| message | string | 请求信息 |
| result.content | array(object) | 明细列表(分页) |
| result.content[].requestId | string | 请求唯一标识 |
| result.content[].orgId | number | 组织 ID |
| result.content[].projectId | number | 项目 ID |
| result.content[].model | string | 模型标识 |
| result.content[].apikeyId | number | 使用的 Apikey ID |
| result.content[].apikeyName | string | 使用的 Apikey 名称 |
| result.content[].inputTokens | number | 输入 token 数 |
| result.content[].inputCachedTokens | number | 输入 token 中隐式缓存命中数量 |
| result.content[].inputExplicitCachedTokens | number | 输入 token 中显式缓存命中数量 |
| result.content[].cacheCreationTokens | number | 缓存创建 token 数 |
| result.content[].outputTokens | number | 输出 token 数 |
| result.content[].outputReasoningTokens | number | 输出中思考(reasoning)token 数 |
| result.content[].outputImageTokens | number | 输出中图像 token 数 |
| result.content[].costInCny | number | 实付金额(人民币) |
| result.content[].currency | string | 计费单价币种(CNY/USD),计费时刻冻结;费用字段恒为人民币 |
| result.content[].preDiscountCostInCny | number | 折前金额(人民币);null 表示该行无折前概念,对账按 costInCny |
| result.content[].billingRule | string | 计费规则快照(JSON 字符串,阶梯价格与档位);null 表示无规则快照 |
| result.content[].requestTime | string | 请求发起时间 |
| result.content[].finishTime | string | 请求完成时间 |
| result.content[].finishReason | string | 结束原因(stop/length 等) |
| result.totalElements | number | 总条数 |
| result.totalPages | number | 总页数 |
| result.number | number | 当前页码 |
| result.size | number | 当前页条数 |
限制说明
仅支持查询当月与上月数据,更早数据已归档
请求示例
curl -s --get 'https://www.sophnet.com/api/open-apis/usages/detail' \
--data-urlencode 'beginTime=2026-09-09T00:00:00.000Z' \
--data-urlencode 'endTime=2026-09-10T00:00:00.000Z' \
--data-urlencode 'page=0' \
--data-urlencode 'size=100' \
-H "Authorization: Bearer <API_KEY>"批量导出脚本:curl_export_usage_detail.sh —— 自动切分时间窗并翻页,拉全量数据到本地 JSON(依赖 curl / jq):
SOPH_API_KEY=<你的_API_KEY> BEGIN_TIME=2026-09-09 END_TIME=2026-09-10 ./curl_export_usage_detail.sh错误说明:401 为 Apikey 无效;403 为该 Apikey 对应账号不是组织管理员
Usage Billing Export
请求说明
- 基本信息
导出组织账单汇总(按 hour / day / month 聚合,每个时间桶一行)。单次时间窗上限 180 天,每页最多 100 条;配套批量导出脚本见下方「批量导出脚本」
请求地址:https://www.sophnet.com/api/open-apis/usages/billing
请求方式:GET
- Path参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| projectId | Long | 否 | 项目过滤(组织级汇总时返回各项目行) |
| resourceUuid | String | 否 | 资源(服务)过滤;必须与 projectId 同时提供 |
| period | String | 否 | 聚合粒度:hour / day / month,默认 day |
| beginTime | String | 否 | 起始时间(ISO 8601);缺省为当前时间前 30 天 |
| endTime | String | 否 | 结束时间(ISO 8601);缺省为当前时间;必须晚于 beginTime |
| page | int | 否 | 页码,0 起,默认 0,最大 100 |
| size | int | 否 | 每页条数,默认 10,最大 100 |
- Header参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | String | 是 | "Bearer" + Apikey,需为组织管理员身份的 Apikey |
响应说明
- 响应头参数
| 名称 | 值 | 描述 |
|---|---|---|
| Content-Type | application/json |
- 响应体参数
| 名称 | 类型 | 描述 |
|---|---|---|
| status | int | 请求状态 |
| message | string | 请求信息 |
| result.content | array(object) | 汇总列表(分页,展平宽表) |
| result.content[].projectId | number | 项目 ID(组织级聚合时为 null) |
| result.content[].resourceUuid | string | 资源 UUID(组织级/项目级聚合时为 null) |
| result.content[].periodStartTime | string | 时间桶起点 |
| result.content[].requestCount | number | 该桶内请求次数 |
| result.content[].tokenTotal | number | 该桶内总 token |
| result.content[].inputTokens | number | 输入 token |
| result.content[].outputTokens | number | 输出 token |
| result.content[].inputCachedTokens | number | 输入 token 中缓存命中数量 |
| result.content[].cost | number | 实付金额(人民币) |
| result.content[].estimateCost | number | 预估金额(人民币) |
| result.totalElements | number | 总条数 |
| result.totalPages | number | 总页数 |
| result.number | number | 当前页码 |
| result.size | number | 当前页条数 |
请求示例
curl -s --get 'https://www.sophnet.com/api/open-apis/usages/billing' \
--data-urlencode 'period=day' \
--data-urlencode 'beginTime=2026-08-01T00:00:00.000Z' \
--data-urlencode 'endTime=2026-09-01T00:00:00.000Z' \
--data-urlencode 'page=0' \
--data-urlencode 'size=100' \
-H "Authorization: Bearer <API_KEY>"批量导出脚本:curl_export_usage_billing.sh —— 自动切分时间窗并翻页,拉全量数据到本地 JSON(依赖 curl / jq):
SOPH_API_KEY=<你的_API_KEY> BEGIN_TIME=2026-08-01 END_TIME=2026-09-01 PERIOD=day ./curl_export_usage_billing.sh错误说明:401 为 Apikey 无效;403 为该 Apikey 对应账号不是组织管理员