274 lines
13 KiB
Markdown
274 lines
13 KiB
Markdown
# 元境平台
|
||
|
||
a llm application, which can select differences llm avaiable in the backend, can interacts with the llm, if click the text widget in message showing area, the will call tts server to translate text inside the widget to audio and speak it out
|
||
|
||
## openai 兼容接口
|
||
我们提供一套兼容openai的API
|
||
### 文本生成
|
||
* path /llmage/t2t
|
||
* method 'POST'
|
||
* headers
|
||
```
|
||
{
|
||
"Content-Type": "application/json",
|
||
"Authorization": "Bearer XXXX" # XXXX是客户从元境平台申请到的APIKEY
|
||
}
|
||
```
|
||
* data
|
||
{
|
||
"model": # 模型识别码, 是供应方提供给model名字
|
||
“prompt": # 提示词, 必须输入
|
||
"sys_prompt" # 系统提示词,可选
|
||
“stream” # 流式输出开关
|
||
"..." # 其他提示词
|
||
}
|
||
|
||
* 返回
|
||
符合openai协议的流式或非流式结果
|
||
* 流式:
|
||
```
|
||
./oc.curl 你是谁
|
||
```
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"logprobs": null, "index": 0, "delta": {"content": "", "role": "assistant"}}], "model": "qwen3-max", "reasoning_content": null, "content": "", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u6211\u662f", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u6211\u662f", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u901a\u4e49\u5343", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u901a\u4e49\u5343", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u95ee\uff0c\u963f\u91cc\u5df4\u5df4\u96c6\u56e2\u65d7\u4e0b\u7684", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u95ee\uff0c\u963f\u91cc\u5df4\u5df4\u96c6\u56e2\u65d7\u4e0b\u7684", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u8d85\u5927\u89c4\u6a21\u8bed\u8a00\u6a21\u578b\u3002\u6211\u80fd\u591f", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u8d85\u5927\u89c4\u6a21\u8bed\u8a00\u6a21\u578b\u3002\u6211\u80fd\u591f", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u56de\u7b54\u95ee\u9898\u3001\u521b\u4f5c\u6587\u5b57\uff0c", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u56de\u7b54\u95ee\u9898\u3001\u521b\u4f5c\u6587\u5b57\uff0c", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u6bd4\u5982\u5199\u6545\u4e8b\u3001\u5199\u516c", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u6bd4\u5982\u5199\u6545\u4e8b\u3001\u5199\u516c", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u6587\u3001\u5199\u90ae\u4ef6\u3001\u5199\u5267\u672c", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u6587\u3001\u5199\u90ae\u4ef6\u3001\u5199\u5267\u672c", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u3001\u903b\u8f91\u63a8\u7406\u3001\u7f16\u7a0b\u7b49\u7b49", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u3001\u903b\u8f91\u63a8\u7406\u3001\u7f16\u7a0b\u7b49\u7b49", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\uff0c\u8fd8\u80fd\u8868\u8fbe\u89c2\u70b9\uff0c\u73a9\u6e38\u620f", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\uff0c\u8fd8\u80fd\u8868\u8fbe\u89c2\u70b9\uff0c\u73a9\u6e38\u620f", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u7b49\u3002\u5982\u679c\u4f60\u6709\u4efb\u4f55\u95ee\u9898\u6216", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u7b49\u3002\u5982\u679c\u4f60\u6709\u4efb\u4f55\u95ee\u9898\u6216", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\u9700\u8981\u5e2e\u52a9\uff0c\u6b22\u8fce\u968f\u65f6\u544a\u8bc9\u6211", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\u9700\u8981\u5e2e\u52a9\uff0c\u6b22\u8fce\u968f\u65f6\u544a\u8bc9\u6211", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "\uff01", "role": null}, "index": 0}], "model": "qwen3-max", "reasoning_content": null, "content": "\uff01", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [{"delta": {"content": "", "role": null}, "index": 0, "finish_reason": "stop"}], "model": "qwen3-max", "reasoning_content": null, "content": "", "finish": "0", "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: {"id": "chatcmpl-2665dfd8-e05f-9d7f-adff-3c53c174a454", "object": "chat.completion.chunk", "created": 1775019761, "choices": [], "model": "qwen3-max", "finish": "1", "usage": {"total_tokens": 70, "completion_tokens": 60, "prompt_tokens": 10, "prompt_tokens_details": {"cached_tokens": 0}}, "llmusageid": "K9_veNBxeqvrFfbGWXs0R"}
|
||
data: [DONE]
|
||
```
|
||
* 非流式
|
||
```
|
||
./oc.curl 你是谁
|
||
{"id": "chatcmpl-eea7abb9-24d5-9f70-b6f6-d7da4f22a8b8", "object": "chat.completion", "created": 1775011902, "choices": [{"finish_reason": "stop", "index": 0, "message": {"content": "我是通义千问,阿里巴巴集团旗下的超大规模语言模型。我能够回答问题、创作文字,比如写故事、写公文、写邮件、写剧本、逻辑推理、编程等等,还能表达观点,玩游戏等。如果你有任何问题或需要帮助,欢迎随时告诉我!", "role": "assistant"}}], "model": "qwen3-max", "reasoning_content": null, "content": "我是通义千问,阿里巴巴集团旗下的超大规模语言模型。我能够回答问题、创作文字,比如写故事、写公文、写邮件、写剧本、逻辑推理、编程等等,还能表达观点,玩游戏等。如果你有任何问题或需要帮助,欢迎随时告诉我!", "finish": "1", "usage": {"completion_tokens": 60, "prompt_tokens": 10, "prompt_tokens_details": {"cached_tokens": 0}, "total_tokens": 70}}
|
||
```
|
||
|
||
## 视频生成
|
||
我们提供以下供应商的视频生成模型服务
|
||
* 北京生数
|
||
viduQ3系列
|
||
* 火山云
|
||
seedance 1.5\ 2.0
|
||
* 阿里万象
|
||
wan 2.6
|
||
|
||
由于视频生成时间长, 目前供应商提供的模型生成视频时都是采取提交任务+查询任务结果两阶段模式, 所以元境平台也遵循这种方法
|
||
|
||
### 支持任务形式
|
||
* 文生视频
|
||
目前支持:
|
||
| 模型id | 供应商 | 模型名 |
|
||
+--------+--------+--------+
|
||
| CrEMkFQfRCmbmopZsCqLj | 豆包 | doubao-seedance-1-5-pro-251215 |
|
||
| u9HZyfDoqU6uKI6M1BTks | 通义万象 | wan2.6-t2v |
|
||
| r0ill7L0s6PtBS8mkmg-7 | vidu | viduq3-pro |
|
||
| YjjGgxO_Xma8PWsMjJvps | 豆包 | eedance2.0 (未开通)|
|
||
* 图生视频
|
||
|
||
* 参考生视频
|
||
| 模型id | 供应商 | 模型名 |
|
||
+--------+--------+--------+
|
||
| VooAIOtJdawpZjusWEzrh | 豆包 | doubao-seedance-1-5-pro-251215 |
|
||
| x4HksKp9mXR1Yv60mw6Py | 通义万象 | wan2.6-r2v |
|
||
|
||
### 任务提交
|
||
* path /llmage/video
|
||
* method POST
|
||
* headers
|
||
```
|
||
{
|
||
"Content-Type": "application/json",
|
||
"Authorization": "Bearer XXXX" # XXXX是客户从元境平台申请到的APIKEY
|
||
}
|
||
```
|
||
* data
|
||
除llmid外,不同的模型需要的数据不同,请看后面的输入数据说明
|
||
```
|
||
{
|
||
"llmid": # 模型识别名
|
||
}
|
||
```
|
||
参数说明
|
||
1. 模型id
|
||
|
||
2. prompt
|
||
提示词
|
||
|
||
3. 其他输入
|
||
不同的模型有不同的输入,但不输入也有缺省值
|
||
通义万相:
|
||
```
|
||
[
|
||
{
|
||
"name":"prompt",
|
||
"required":true,
|
||
"uitype": "text",
|
||
"label":"提示词"
|
||
},
|
||
{
|
||
"name":"negative_prompt",
|
||
"label":"反向提示词",
|
||
"uitype": "text"
|
||
},
|
||
{
|
||
"name":"audio_file",
|
||
"uitype":"audio",
|
||
"label":"配音文件"
|
||
},
|
||
{
|
||
"name":"image1_file",
|
||
"uitype":"image",
|
||
"label":"首帧图片"
|
||
},
|
||
{
|
||
"name":"image2_file",
|
||
"uitype":"image",
|
||
"label":"尾帧图片"
|
||
},
|
||
{
|
||
"name":"size",
|
||
"uitype":"code",
|
||
"defaultvalue":"1920*1080",
|
||
"data":[
|
||
{
|
||
"value":"832*480",
|
||
"text":"832*480"
|
||
}, {
|
||
"value":"480*832",
|
||
"text":"480*832"
|
||
},{
|
||
"value":"624*624",
|
||
"text":"624*624"
|
||
},{
|
||
"value":"1280*720",
|
||
"text":"1280*720"
|
||
},{
|
||
"value":"720*1280",
|
||
"text":"720*1280"
|
||
},{
|
||
"value":"960*960",
|
||
"text":"960*960"
|
||
},{
|
||
"value":"1088*832",
|
||
"text":"1088*832"
|
||
},{
|
||
"value":"832*1088",
|
||
"text":"832*1088"
|
||
},{
|
||
"value":"1920*1080",
|
||
"text":"1920*1080"
|
||
},{
|
||
"value":"1080*1920",
|
||
"text":"1080*1920"
|
||
},{
|
||
"value":"1440*1440",
|
||
"text":"1440*1440"
|
||
},{
|
||
"value":"1632*1248",
|
||
"text":"1632*1248"
|
||
},{
|
||
"value":"1248*1632",
|
||
"text":"1248*1632"
|
||
}
|
||
],
|
||
"label":"视频尺寸"
|
||
},
|
||
{
|
||
"name":"duration",
|
||
"lable":"视频时长",
|
||
"uitype":"code",
|
||
"defaultvalue": 15,
|
||
"data":[
|
||
{
|
||
"value":"15",
|
||
"text":"15秒"
|
||
}, {
|
||
"value":"10",
|
||
"text":"10秒"
|
||
}, {
|
||
"value":"5", "text":"5秒"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
|
||
* 返回
|
||
```
|
||
{
|
||
"taskid": # 任务id, 后续使用此id查询执行结果
|
||
"status": # 状态 有:
|
||
# SUCCEEDED: 成功
|
||
# FAILED:失败
|
||
# CREATED:已创建
|
||
# PENDING:排队中
|
||
# RUNNING:运行中
|
||
}
|
||
```
|
||
返回例子:
|
||
```
|
||
{
|
||
"taskid": "936759404378734592",
|
||
"status": "created"
|
||
}
|
||
```
|
||
|
||
### 查询任务状态
|
||
* path /llmage/tasks
|
||
* method POST
|
||
* headers
|
||
```
|
||
{
|
||
"Content-Type": "application/json",
|
||
"Authorization": "Bearer XXXX" # XXXX是客户从元境平台申请到的APIKEY
|
||
}
|
||
```
|
||
* params
|
||
```
|
||
{
|
||
"taskid": "936759404378734592"
|
||
}
|
||
```
|
||
* 返回
|
||
```
|
||
{
|
||
"status": # 状态 有:
|
||
# SUCCEEDED: 成功
|
||
# FAILED:失败
|
||
# CREATED:已创建
|
||
# PENDING:排队中
|
||
# RUNNING:运行中
|
||
"taskid": # 供应商生成的任务号,如果失败taskid无意义
|
||
"usage": # status==SUCCEEDED时有效,计费信息
|
||
"image": # 视频封面url
|
||
"video": # 视频url
|
||
}
|
||
```
|
||
返回例子:
|
||
```
|
||
{
|
||
"usage": { # 由于各个供应商,模型的计价方式不同
|
||
# usage的内容会有所变化
|
||
"action": "t2v",
|
||
"credits": 10,
|
||
"type": "text2video",
|
||
"model": "viduq3-pro",
|
||
"resolution": "540p",
|
||
"off_peak": false,
|
||
"duration": 1
|
||
},
|
||
"image": "https://opencomputing.ai/idfile?path=/tmp/19/43/137/39/cover.jpeg",
|
||
"video": "https://opencomputing.ai/idfile?path=/tmp/137/173/31/47/video.mp4",
|
||
"status": "SUCCEEDED"
|
||
}
|
||
```
|
||
|