Updated on 2026-07-08 GMT+08:00

OpenAI-compatible APIs

Constraints

This function is only supported in CN-Hong Kong.

API Information

Parameter

Description

Example Value

API URL

API URL for calling the model service.

https://api-ap-southeast-1.modelarts-maas.com/openai/v1/chat/completions

If the OpenAI SDK is used, set base_url to https://api-ap-southeast-1.modelarts-maas.com/openai/v1.

Authentication request header

Provides the server with identity authentication/authorization credentials.

"Authorization": "Bearer $MaaS_API_Key"

Supported Models

You can log in to the MaaS console and enable the following models on the Model Inference > Real-Time Inference > Built-in Services page. On the model details page in the Model Square, you can view detailed information about the models.

Model

Version

Supported Region

Value of model

GLM

GLM-5

CN-Hong Kong

glm-5

GLM-5.1

CN-Hong Kong

glm-5.1

GLM-5.2

CN-Hong Kong

glm-5.2

DeepSeek

DeepSeek-V4-Pro

CN-Hong Kong

deepseek-v4-pro

DeepSeek-V4-Flash

CN-Hong Kong

deepseek-v4-flash

DeepSeek-V3.1

CN-Hong Kong

deepseek-v3.1-terminus

DeepSeek-V3

CN-Hong Kong

DeepSeek-V3

DeepSeek-V3.2

CN-Hong Kong

deepseek-v3.2

DeepSeek-R1-0528

CN-Hong Kong

deepseek-r1-250528

Request Parameters

Category

Parameter

Type

Mandatory

Range

Description

General

model

string

Yes

-

Model ID for generating content.

Default value: N/A

messages

object[]

Yes

-

List of messages in a dialog. Different models support different types of messages.

Default value: N/A

System message

messages.role

string

Yes

system

Role that sends a message.

Default value: N/A

messages.content

string/object[]

Yes

-

Message sent by the current role.

Default value: N/A

messages.content.type

string

Yes

text

Message type.

Default value: N/A

messages.content.text

string

Yes

-

Text content of the message.

Default value: N/A

User message

messages.role

string

Yes

user

Role that sends a message.

Default value: N/A

messages.content

string/object[]

Yes

-

Message sent by the current role.

Default value: N/A

messages.content.type

string

Yes

text

Message type.

Default value: N/A

messages.content.text

string

Yes

-

Text content of the message.

Default value: N/A

Assistant message

messages.role

string

Yes

assistant

Role that sends a message.

Default value: N/A

messages.content

string/object[]

Yes

-

Message sent by the current role.

Default value: N/A

messages.tool_calls

array

No

-

Tool call records from previous model responses in the dialog history.

Default value: N/A

messages.tool_calls.id

string

Yes

-

ID of the called tool.

Default value: N/A

messages.tool_calls.type

string

Yes

function

Tool type.

Default value: N/A

messages.tool_calls.function

object

Yes

-

Function information corresponding to the tool called by the model.

Default value: N/A

messages.tool_calls.function.arguments

string

Yes

-

JSON parameters generated by the model for calling the function.

Default value: N/A

messages.tool_calls.function.name

string

Yes

-

Name of the function to be called by the model.

Default value: N/A

Tool message

messages.role

string

Yes

tool

Role that sends a message.

Default value: N/A

messages.tool_call_id

string

Yes

-

ID of the tool called by the model.

Default value: N/A

messages.content

string/object[]

Yes

-

Message sent by the current role.

Default value: N/A

Deep thinking control

chat_template_kwargs

dict[str, Any]

No

-

Additional keyword parameters passed to the template renderer, which can be used to control whether the model enables deep thinking mode. For details, see Thinking Control for Deep Thinking Models.

Default value: N/A

Model output behavior configuration

max_completion_tokens

integer/null

No

The value varies depending on the model. For details, see the maximum output length and maximum chain-of-thought (CoT) length on the model details page of the MaaS console.

Maximum length of the model output, including the model answer (content) and CoT (reasoning_content).

After this parameter is set, the token length of the model output does not exceed the value of max_completion_tokens.

  • This parameter cannot be set together with max_tokens. Otherwise, an error is reported.
  • Even when the thinking mode is disabled, max_completions_tokens remains effective for deep thinking models, controlling only the output token length of the generated content.

Default value: N/A

max_tokens

integer/null

No

The value varies depending on the model. For details, see the maximum output length on the model details page of the MaaS console.

Maximum length of a model response, in tokens.

  • The model response does not contain the CoT content.

    Model response = Model output – Model CoT (if any).

  • The total length of output tokens is also restricted by the model's context length.

Default Value: 4K

continue_final_message

boolean

No

-

Specifies whether to enable prefix continuation.

To enable this function, set continue_final_message to False. Otherwise, an error is reported.

Default value: False

add_generation_prompt

boolean

No

-

If this parameter is set to True, the generation prompt will be added to the chat template. This is a parameter used by the chat template in the tokenizer configuration of the model.

This parameter and continue_final_message are mutually exclusive and cannot be set to True simultaneously.

Default value: True

temperature

float/null

No

[0, 2]

Sampling temperature, used to control the randomness of the content generated by the model.

A higher value (for example, greater than 1) will make the model output more random, divergent, and creative, while a lower value (for example, 0.1) will make the output more focused, deterministic, and conservative.

It is recommended that you adjust either temperature or top_p.

DeepSeek-V3, DeepSeek-R1-0528, and DeepSeek-V4 apply special handling to inputs:

  • DeepSeek-V3: If the temperature is less than or equal to 1, it is multiplied by 0.3; if the temperature is greater than 1, 0.7 is subtracted from it. If the temperature is empty, the default is 0.6.
  • DeepSeek-R1-0528: Regardless of user input, the value remains 0.6.
  • DeepSeek-V4: In thinking mode, the value is always 1.0, regardless of the user input.

Default value: For other models, the input is used if provided; otherwise, the default is 0.6.

top_p

float/null

No

(0,1]

Nucleus sampling probability threshold, used to control the diversity of the content generated by the model. Similar to the temperature parameter but operates differently, allowing finer control over the vocabulary range of the model's output.

When set close to 0, the model samples from only the most probable tokens, resulting in very conservative and highly deterministic outputs. When set close to 1, there is virtually no restriction on the vocabulary, leading to more random and divergent outputs.

It is recommended to adjust either temperature or top_p, but not both simultaneously.

Default value:

  • DeepSeek-V4: In thinking mode, the value is always 1.0, regardless of the user input.
  • Other models: 0.7

top_k

integer

No

≥ 0

Controls the model to select only from the top k most probable tokens during generation, influencing the randomness of the generated text.

Higher values increase randomness, while lower values enhance determinism.

Default value: 20

frequency_penalty

number/null

No

[-2, 2]

Frequency penalty coefficient, where the model penalizes new tokens based on their frequency of occurrence. Positive values reduce the likelihood of repetitive token sequences.

DeepSeek-V4: In thinking mode, the value is always 0, regardless of the user input.

Default value: 0

presence_penalty

number/null

No

[-2, 2]

A penalty coefficient where the model penalizes a new token based on its prior occurrence. A positive value increases the likelihood of the model generating novel content.

DeepSeek-V4: In thinking mode, the value is always 0, regardless of the user input.

Default value: 0

logit_bias

map/null

No

-

This parameter is not supported by models with deep thinking capabilities. It adjusts the probability of a specified token appearing in the model's output. The input is a JSON object mapping tokens to bias values [-100, 100].

Lower values decrease the likelihood, while higher values increase the chance of selection.

Default value: null

stream

boolean/null

No

-

Determines if the response content is returned in a streaming manner.

  • false: Returns results once all content has been generated by the model.
  • true: Returns content piece by piece, ending with data: [DONE].

Default value: false

stream_options

object/null

No

-

Options for streaming responses. Can be set when stream is true.

Default value: N/A

stream_options.include_usage

boolean

No

-

Indicates whether to output the token usage information of the current request before the model streaming output ends. Currently, this function cannot be disabled.

  • true: An additional chunk is returned before data: [DONE]. In this chunk, the usage field displays the token usage of the entire request, and the choices field is an empty array.

    Default Value: true

stop

string / string[] / null

No

null

When the model encounters the string specified in the stop field, the generation stops and the string itself does not appear in the response. A maximum of four strings are supported. The stop token does not hit the token in the CoT, but only hits the part in the formal answer content.

Default value: N/A

reasoning_effort

string

No

  • high
  • max

Controls the reasoning intensity.

Involved models: DeepSeek-V4 series and GLM-5.2

Default value: high

Tool calls

tools

object[]/null

No

-

List of tools to be called, which can be included in the model's returned information. Configure this structure when you require the model to specify the tools to be called.

Default value: N/A

tools.type

string

Yes

function

Tool type.

Default value: N/A

tools.function

object

Yes

-

Specifies whether the model return contains the tools to be called.

Default value: N/A

tools.function.name

string

Yes

-

Name of the function to be called.

Default value: N/A

tools.function.description

string

No

-

Description of the function to be called. The model will determine if the tool is needed for the current task based on this description.

Default value: N/A

tools.function.parameters

object

No

-

Function request parameters, described in JSON format. Example:

{
  "type": "object",
  "properties": {
    "parameter name": {
      "type": "string | number | boolean | object | array",
      "description": "parameter description"
    }
  },
  "required": ["mandatory parameters"]
}

Parameters must conform to JSON specifications.

Default value: N/A

tool_choice

string/object

No

  • none
  • auto
  • named

Controls the mode of how the model calls tools.

  • none : Do not call any tool.
  • auto : The model decides whether to call tools or not.
  • named: The model must call the specified function.

Default value: auto

tool_choice.type

string

Yes

function

Type of the call, which should be function here.

Default value: N/A

tool_choice.name

string

Yes

-

Name of the tool to be called.

Default value: N/A

Response Parameters (Non-Streaming)

Parameter

Type

Description

created

integer

Unix timestamp of the creation time of this request, in seconds.

id

string

Unique identifier of this request.

model

string

Model ID used in this request.

object

string

Fixed as chat.completion.

choices

object[]

Model output content of this request.

choices.finish_reason

string

Reason why the model stopped generating:

  • stop: The model output ended naturally or hit the field specified in the request parameter stop.
  • length: The model output triggered the max_tokens limit (length limit of CoT + answer content).
  • tool_calls: The model triggered tool calls.

choices.index

integer

Index of the current element in the choices list.

choices.message

object

Content output by the model.

choices.message.role

string

Role of the output content.

choices.message.content

string

Message content generated by the model.

choices.message.reasoning_content

string/null

CoT content generated by the model, only returned by deep thinking models.

choices.message.tool_calls

object[]/null

Tool call information generated by the model, returned only if tool calls were triggered.

choices.message.tool_calls.id

string

ID of the called tool.

choices.message.tool_calls.type

string

Tool type. Currently, it only supports function.

choices.message.tool_calls.function

object

Function called by the model.

choices.message.tool_calls.function.name

string

Name of the function called by the model.

choices.message.tool_calls.function.arguments

string

JSON format input generated by the model for calling the function.

choices.logprobs

object/null

Logarithmic probability information of the current content.

usage

object

Token usage of this request.

usage.completion_tokens

integer

Tokens consumed by the model's output content.

usage.prompt_tokens

integer

Number of tokens input to the model for processing.

usage.total_tokens

integer

Total number of tokens consumed by this request (input + output).

Response Parameters (Streaming)

Parameter

Type

Description

created

integer

Unix timestamp of the creation time of this request, in seconds.

id

string

Unique identifier of this request.

model

string

Name and version of the model used in this request.

object

string

Fixed as chat.completion.chunk.

choices

object[]

Model output content of this request.

choices.finish_reason

string

Reason why the model stops generating tokens. Range:

  • stop: The model output ends naturally or is truncated due to matching the field specified in the stop request parameter.
  • length: The model output is truncated because the model output limit is reached.
  • tool_calls: The model calls tools.

choices.index

integer

Index of the current element in the choices list.

choices.delta

object

Incremental output from the model.

choices.delta.role

string

Role of the output content.

choices.delta.content

string

Message content generated by the model.

choices.delta.reasoning_content

string/null

The model's CoT process.

choices.delta.tool_calls

object[]/null

Tool calls generated by the model.

choices.message.tool_calls.id

string

ID of the called tool.

choices.message.tool_calls.type

string

Tool type. Currently, it only supports function.

choices.message.tool_calls.function

object

Function called by the model.

choices.message.tool_calls.function.name

string

Name of the function called by the model.

choices.message.tool_calls.function.arguments

string

JSON format parameter generated by the model for calling the function.

The model does not always generate valid JSON, and may fabricate some parameters that are not defined in your function parameter specifications. Before calling a function, verify that these parameters are valid in your code.

choices.logprobs

object/null

Logarithmic probability information of the current content.

usage

object

Token usage of this request.

usage.completion_tokens

integer

Tokens spent on the model's output content.

usage.prompt_tokens

integer

Number of tokens input to the model for processing.

usage.total_tokens

integer

Total number of tokens consumed by this request (input + output).

Thinking Control for Deep Thinking Models

Model

Default Mode

Thinking Control

GLM-5.2

GLM-5.1

GLM-5

Deep thinking

"chat_template_kwargs": {"thinking": True}

DeepSeek-V4-Flash

DeepSeek-V4-Pro

Deep thinking

"chat_template_kwargs": {"thinking": True}

DeepSeek-R1-0528

Deep thinking

Cannot be disabled.

DeepSeek-V3.1

Non-thinking

"chat_template_kwargs": {"thinking": True}

DeepSeek-V3.2

Non-thinking

"chat_template_kwargs": {"thinking": True}

Tool Choices for Models

Model

Supported Tool Choice

GLM-5.2

GLM-5.1

  • none
  • auto
  • named

GLM-5

  • none
  • auto

DeepSeek-V4-Flash

DeepSeek-V4-Pro

DeepSeek-R1-0528

DeepSeek-V3.2

  • none
  • auto
  • named

DeepSeek-V3

DeepSeek-V3.1

  • auto
  • named