refactor: v1 API 统一使用 catelogid 参数替代 lctype/llmcatelogid

This commit is contained in:
yumoqing 2026-05-30 16:22:21 +08:00
parent f32f49fb85
commit 08bebcd257
5 changed files with 27 additions and 22 deletions

View File

@ -21,6 +21,7 @@ Base Path: `/llmage/v1`
| 参数 | 类型 | 说明 |
|------|------|------|
| `catelogid` | string | 目录类型,默认 `"文生文"` |
| `stream` | boolean | 是否启用流式输出 |
| `off_peak` | boolean | 是否使用非高峰时段 |
| `transno` | string | 交易流水号(不传则自动生成) |
@ -82,7 +83,7 @@ data: [DONE]
| 参数 | 类型 | 说明 |
|------|------|------|
| `model` | string | 模型名称,如 `"keling-2.1"` |
| `llmcatelogid` | string | 目录类型,如 `"文生视频"` / `"图生视频"` |
| `catelogid` | string | 目录类型,如 `"文生视频"` / `"图生视频"` |
| `prompt` | string | 生成提示词 |
### 可选参数
@ -100,7 +101,7 @@ data: [DONE]
```json
{
"model": "keling-2.1",
"llmcatelogid": "文生视频",
"catelogid": "文生视频",
"prompt": "A beautiful sunset over the ocean",
"duration": "5s",
"resolution": "1080p"
@ -135,7 +136,7 @@ data: [DONE]
| 参数 | 类型 | 说明 |
|------|------|------|
| `model` | string | 模型名称,如 `"jimeng-4.0"` |
| `llmcatelogid` | string | 目录类型,如 `"文生图"` / `"图生图"` |
| `catelogid` | string | 目录类型,如 `"文生图"` / `"图生图"` |
| `prompt` | string | 生成提示词 |
### 可选参数
@ -154,7 +155,7 @@ data: [DONE]
```json
{
"model": "jimeng-4.0",
"llmcatelogid": "文生图",
"catelogid": "文生图",
"prompt": "A beautiful sunset over the ocean",
"size": "1024x1024",
"n": 1
@ -218,7 +219,7 @@ GET /llmage/v1/tasks?taskid=task_xxx
| 参数 | 类型 | 说明 |
|------|------|------|
| `lctype` | string | 按目录类型过滤 |
| `catelogid` | string | 按目录类型过滤 |
| `orderby` | string | 排序字段 |
### 请求示例
@ -247,12 +248,16 @@ GET /llmage/v1/models
## 通用说明
### 参数统一
所有 v1 接口统一使用 `catelogid` 参数标识目录类型,替代原有的 `lctype` / `llmcatelogid`
### 认证
所有接口需要 Bearer Token 认证,请求头中携带:
```
Authorization: Bearer <your_api_key>
Authorization: Bearer ***
```
### 余额检查

View File

@ -10,7 +10,7 @@ async def gen():
yield l
debug_params('params_kw', params_kw)
lctype='文生文'
catelogid = params_kw.catelogid or '文生文'
if params_kw.off_peak:
off_peak = params_kw.off_peak
if off_peak in [True, "Y" "y", 1, "1"]:
@ -33,11 +33,11 @@ async with get_sor_context(env, 'llmage') as sor:
sql = """select distinct a.* from llm a
join llm_api_map m on a.id = m.llmid
join llmcatelog b on m.llmcatelogid = b.id
where b.name = ${lctype}$
where b.name = ${catelogid}$
and a.model=${model}$
and a.status = 'published'"""
recs = await sor.sqlExe(sql, {
'lctype': lctype,
'catelogid': catelogid,
'model': params_kw.model or 'qwen3-max'
})
if len(recs) == 0:

View File

@ -1,12 +1,12 @@
# OpenAI-compatible Image Generation API
# POST /v1/image/generations
# Required params: model, llmcatelogid
# Required params: model, catelogid
# Optional params: prompt, image_url, n, size, style, quality, etc.
#
# Example request:
# {
# "model": "jimeng-4.0",
# "llmcatelogid": "文生图",
# "catelogid": "文生图",
# "prompt": "A beautiful sunset over the ocean",
# "size": "1024x1024",
# "n": 1
@ -36,15 +36,15 @@ if not params_kw.model:
d = return_error('Missing required parameter: model')
return json_response(d, status=400)
if not params_kw.llmcatelogid:
d = return_error('Missing required parameter: llmcatelogid')
if not params_kw.catelogid:
d = return_error('Missing required parameter: catelogid')
return json_response(d, status=400)
if not params_kw.prompt:
d = return_error('Missing required parameter: prompt')
return json_response(d, status=400)
lctype = params_kw.llmcatelogid
lctype = params_kw.catelogid
env = request._run_ns
async with get_sor_context(env, 'llmage') as sor:

View File

@ -6,9 +6,9 @@ def get_time_in_seconds(datestr):
timestamp = dt_obj.timestamp()
return timestamp
lctype=params_kw.lctype
orderby=params_kw.orderby or 'model'
rets = await get_llms_by_catelog_to_customer(catelogid=lctype, orderby=orderby)
catelogid = params_kw.catelogid
orderby = params_kw.orderby or 'model'
rets = await get_llms_by_catelog_to_customer(catelogid=catelogid, orderby=orderby)
ret = {
"object": "list",
"data": []

View File

@ -1,12 +1,12 @@
# OpenAI-compatible Video Generation API
# POST /v1/video/generations
# Required params: model, llmcatelogid
# Required params: model, catelogid
# Optional params: prompt, image_url, duration, resolution, n, etc.
#
# Example request:
# {
# "model": "keling-2.1",
# "llmcatelogid": "文生视频",
# "catelogid": "文生视频",
# "prompt": "A beautiful sunset over the ocean",
# "duration": "5s",
# "resolution": "1080p"
@ -44,15 +44,15 @@ if not params_kw.model:
d = return_error('Missing required parameter: model')
return json_response(d, status=400)
if not params_kw.llmcatelogid:
d = return_error('Missing required parameter: llmcatelogid')
if not params_kw.catelogid:
d = return_error('Missing required parameter: catelogid')
return json_response(d, status=400)
if not params_kw.prompt:
d = return_error('Missing required parameter: prompt')
return json_response(d, status=400)
lctype = params_kw.llmcatelogid
lctype = params_kw.catelogid
env = request._run_ns
async with get_sor_context(env, 'llmage') as sor: