常见模型 API 文档
通过提供标准的 Restful 接口,给第三方平台接入 MaaS 平台的能力。
快速开始
Base URL
在推理任务详情,查看Api地址
OpenAI接口
接口 | 接口类型 | 接口描述 |
---|---|---|
/v1/chat/completions | POST | 为指定的聊天对话创建一个模型响应,支持携带历史问答 |
/v1/completions | POST | 给定一个提示,该模型将返回一个或多个预测的完成,返回每个位置的替代标记的概率 |
请求参数
名称 | 位置 | 类型 | 必选 | 说明 |
---|---|---|---|---|
Authorization | header | string | 是 | Bearer |
Content-Type | header | string | 是 | application/json |
body | body | string | 是 | 参考标准的OpenAI接口规范 |
API Key : 在用户中心的访问令牌页面中获取,你也可以创建多个 Api Key 以运用到不同业务系统中。
模型名称:模型名称是在推理任务查询到的。
cURL 示例
- 非流式请求
请注意替换 <Base URL>
、<你的 Api-Key>
、<模型名称>
为实际值。
bash
curl \
--request POST \
--url <Base URL>/v1/chat/completions \
--header 'Authorization: Bearer <你的 Api-Key>' \
--header 'content-type: application/json' \
--data '{
"model": "<模型名称>",
"messages": [
{
"role": "user",
"content": "Say this is a test!"
}
],
"temperature": 0.7,
"stream": false
}'
响应格式请前往 openAI规范 文档查看。
- 流式请求
将参数中的 stream
参数设置为 true
,即可开启流式请求。响应会以 SSE 的形式返回。请注意替换 <Base URL>
、<你的 Api-Key>
、<模型名称>
为实际值。
bash
curl \
--request POST \
--url <Base URL>/v1/chat/completions \
--header 'Authorization: Bearer <你的 Api-Key>' \
--header 'content-type: application/json' \
--data '{
"model": "<模型名称>",
"messages": [
{
"role": "user",
"content": "Say this is a test!"
}
],
"temperature": 0.7,
"stream": true
}'
响应格式请前往 openAI规范 文档查看。
DeepSeek-R1-Distill-Qwen-32B
- 接口示例
/v1/chat/completions
- 示例body参数
只设置关键的参数,更多参数参考 openAI规范 文档
- 非流式请求
json
{
"model": "DeepSeek-R1-Distill-Qwen-32B",
"messages": [
{
"role": "user",
"content": "推荐几个电影"
}
],
"temperature": 0.6,
"stream": false
}
- 流式请求
json
{
"model": "DeepSeek-R1-Distill-Qwen-32B",
"messages": [
{
"role": "user",
"content": "推荐几个电影"
}
],
"temperature": 0.6,
"stream": true
}
QwQ-32B
- 接口示例
/v1/chat/completions
- 示例body参数
只设置关键的参数,更多参数参考 openAI接口 文档
- 非流式请求
json
{
"model": "QwQ-32B",
"messages": [
{
"role": "user",
"content": "分析一下AI如何赋能石油行业的发展"
}
],
"stream": false
}
- 流式请求
json
{
"model": "QwQ-32B",
"messages": [
{
"role": "user",
"content": "分析一下AI如何赋能石油行业的发展"
}
],
"stream": true
}
ChatGLM4-9B
- 接口示例
/v1/chat/completions
- 示例body参数
只设置关键的参数,更多参数参考 openAI接口 文档
json
{
"model": "{模型名称}",
"prompt": "现在是3个人头脑风暴,你需要从三个人角度讨论形成结果,并展示讨论过程。",
"messages": [
{
"role": "user",
"content": "推荐几个电影"
}
],
"stop_token_ids": [
151329,
151336,
151338
],
"temperature": 0.7
}
Qwen2-72B
- 接口示例
/v1/chat/completions
- 示例body参数
只设置关键的参数,更多参数参考 openAI接口 文档
json
{
"model": "{模型名称}",
"messages": [{
"role": "user",
"content": "你好"
}],
"temperature": 0.7,
"stream": false
}
视觉大模型(以 MiniCPM-V 为例)
- 接口示例
/v1/chat/completions
- 示例body参数
只设置关键的参数,更多参数参考 openAI接口 文档
- 图像识别
json
{
"model": "MiniCPM-V",
"messages": [{
"role": "user",
"content": [{
"type": "text",
"text": "请描述这张图片"
}, {
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJ......"
}
}]
}],
"temperature": 0.7,
"stream": false,
}
- 另外视觉大模型通常也支持普通的对话补全功能。
json
{
"model": "{模型名称}",
"messages": [{
"role": "user",
"content": "Say this is a test!"
}],
"temperature": 0.7,
"stream": true,
"stop_token_ids":[292542]
}