MaaS Standard API V1
This chapter describes the specifications for calling chat APIs.
MaaS Standard API V1 is no longer evolving; prioritize the use of MaaS Standard API V2.
API Information
| Parameter | Description | Example Value |
|---|---|---|
| API URL | API URL for calling the model service. | https://api-ap-southeast-1.modelarts-maas.com/v1/chat/completions |
| model | model parameter in an API call | For details about the value of model, see How Do I Obtain Model Parameters? |
Creating a Chat Request
- Authentication description
MaaS inference services support API key authentication. The authentication header is in the following format:
'Authorization': 'Bearer API key of the region where the service is deployed'
- The request and response parameters are as follows.
Table 2 Request parameters Parameter
Mandatory
Type
Description
model
Yes
String
Definition
Model parameter to call. For details about the value, see Table 1.
Constraints
N/A
Range
N/A
Default Value
N/A
messages
Yes
Array
Definition
Input question. role shows the role, and content shows the dialog content. Example:
"messages": [ {"role": "system","content": "You are a helpful AI assistant."}, {"role": "user","content": "Which number is larger, 9.11 or 9.8?"} ]For more information, see Table 3.
Constraints
N/A
messages.prefix
No
Boolean
Definition
Controls whether to enable continuation mode. In this mode, the user provides a message starting with assistant, and the model completes the rest based on that beginning and the input instruction.
Constraints
To use this feature, ensure that the last message in the messages list has the role set to assistant and the prefix parameter set to true. Example:
messages = [ {"role": "user", "content": "Write a snippet of Python code"}, {"role": "assistant", "content": "```python\n", "prefix": True} ]Range
- True: Enable prefix continuation.
- False: Disable prefix continuation.
Default Value
False
stream_options
No
Object
Definition
Specifies whether to display the number of used tokens during streaming output.
Constraints
This parameter is only valid when stream is set to True. You need to set stream_options to {"include_usage": true} to print the number of tokens used. For more information, see Table 4.
max_tokens
No
Int
Definition
Maximum number of tokens that can be generated for the current task, including tokens generated by the model and reasoning tokens for deep thinking.
Constraints
N/A
Range
The value varies depending on the model. For details, see the maximum output length on the model details page of the MaaS console.
Default Value
N/A
top_k
No
Int
Definition
Controls the model to select only from the top k most probable tokens, influencing the randomness of the generated text. Higher values increase randomness, while lower values enhance determinism.
Constraints
N/A
Range
>=0
Default Value
N/A
top_p
No
Float
Definition
Nucleus sampling probability threshold, used to control the diversity of the content generated by the model. Similar to the temperature parameter, it influences randomness, but offers finer control by dynamically adjusting the pool of possible tokens.
Setting this value near 0 restricts sampling to the highest-probability tokens, yielding highly predictable and deterministic text. Setting this value near 1 allows the model to sample from virtually the entire vocabulary, resulting in higher randomness and more creative, divergent outputs.
Constraints
It is recommended that you adjust either temperature or top_p.
Range
(0,1.0]
Default Value
1.0: All tokens are considered.
temperature
No
Float
Definition
Model sampling temperature. The higher the value, the more random the model output; the lower the value, the more deterministic the output.
Constraints
Adjust either temperature or top_p separately for best results, not both at once.
Range
0 to 2.0
Recommended value: 0.6 for Qwen3 series models.
Default Value
1.0
stop
No
None/String/List
Definition
A list of strings used to stop generation. The output does not contain the stop strings.
For example, if the value is set to ["You," "Good"], text generation will stop once either You or Good is reached.
Constraints
N/A
stream
No
Boolean
Definition
Controls whether to enable streaming inference.
Constraints
N/A
Range
- False: Disable streaming inference.
- true: Enable streaming inference.
Default Value
False
n
No
Int
Number of responses generated for each input message.
- If beam_search is not used, the recommended value range of n is 1 ≤ n ≤10. If n is greater than 1, ensure that greedy_sample is not used for sampling, that is, top_k is greater than 1 and temperature is greater than 0.
- If beam_search is used, the recommended value range of n is 1 < n ≤ 10. If n is 1, the inference request will fail. NOTE:
- For optimal performance, keep n at 10 or below. Large values of n can significantly slow down processing. Insufficient VRAM may cause inference requests to fail.
use_beam_search
No
Boolean
Definition
Controls whether to use beam_search to replace sampling.
Constraints
When this parameter is used, the following parameters must be configured as required:
- n: > 1
- top_p: 1.0
- top_k: -1
- temperature: 0.0
Range
- False: Do not replace sampling with beam search.
- True: Replace sampling with beam search.
Default Value
False
presence_penalty
No
Float
Definition
Presence penalty coefficient, which is an important parameter used to control the diversity of model outputs. This reduces the probability that the model will repeatedly use previously mentioned tokens or topics, thereby encouraging it to generate new content.
As long as a token has appeared at least once in the previously generated text, the model imposes a fixed penalty on it to reduce the probability of it being selected again. The model determines this penalty based solely on whether the token has appeared so far. A positive value increases the likelihood of the model generating novel content.
Constraints
N/A
Range
[-2,2]
- 0: No penalty is applied.
- Positive value: Increases the penalty. A larger value makes the model more likely to introduce new tokens and topics to avoid repetition.
- Negative value: Reduces the penalty (acting as a reward). The model becomes more inclined to reuse previously generated words, which often results in repetitive and verbose text (generally not recommended).
Default Value
0.0
frequency_penalty
No
Float
Definition
Frequency penalty coefficient, which is an important parameter used to control the diversity of model outputs.
The probability of a token reappearing decreases proportionally based on its frequency in the generated text. The more frequently a token appears, the lower its likelihood of being used again.
Constraints
N/A
Range
[-2.0,2.0]
- 0: No penalty is applied.
- Positive value: Increases the penalty. A larger value makes the model more likely to introduce new tokens and topics to avoid repetition.
- Negative value: Reduces the penalty (acting as a reward). The model becomes more inclined to reuse previously generated words, which often results in repetitive and verbose text (generally not recommended).
Default Value
0.0
length_penalty
No
Float
Definition
Imposes a larger penalty on longer sequences in a beam search process.
Constraints
When this parameter is used, the following parameters must be configured as required:
- top_k: -1
- use_beam_search: true
- best_of: > 1
Range
N/A
Default Value
1.0
thinking
No
Object
Definition
Controls whether to enable the deep thinking mode for a model.
Constraints
N/A
thinking.type
Yes
String
Definition
Controls whether to enable the deep thinking mode for a model.
Constraints
N/A
Range
- enabled: The deep thinking mode is enabled. The model must think before answering.
- disabled: The deep thinking mode is disabled. The model directly answers questions without thinking.
Default Value
The default value varies depending on the model. You can log in to the MaaS console and view the description of the deep thinking mode in the Version area on the Model Square > Model Details page.
Table 4 Request parameter stream_options Parameter
Mandatory
Type
Description
include_usage
No
Boolean
Definition
Specifies whether the streaming response includes token usage information.
Constraints
N/A
Range
- True: The token usage information is included in the response. Each chunk contains a usage field that shows the total token usage.
- False: The token usage information is not included in the response.
Default Value
True
Table 5 Response parameters Parameter
Type
Description
id
String
Definition
Unique identifier of this request.
Range
N/A
object
String
Definition
Dialog type.
Range
chat.completion
created
Int
Definition
Time when the request is created, in timestamp format, for example, 1782271333.
Range
N/A
model
String
Definition
Model parameter used in this request.
Range
Model parameter used in this request.
choices
Array
Definition
Model output, including the index and message parameters. In message:
- content is the model's final reply.
- reasoning content is the model's deep thinking content (for DeepSeek models only).
usage
Object
Definition
Statistics on tokens consumed by this request:
- prompt tokens: number of input tokens.
- completion tokens: number of output tokens.
- total tokens: total number of tokens (including input and output tokens).
prompt_logprobs
Float
Definition
Log probability. You can use this to measure the model's confidence in its output or to explore other options the model provides.
Range
N/A
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot