跳转至

MaaS_Baichuan

请求协议

https

参数名 类型 必填 描述
Content-Type string 固定为 application/json
Authorization string Bearer ${YOUR_AK}

请求 URL

POST https://{新平台域名}/v1/ai/{endpointPath}/chat/completions

请求 Body 参数

参数名 二级参数 三级参数 四级参数 类型 必填 描述
model - - - string 使用的模型 ID
messages - - - array[json] 对话消息列表 (历史对话按从老到新顺序填入)
role - - string 消息作者的角色,为以下其中之一 1、user 2、assistant 3、system
content - - object 消息内容,string或array[json]类型
- - - string content为string类型时,消息内容为普通文本
- - - array[json] content为array[json]类型时,消息内容为文本结构
- type - string content为array[json]类型时填写此字段,内容类型,必须为text或者file两者中一个
- text - string content为array[json]类型时填写此字段,当 type 为 text 时,填写的消息文本
- file - object content为array[json]类型时填写此字段,当 type 为 file 时,填写的文件内容
- - file_id string content为array[json]类型时填写此字段。
stream - - - boolean 是否使用流式接口,默认值为 false
temperature - - - float 取值范围: [.0f, 1.0f]。 多样性,越高,多样性越好, 缺省 0.3
top_p - - - float 取值范围: [.0f, 1.0f)。值越小,越容易出头部, 缺省 0.85
top_k - - - int 取值范围: [0, 20]。 搜索采样控制参数,越大,采样集大, 0 则不走 top_k 采样筛选策略,最大 20(超过 20 会被修正成 20),缺省 5
max_tokens - - - int 回答产生的最大 token 数。取值范围[1,32000]
metadata - - - map 扩展参数
evidence_scope - - string 证据材料获取范围(仅对Baichuan-M3-Plus模型生效)。支持 grounded、cited两种,默认为grounded。 grounded已对齐证据, 模型grounding阶段中被选取并校验的全部证据材料,但不要求这些证据一定在最终回答中被明确引用。 cited已引用证据,在最终模型输出中被明确引用(如通过 citation 编号)的证据材料,是grounded证据的子集。
disable_follow-up_question_extension - - boolean 是否禁用回复里的问题扩展。true: 禁用扩展; false: 不禁用扩展,默认为false。(仅对Baichuan-M3-Plus模型生效)。
output_style - - string 回答风格。支持expert 专业模式、patient 通俗模式,不传递参数默认为专业模式。(仅对Baichuan-M3-Plus模型生效)。
thinking - - - map 思考的扩展参数,仅限Baichuan-M3使用。
budget_tokens - - int 思考的token数,取值范围:大于等于 1024并且小于 max_tokens

请求示例

curl --location --request POST 'https://{新平台域名}/v1/ai/{endpointPath}/chat/completions \
--header 'Authorization: Bearer ${YOUR_AK}' \
--header 'Content-Type: application/json' \
--data-raw '{
            "model": "Baichuan-M3",
            "messages": [
               {
                  "role": "user",
                  "content": "小儿感冒咳嗽,痰咳不出来怎么办?"
               }
            ],
            "stream": false,
            "max_tokens": 3000,
            "thinking": {
                  "budget_tokens": 2000
            }
         }'

响应示例

{
    "id": "chatcmpl-TT8pnXcBIF38VECBUAWLoaAq",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "**暂时不...如有其他问题,随时可以问我。🙏\n(注意:线上咨询不能替代面诊。如有任何不确定,请寻求专业医生的帮助。)",
                "reasoning_content": "嗯,用户问的是小儿感冒咳嗽,痰咳不出来怎么办...避免用太专业的术语,让家长容易理解。同时要强调不要自己乱用药,尤其是抗生素和止咳药。\n"
            },
            "finish_reason": "stop",
            "native_finish_reason": "stop"
        }
    ],
    "created": 1779243318,
    "model": "MaaS_Baichuan_M3_20260113",
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 43,
        "completion_tokens": 2065,
        "total_tokens": 2108,
        "search_count": 0
    }
}

流式请求示例

 curl --location --request POST 'https://{新平台域名}v1/ai/{endpointPath}/chat/completions \
--header 'Authorization: Bearer ${YOUR_AK}' \
--header 'Content-Type: application/json' \
 -d '{
        "model": "Baichuan-M3",
        "messages": [
        {
            "role": "user",
            "content": "对于肌酐清除率低于30mL/min的患者,使用万古霉素的负荷剂量和维持剂量应如何调整?"
        }
        ],
        "stream": true,
        "max_tokens":12000,
        "thinking":{
           "budget_tokens": 2000
        }
    }'

OpenAI SDK调用方式

from openai import OpenAI

client = OpenAI(
    api_key="${YOUR_AK}",
    base_url="{新平台域名}/v1",
)

completion = client.chat.completions.create(
    model="MaaS_Baichuan_M3_20260113",
    messages=[
        {"role": "user", "content": "北京有哪些美食"}
    ],
    stream=True
)

for chunk in completion:
    print(chunk.choices[0])