跳转至

AI Research接口文档

公共信息

参数 描述 示例
basePath 调用mass api的基础路径,包含/v1/ai固定路径 https://genaiapi.cloudsway.net/v1/ai
endpointPath 调用mass api的生成的一段随机路径 RkBOAlaWzKcubSji
AccessKey 调用mass api的accessKey RWxxxxxxxx0Gd

请求方法

POST

请求路径

{basePath}/{endpointPath}/chat/completions

参数 描述 示例
Authorization AccessKey
Bearer ${AccessKey}
Bearer RWxxxxxxxx0Gd

请求body

参数 类型 示例说明
model String 模型名称:Deepseek_R1_Search,Deepseek_V3_Search
stream boolean true:流式false:非流式
messages List [{"role":"user", "content": "海因定理的证明"}]
max_tokens int 最大token数

示例

curl --location 'https://genaiapi.cloudsway.net/v1/ai/xxxxx/chat/completions' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
    "model": "Deepseek_R1_Search",
    "messages": [
        {
            "role": "user",
            "content": "1+1等于几"
        }
    ],
    "stream": false,
    "stream_options": {
        "include_usage": true
    }
}'

响应结构

除了标准的openai响应结构外,增加了reference数据:搜索到的网页信息

参数 类型 示例说明
reference List "reference": [{"name": "1+1等于几?有多少种答案 - 百度知道", "url":"https://zhidao.baidu.com/question/400830935332337885.html", "snippet": "1+1等于几?..." }, {"name": "“1+1”到底是什么?", "url": "https://baijiahao.baidu.com/s?id=1646919430155086496", "snippet": "..." }]
name 网站名称
url 网址
snippet 网站摘要

非流式响应示例

{
    "id": "021741315812172e641ee46b93e8beaf1fb3bde23bbe0c6ccbaba",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\n\n1+1在不同领域和情境中存在多种解释和答案...",
                "reasoning_content": "好的,用户问的是“1+1等于几”,..."
            },
            "finish_reason": "stop"
        }
    ],
    "created": 1741315831,
    "model": "deepseek-r1-250120",
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 1262,
        "completion_tokens": 1030,
        "total_tokens": 2292,
        "completion_tokens_details": {
            "reasoning_tokens": 572
        }
    },
    "reference": [
        {
            "name": "1+1等于几?有多少种答案 - 百度知道",
            "url": "https://zhidao.baidu.com/question/400830935332337885.html",
            "snippet": "1+1等于几?有多少种答案有12种答案。..."
        },
        {
            "name": "“1+1”到底是什么?为什么那么多数学家要去证明它",
            "url": "https://baijiahao.baidu.com/s?id=1646919430155086496",
            "snippet": "本文介绍了哥德巴赫猜想的历史和现状,..."
        }
    ]
}

流式响应示例

流式响应中,reference内容会在第一个chunk中返回,后续是chunk结构也是标准的openai响应结构

data: {
    "choices": [
        {
            "delta": {
                "content": "",
                "reasoning_content": "好的",
                "role": "assistant"
            },
            "index": 0
        }
    ],
    "created": 1741316034,
    "id": "02174131603458223463574da793b897ea7fed342331c6eab8d9b",
    "model": "deepseek-r1-250120",
    "service_tier": "default",
    "object": "chat.completion.chunk",
    "reference": [
        {
            "name": "周杰伦(华语流行乐男歌手、音乐人、演员、导演、编剧 ...",
            "url": "https://baike.baidu.com/item/%E5%91%A8%E6%9D%B0%E4%BC%A6/129156",
            "snippet": "周杰伦(Jay Chou),..."
        }
    ]
}


data: {"choices":[{"delta":{"content":"","reasoning_content":",","role":"assistant"},"index":0}],"created":1741316034,"id":"02174131603458223463574da793b897ea7fed342331c6eab8d9b","model":"deepseek-r1-250120","service_tier":"default","object":"chat.completion.chunk","usage":null}

....
data: {"choices":[],"created":1741316034,"id":"02174131603458223463574da793b897ea7fed342331c6eab8d9b","model":"deepseek-r1-250120","object":"chat.completion.chunk","usage":{"completion_tokens":688,"prompt_tokens":1079,"total_tokens":1767,"prompt_tokens_details":{"cached_tokens":0},"completion_tokens_details":{"reasoning_tokens":324}}}

data: [DONE]