sage/wwwroot/API.md
2026-03-21 17:38:49 +08:00

249 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 元境API
## 手机注册和登录
手机登录,如果账号不存在先注册后登陆
### 生成短信验证码
* path /rbac/gen_sms_code.dspy
* method 'GET'
* parameters
cellphone: 手机号
* 返回
```
{
"status": "ok",
"data": {
"key": # 密钥,需要在登录时带回
}
}
```
or
```
{
"status": "error",
"data": {
"message":
"key": key # 登陆需带上的key
}
}
```
### 登录接口
* path /rbac/phone_login.dspy
* method 'POST'
* data
```
{
"cellphone":
"key": # 登陆需带上的key
"sms_code":
"selected_id": # 只有在手机号对应多账号,用户选择某个账号后需要
# 用户id 当用户选择了多手机号之一的账户需要,
}
```
* 返回
```
{
"status": "ok",
"data": {
"user": {
"id": # 用户id
"username": # 用户名
"orgid": # 机构id
"nick_name" # 显示名不存在时显示username
... #其他用户信息
}
}
}
```
or 当手机号有多个账号
```
{
"status": "choose", # 指示前端多账户,需用户选择
"data": {
"key": # 登陆需带上的key
"users": recs # 可选账户现实username用户选择后将id返回后台
}
}
```
```
{
"status": "error",
"data": {
"message": # 错误信息
}
}
```
## 充值
目前支持支付宝在线充值
### 发起支付宝充值
* path /unipay/user_recharge.dspy
* method "POST"
* data
```
{
"provider": "alipay", # 充值渠道
"amount": # 充值金额
"currency": "CNY" # 币种
}
```
* 返回
```
{
"status": "ok",
"data": {
"redirct": url # 充值url
}
}
```
or
```
{
"status": "error",
"data": {
"message": 出错信息
}
}
```
## 账户管理
### 查询账户余额
* path /accounting/mybalance.dspy
* method 'GET'
* params 无
* 返回
```
{
"status": "ok",
"data": [
{
"account": # 账号名称
"balance": # 余额
}
]
}
```
or
```
{
"status": "error",
"data": {
"message": 错误信息
}
}
```
## 交易管理
### 查询产品价格
* path /platformbiz/query_product_price.dspy
* method "POST"
* data
```
{
"product_type": "llm" # llm大模型
"product_id": # 大模型id
“config_data # 不同的模型的配置数据不一样
}
```
* 返回
```
{
"status": "ok",
"data": {
"list_price": # 原价
"price": # 客户价格
"config_data" # 与请求相同
}
}
```
### 查询交易明细
* path /platformbiz/query_orders.dspy
* method "GET"
* params
```
{
"page": # 当前页,缺省第一页
"pagerows": # 每页记录数缺省80
}
```
* 返回
```
{
"total": # 总记录数
"rows": # 当前页数据数组
}
```
row:
```
{
"id": # 订单号
"order_date":
"order_detail":[
"product_type": # llm: 大模型
"productid": # 产品id
"usage": # 大模型使用信息
"amount" # 消费金额
]
}
```
## 文生视频
* path /llmage/vidu_inference.dspy
* method "POST"
* data
```
{
"llmid": # vidu的llmid
"prompt": # 提示词
"duration": # 1 - 15
"audio": # 逻辑值,
"ratio" # "data":[{"value":"16:9"},{"value":"9:16"},{"value":"4:3"},{"value":"3:4"},{"value":"1:1"}]
"resolution": # 分辨率:"data":[{"value":"540p","text":"540p"},{"value":"720p","text":"720p"},{"value":"1080p","text":"1080p"}]
}
* 返回
流式数据, 每行一个jsonjson结构
```
{
"status": # FAILED, SUCCEEDED, 其他
# FAILED失败 error属性中说明失败原因
# SUCCEEDED成功video中保存生成视频url
“error": # 失败时有效,出错原因
“video” # 生成的视频,成功时有效
"usage": # 模型计费信息, 成功时有效
“type” # 类型?看看值是什么
}
```
## 图生视频
* path /llmage/vidu_inference.dspy
* method "POST"
* data
```
{
"llmid": # vidu的llmid
"prompt": # 提示词
"duration": # 1 - 15
"audio": # 逻辑值,
"ratio" # "data":[{"value":"16:9"},{"value":"9:16"},{"value":"4:3"},{"value":"3:4"},{"value":"1:1"}]
"resolution": # 分辨率:"data":[{"value":"540p","text":"540p"},{"value":"720p","text":"720p"},{"value":"1080p","text":"1080p"}]
}
```
* 返回
流式数据, 每行一个jsonjson结构
```
{
"status": # FAILED, SUCCEEDED, 其他
# FAILED失败 error属性中说明失败原因
# SUCCEEDED成功video中保存生成视频url
“error": # 失败时有效,出错原因
“video” # 生成的视频,成功时有效
"usage": # 模型计费信息, 成功时有效
“type” # 类型?看看值是什么
}
```