21 KiB
21 KiB
元境平台API
元境平台为下游系统提供兼容openai接口协议的API,下游系统需要开通元境平台的API,要做以下步骤
- 注册一个账号
- 登录
- 申请APIKEY
- 充值
完成上述步骤后, 可以按照下面的例子实现文生文,文生视频,图生视频,参考生视频的模型推理服务
元境平台支持的模型,请参看模型广场
申请APIKEY
用户需要在元境平台(https://ai.opencomputing.cn)上用手机登录, 登录“创建APIKEY”
输入信息后点击提交,APIKEY创建完成
点击"复制apikey", 在弹出窗口看到apikey, 复制他
充值
用户需要在元境平台上充值,目前支持alipay(支付宝)充值
查看当前余额
- 用户登录
- 呼出用户菜单
- 点击财务
API对接的base url
openai 兼容接口
我们提供一套兼容openai的API
文本生成
- path /llmage/v1/chat/completions
- method 'POST'
- headers
{
"Content-Type": "application/json",
"Authorization": "Bearer <your-apikey>" # 客户从元境平台申请到的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}}
文生视频
目前支持:
| 模型id | 供应商 | 模型名 |
|---|---|---|
| YjjGgxO_Xma8PWsMjJvps | 豆包 | doubao-seedance-2-0-260128 |
| TWay-xd0p0pkEX-_Kuhto | We Token AI | dreamina-seedance-2-0-260128(*), dreamina-seedance-2-0-fast-260128 |
| CrEMkFQfRCmbmopZsCqLj | 豆包 | doubao-seedance-1-5-pro-251215 |
| CrEMkFQfRCmbmopZsCqLj | 豆包 | doubao-seedance-1-5-pro-251215 |
| u9HZyfDoqU6uKI6M1BTks | 通义万象 | wan2.6-t2v |
| r0ill7L0s6PtBS8mkmg-7 | vidu | viduq3-pro |
| YjjGgxO_Xma8PWsMjJvps | 豆包 | eedance2.0 (未开通) |
seedance 2.0 上传数据要求
| 字段名 (Name) | 类型 (Type) | 必填 (Required) | 默认值 (Default) | 说明 (Description) |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| model | 模型名 |否 | doubao-seedance-2-0-260128 | doubao-seedance-2-0-260128 或 doubao-seedance-2-0-fast-260128 | | |||
| prompt | string | 是 | - | 提示词。用于描述你希望生成的视频内容。 |
| 的内容。 | ||||
| resolution | string | 否 | 720p |
视频尺寸。指定生成视频的分辨率。 可选值: 480p, 720p, 1080p |
| ratio | string | 否 | adaptive | 可选:adaptive, 16:9, 4:3, 1:1, 3:4, 9:16, 21:9 |
| duration | integer | 否 | 5 |
视频时长。指定生成视频的长度(秒)。 可选值:整数秒 |
万象上传数据要求
| 字段名 (Name) | 类型 (Type) | 必填 (Required) | 默认值 (Default) | 说明 (Description) |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| model | 模型名 | 否 | 标星 | - |
| prompt | string | 是 | - | 提示词。用于描述你希望生成的视频内容。 |
| negative_prompt | string | 否 | (empty) | 反向提示词。用于描述你希望视频中避免出现的内容。 |
| size | string | 否 | 1920*1080 |
视频尺寸。指定生成视频的分辨率。 可选值: 832*480, 480*832, 624*624, 1280*720, 720*1280, 960*960, 1088*832, 832*1088, 1920*1080, 1080*1920, 1440*1440, 1632*1248, 1248*1632 |
| duration | integer | 否 | 15 |
视频时长。指定生成视频的长度(秒)。 可选值: 5, 10, 15 |
vidu 上传参数
| 字段名 (Name) | 类型 (Type) | 必填 (Required) | 默认值 (Default) | 说明 (Description) |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| prompt | string | 是 | - | 提示词。用于描述生成视频的内容。 |
| off_peak | string | 否 | N |
错峰执行。是否开启非高峰时段生成。 可选值: Y (是), N (否) |
| duration | integer | 否 | 10 |
视频长度。生成视频的时长(秒)。 范围:1-16 秒 (根据字段描述) |
| ratio | string | 否 | 16:9 |
长宽比。指定视频的画面比例。 可选值: 16:9, 9:16, 4:3, 3:4, 1:1 |
| resolution | string | 否 | 1080p |
分辨率。指定生成视频的清晰度。 可选值: 540p, 720p, 1080p |
seedance 上传数据要求
| 字段名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| prompt | string | 是 | - | 提示词。描述生成视频的内容。 |
| radio | string | 否 | - | 宽高比例。指定视频的长宽比。 可选值: 16:9, keep_ratio, 4:3, 1:1, 3:4, 9:16, 9:21, 21:9, adaptive |
| resolution | string | 否 | 1080p |
分辨率。指定视频清晰度。 可选值: 480p, 720p, 1080p |
| duration | integer | 否 | 12 |
视频长度。视频时长(秒)。 |
例子
使用seedance的例子
#!/usr/bin/env bash
curl -X POST https://opencomputing.ai/llmage/video \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-apikey-from-opencomputing.ai" \
-d '{
"llmid": "CrEMkFQfRCmbmopZsCqLj",
"prompt": "小猫在抓老鼠",
"duration": 5,
"ratio": "16:9",
"resolution": "480p"
}'
图生视频
| 模型id | 供应商 | 模型名 | 功能 |
|---|---|---|---|
| UeYax4591ytnPcr9eumry | 豆包 | doubao-seedance-2-0-260128 | 文图生视频 |
| tb0VSY6WeyGbzaolU1_qE | We Token AI豆包海外版 | dreamina-seedance-2-0-fast-260128, dreamina-seedance-2-0-260128 | |
| 7RTOJD6K8A7RXCMG4GnQ9 | 豆包 | doubao-seedance-1-5-pro-251215 | 文图生视频 |
| 7RTOJD6K8A7RXCMG4GnQ9 | 豆包 | doubao-seedance-1-5-pro-251215 | 文生视频 |
| FK_h7FLYnosv2TkMN4ATC | vidu | viduq3-pro | |
| x4HksKp9mXR1Yv60mw6Py | 通义万象 | wan2.6-r2v |
seedance 2.0 上传数据要求
| 字段名 (Name) | 类型 (Type) | 必填 (Required) | 默认值 (Default) | 说明 (Description) |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| model | 模型名 |否 | doubao-seedance-2-0-260128 | doubao-seedance-2-0-260128 或 doubao-seedance-2-0-fast-260128 | | |||
| prompt | string | 是 | - | 提示词。用于描述你希望生成的视频内容。 |
| image1_file | 图片文件 | 是 | - | 首帧图片。 |
| image2_file | 图片文件 | 是 | - | 尾帧图片。 |
| resolution | string | 否 | 720p |
视频尺寸。指定生成视频的分辨率。 可选值: 480p, 720p, 1080p |
| ratio | string | 否 | adaptive | 可选:adaptive, 16:9, 4:3, 1:1, 3:4, 9:16, 21:9 |
| duration | integer | 否 | 5 |
视频时长。指定生成视频的长度(秒)。 可选值:整数秒 |
通义万象上传数据要求
| 字段名 (Name) | 类型 (Type) | 必填 (Required) | 默认值 (Default) | 说明 (Description) |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| prompt | string | 是 | - | 提示词。用于描述你希望生成的视频内容。 |
| negative_prompt | string | 否 | (empty) | 反向提示词。用于描述你希望视频中避免出现的内容。 |
| size | string | 否 | 1920*1080 |
视频尺寸。指定生成视频的分辨率。 可选值: 832*480, 480*832, 624*624, 1280*720, 720*1280, 960*960, 1088*832, 832*1088, 1920*1080, 1080*1920, 1440*1440, 1632*1248, 1248*1632 |
| duration | integer | 否 | 15 |
视频时长。指定生成视频的长度(秒)。 可选值: 5, 10, 15 |
| image_file1 | string/file | 是 | - | 首帧图片。视频的起始画面(通常为图片 URL 或 Base64)。 |
| image_file2 | string/file | 是 | - | 尾帧图片。视频的结束画面(通常为图片 URL 或 Base64)。 |
vidu 上传数据要求
| 字段名 (Name) | 类型 (Type) | 必填 (Required) | 默认值 (Default) | 说明 (Description) |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| model | string | 否 | viduq3-pro |
模型。选择生成视频所使用的模型版本。 可选值: viduq2-turbo, viduq3-pro |
| prompt | string | 是 | - | 提示词。描述视频内容的文本。 |
| off_peak | string | 否 | N |
错峰执行。是否开启非高峰时段生成。 可选值: Y (是), N (否) |
| image_file1 | string/file | 是 | - | 首帧图片。视频的起始画面(通常为图片 URL 或 Base64)。 |
| image_file2 | string/file | 是 | - | 尾帧图片。视频的结束画面(通常为图片 URL 或 Base64)。 |
| duration | integer | 否 | 10 |
视频长度。生成视频的时长(秒)。 范围:1-16 秒 |
| ratio | string | 否 | 16:9 |
长宽比。指定视频的画面比例。 可选值: 16:9, 9:16, 4:3, 3:4, 1:1 |
| resolution | string | 否 | 1080p |
分辨率。指定生成视频的清晰度。 可选值: 540p, 720p, 1080p |
seedance 1.5 上传数据要求
| 字段名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| llmid | 模型编号 | 是 | - | - |
| prompt | string | 是 | - | 提示词。描述视频内容的文本。 |
| radio | string | 否 | - | 宽高比例。指定视频的长宽比。 可选值: 16:9, keep_ratio, 4:3, 1:1, 3:4, 9:16, 9:21, 21:9, adaptive |
| resolution | string | 否 | 1080p |
分辨率。指定视频清晰度。 可选值: 480p, 720p, 1080p |
| duration | integer | 否 | 12 |
视频长度。视频时长(秒)。 |
| image_file1 | string | 否 | - | 首帧图片。视频开始的画面(URL 或 Base64)。 |
| image_file2 | string | 否 | - | 尾帧图片。视频结束的画面(URL 或 Base64)。 |
例子
使用seedance 1.5的例子
#!/usr/bin/env bash
curl -X POST https://opencomputing.ai/llmage/video \
-H "Authorization: Bearer <your-apikey-from-opencomputing.ai" \
-F "model=dreamina-seedance-2-0-260128" \
-F "llmid=CrEMkFQfRCmbmopZsCqLj" \
-F "prompt=从图片1到图片2丝滑转换" \
-F "duration=5" \
-F "ratio=16:9" \
-F "resolution=480p" \
-F "image1_file=@./myimg1.jpg" \
-F "image1_file=@./myimg2.jpg"
参考生视频
| 模型id | 供应商 | 模型名 |
|---|---|---|
| dmPXF65TD1riKj9KaxLmg | 豆包 | doubao-seedance-2-0-260128(*), doubao-seedance-2-0-fast-260128 |
| nVbH7lEO51soqTbLGIHE_ | WeTokenAI 豆包海外版 | dreamina-seedance-2-0-260128(*), dreamina-seedance-2-0-fast-260128 |
seedance 2.0 上传数据要求
| 字段名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| model | str | 否 | 默认值为打星模型 | |
| prompt | string | 是 | - | 提示词。描述视频内容的文本。 |
| ratio | string | 否 | - | 宽高比例。指定视频的长宽比。 可选值: 16:9, 4:3, 1:1, 3:4, 9:16, 9:21, 21:9 |
| resolution | string | 否 | 1080p |
分辨率。指定视频清晰度。 可选值: 480p, 720p, 1080p |
| duration | integer | 否 | 12 |
视频长度。视频时长(秒)。 |
| image_files | 数组 | 是 | [] | 参考图片数组。 |
| video_files | 数组 | 否 | [] | 参考视频数组。 |
| audio_files | 数组 | 否 | [] | 参考音频数组。 |
任务提交
- path /llmage/video
- method POST
- headers
{
"Content-Type": "application/json",
"Authorization": "Bearer <your-apikey>" # 客户从元境平台申请到的APIKEY
}
-
data 除llmid外,不同的模型需要的数据不同,请看上传数据说明
-
返回
{
"taskid": # 任务id, 后续使用此id查询执行结果
"status": # 状态 有:
# SUCCEEDED: 成功
# FAILED:失败
# CREATED:已创建
# PENDING:排队中
# RUNNING:运行中
}
返回例子:
{
"taskid": "936759404378734592",
"status": "created"
}
例子
seedance 2.0 参考生视频
curl -X POST https://opencomputing.ai/llmage/video \
-H "Authorization: Bearer <APIKEY>" \
-F "llmid=dmPXF65TD1riKj9KaxLmg" \
-F "model": "doubao-seedance-2-0-260128" \
-F "image_files=@./1.jpg" \
-F "image_files=@./2.jpg" \
-F "prompt=平滑过度从第一张图片到第二张图片" \
-F "ratio=4:3" \
-F "resolution=720p" \
-F "duration=4"
查询任务状态
- path /llmage/tasks
- method GET
- headers
{
"Content-Type": "application/json",
"Authorization": "Bearer <your-apikey>" # 客户从元境平台申请到的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"
}
例子
#!/usr/bin/env bash
curl -X POST https://opencomputing.ai/llmage/tasks?taskid=<taskid> \
-H "Authorization: Bearer <your-apikey-from-opencomputing.ai>"
错误信息
- 401: {"error": "Invalid API Key"}
- 400: {"error": "Missing required parameter: prompt"}
- 429: {"error": "Insufficient balance"} (余额不足)