feat: add public model catalog discovery
This commit is contained in:
+33
@@ -23,6 +23,8 @@ T-302 已实现生成接口基线:`POST /api/v1/generate/title` 与 `POST /api
|
||||
|
||||
T-303 已实现余额查询基线:`GET /api/v1/balance` 已接入 API Key 鉴权,返回当前 `UserWallet.points_balance`;测试覆盖响应余额与 `PointsLedger.points_delta` 累加值一致的账务场景,并确认 Web session 不能调用该外部接口。
|
||||
|
||||
T-601 已实现可用别名发现:`GET /api/v1/models` 已接入 API Key 鉴权,只返回当前 active 且具备对应能力的公开别名、能力、是否需要原图和点数单价;接口不调用 `AiModel.to_resolved_model()`,不解密 provider key,不返回底层 SKU、模型 URL、`api_key_encrypted`、`extra_body` 等内部配置,且成功请求不占用生成接口限流额度。
|
||||
|
||||
T-304 已实现充值回调基线:`POST /api/v1/recharge/callback/wechat` 与 `/alipay` 已 `@csrf_exempt`,回调先验签(开发/测试可用明确 HMAC mock,生产 `PAYMENT_CALLBACK_MODE=sdk` 走支付 SDK),再按 `order_no` 锁定 `RechargeOrder` 幂等入账;金额或支付方式不一致不加点,重复回调不重复写充值流水。
|
||||
|
||||
T-305 已实现扫码充值下单与轮询基线:`POST /api/v1/recharge/create` 与 `GET /api/v1/recharge/status` 走用户端 `SessionAuthentication + CSRF`,不接受 API Key;下单创建 pending 订单并锁定汇率/点数,再返回微信 `code_url` 或支付宝 `qr_code`;状态查询只允许订单所属用户访问,并在 pending 时尝试主动查单补入账,查单不可用时保持 pending 等回调。
|
||||
@@ -140,6 +142,37 @@ T-504/T-505 已实现用户端充值页基线:`/recharge` 走 Django session +
|
||||
}
|
||||
```
|
||||
|
||||
### `GET /api/v1/models`
|
||||
|
||||
查询当前可调用的能力别名。成功响应:
|
||||
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"alias": "title-standard",
|
||||
"operation_type": "title",
|
||||
"capabilities": ["text"],
|
||||
"requires_image": false,
|
||||
"pricing_status": "priced",
|
||||
"prices": [
|
||||
{"resolution": "default", "points_cost": 2}
|
||||
]
|
||||
},
|
||||
{
|
||||
"alias": "image-edit",
|
||||
"operation_type": "image",
|
||||
"capabilities": ["image", "vision"],
|
||||
"requires_image": true,
|
||||
"pricing_status": "unpriced",
|
||||
"prices": []
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
要点:只列 `ModelAlias.is_active=True` 且 `ai_model.is_active=True`,并按操作类型校验模型声明能力。缺定价规则不报错,`pricing_status="unpriced"` 且 `prices=[]`,用户端页面显示「暂未定价」。该接口返回的是公开能力别名,不返回底层供应商模型名、模型 URL、provider key、`api_key_encrypted`、`extra_body` 或其他原始配置;实现不得依赖 `AI_KEY_ENCRYPTION_KEY`。未来接入 `account_alias_permission` 后,本接口应只列当前 API Key 所属用户被授权的别名。
|
||||
|
||||
## 计费模块合约(`apps.billing`)
|
||||
|
||||
T-202 后,计费计算已有独立模块;T-203 后,扣点/退点也收敛到 billing 层,供后续生成接口和充值下单调用:
|
||||
|
||||
Reference in New Issue
Block a user