Skip to content

MaaS_Baichuan

Request Protocol

https

Parameter Name Type Required Description
Content-Type string is Fixed to application /json
Authorization string is Bearer ${YOUR_AK}

Request URL

POST https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/chat/completions

Request Body Parameters

Parameter Name Secondary Parameter Level 3 Parameter Level 4 Parameter Type Required Description
model - - - string is Model ID Used
messages - - - array[json] is Conversation message list (historical conversations are filled in chronological order from oldest to newest)
role - - string is The role of the message author is one of the following: 1. user 2. assistant 3. system
content - - object is Message content, type string or array[json]
- - - string No When content is of type string, the message content is plain text
- - - array[json] No When content is of type array[json], the message content is in text structure
- type - string No Fill in this field when content is of type array[json], content type, must be either text or file
- text - string No Fill in this field when content is of type array[json]; when type is text, fill in the message text
- file - object No Fill in this field when content is of type array[json], and fill in the file content when type is file
- - file_id string No Fill in this field when content is of type array[json].
stream - - - boolean No Whether to use the streaming interface, with a default value of false
temperature - - - float No Value range: [.0f, 1.0f]. Diversity, the higher, the better, default 0.3
top_p - - - float No Value range: [.0f, 1.0f). The smaller the value, the easier it is to get a head, default 0.85
top_k - - - int No Value range: [0, 20]. Search sampling control parameter. The larger the value, the larger the sampling set. A value of 0 means not using the top_k sampling screening strategy. The maximum value is 20 (values exceeding 20 will be corrected to 20), and the default value is 5.
max_tokens - - - int No Maximum number of tokens generated by the response. Range: [1, 32000]
metadata - - - map No Extended Parameters
evidence_scope - - string No Evidence material acquisition scope (only applicable to the Baichuan-M3-Plus model). Supports two types: grounded and cited, with grounded as the default. Grounded refers to aligned evidence, which includes all evidence materials selected and verified during the model grounding phase, but does not require these materials to be explicitly cited in the final answer. Cited refers to cited evidence, which includes evidence materials explicitly cited (e.g., through citation numbers) in the final model output and is a subset of grounded evidence.
disable_follow-up_question_extension - - boolean No Whether to disable question expansion in replies. true: disable expansion; false: do not disable expansion, default is false. (Only applicable to the Baichuan-M3-Plus model).
output_style - - string No Answer style. Supports expert professional mode and patient popular mode; if no parameters are passed, it defaults to professional mode. (Only applicable to the Baichuan-M3-Plus model).
thinking - - - map No Extended parameters for thinking, only applicable to Baichuan-M3.
budget_tokens - - int No Number of tokens for thinking, range: greater than or equal to 1024 and less than max_tokens

Request Example

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": "What should be done if a child has a cold and cough but cannot expel phlegm?"
               }
            ],
            "stream": false,
            "max_tokens": 3000,
            "thinking": {
                  "budget_tokens": 2000
            }
         }'

Response Example

{
    "id": "chatcmpl-TT8pnXcBIF38VECBUAWLoaAq",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "**Not for now... If you have any other questions, feel free to ask me. 🙏
(Note: Online consultation cannot replace an in-person visit. If you are unsure about anything, please seek the help of a professional doctor.))",
                "reasoning_content": "Well, the user is asking about what to do when a child has a cold and cough but can't bring up the phlegm... Avoid using overly technical terms so that parents can easily understand. At the same time, emphasize not to self-medicate, especially with antibiotics and cough suppressants."
            },
            "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
    }
}

Streaming Request Example

 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": "question"
        }
        ],
        "stream": true,
        "max_tokens":12000,
        "thinking":{
           "budget_tokens": 2000
        }
    }'

OpenAI SDK Call Method

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": "question"}
    ],
    stream=True
)

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

File Management Interface Description

File upload can be used with documents that support functions such as Knowledge Base retrieval. Supported document formats: pdf, doc, docx, txt, xlsx, xls, csv, pptx.

Restricted Content Limit Quantity
Total File Size 5GB
Single file size 50MB
Upload Frequency 60rpm

1. File Object

Field Name Type Description
id string Unique identifier for the file, used for the file interface
bytes integer File Byte Size
created_at integer Creation Time, Unix Timestamp (seconds)
filename string File Name
object string Type, file object type is 'file'
purpose string Usage intent of the file. Details are as follows: Knowledge Base: knowledge-base Assistant Conversation: assistants Document Parsing: file-parsing Baichuan-M2-Plus/Baichuan-M3-Plus Conversation: medical When the intent is medical, supported document formats: pdf, doc, docx, txt, html, htm, md, markdown, rft, xml, csv, png, jpg, jpeg, gif, bmp, webp, json

2. File List Query

[POST] /v1/ai/{endpointPath}/files

2.1 Return Value

Field Name Level 1 Subparameter Type Description
data - array[object] Returns a list of file objects
id string Unique identifier for the file, used for the file interface
bytes integer File Byte Size
created_at integer Creation Time, Unix Timestamp (seconds)
filename string File Name
object string Type, file object type is 'file'
purpose string Usage intention of the file. Such as 'Knowledge Base'
object - string Object type "list"

2.2 Interface Example

2.2.1 Request

curl https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files\
  -H "Authorization: Bearer $API_KEY"

2.2.2 Return Value

{
    "data": [
        {
            "id": "file-123",
            "bytes": 1562,
            "created_at": 1701832828,
            "filename": "xxx.pdf",
            "object": "file",
            "purpose": "knowledge-base"
        },
        {
            "id": "file-124123",
            "bytes": 183237,
            "created_at": 1702201134,
            "filename": "xxx.doc",
            "object": "file",
            "purpose": "knowledge-base"
        }
    ],
    "object": "list"
}

3. File Upload Interface

[POST] https://genaiapi.cloudsway.net/v1 /ai/{endpointPath}/files

Limitations: The size of a single document is limited to 50MB. The Knowledge Base currently supports files of types pdf, doc, docx, xlsx, xls, csv, and pptx, among which xlsx, xls, and csv can only upload QA pair data according to a fixed template. The specific template can be found on the document upload page of the Experience Center. If you receive a rate limit error, it means you have made too many requests in a short period of time, and the API will reject new requests until the specified time has passed.

3.1 Request Parameters

Parameter Name Type Is it required? Description
file file Y Content of the uploaded file
purpose string Y Document Intent

3.2 Return Value

File Object

3.3 Interface Example

3.3.1 Request

curl https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files \
  -H "Authorization: Bearer $API_KEY" \
--form 'purpose="medical"' \
--form 'file=@"C:\\Users\\user\\Desktop\\test.txt"'

3.3.2 Return Value

{
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "filename": "mydata.pdf",
  "purpose": "knowledge-base"
}

4. File Deletion Interface

[DELETE] https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files/{fileId} Used to delete a file. Files used by the Knowledge Base need to be unlinked first before they can be deleted.

4.1 Request Parameters

Parameter Name Type Is it required? Description
file_id string Y Document ID

4.2 Interface Example

4.2.1 Request

curl https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files/{fileId} \
  -X DELETE \
  -H "Authorization: Bearer $API_KEY"

4.2.2 Return Value

{
  "id": "file-abc123",
  "object": "file",
  "deleted": true
}

5. File Retrieval Interface

[GET]

https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files/{fileId} Returns information about a file.

5.1 Request Parameters

Parameter Name Type Is it required? Description
file_id string Y Document ID

5.2 Return Value

Returns the file object information for the specified file ID

5.3 Interface Example

5.3.1 Request

curl https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files/{fileId} \
  -H "Authorization: Bearer $API_KEY"

5.3.2 Return Value

{
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "filename": "mydata.pdf",
  "purpose": "knowledge-base",
}

6. File Parsing Content Retrieval Interface

Only process files with the intention offile-parsingormedical. When calling the file upload interface, please setpurposetofile-parsingormedical.

[GET] https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files/{fileId}/parsed-content

Returns the document parsing result.

6.1 Request Parameters

Parameter Name Type Is it required? Description
file_id string Y Document ID

6.2 Return Value

Parameter Name Type Description
status string init: to be parsed; parsing: parsing; online: parsing successful; fail: parsing failed; unsafe: failed security check.
content string Document Parsing Content

6.3 Interface Example

6.3.1 Request

curl https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/files/{fileId}/parsed-content \
  -H "Authorization: Bearer $API_KEY"

6.3.2 Return Value

{
    "status": "online",
    "content": "xxx"
}