Updated on 2026-06-23 GMT+08:00

Deep Thinking

When handling complex tasks, traditional models often struggle to provide comprehensive and insightful responses. To address this, you can use advanced models capable of deep thinking. These models analyze and break down questions before providing answers, resulting in more thorough and detailed responses. When you query the model, MaaS returns the logical thought process (chain-of-thought content) used by the model before answering the question. This allows you to observe the model's reasoning process and utilize this information. By enabling models with deep thinking capabilities, you can significantly enhance the quality and depth of responses. Additionally, reviewing the chain-of-thought content helps you better understand the model's reasoning process.

How It Works

In addition to generating questions and answers, deep-thinking models also produce Chain-of-Thought (CoT) reasoning traces. CoT refers to the model's ability to generate a series of intermediate reasoning steps when solving complex problems. This capability allows the model not only to provide the final answer but also to demonstrate its reasoning process, thereby enhancing the model's explainability and transparency.

Supported Models

For the models currently supported for deep thinking, see Deep Thinking.

API Description

For the complete parameters for model calls, see Sending a Chat Request (Chat/Post).

Prerequisites

  • You have subscribed to the built-in service on the Model Inference > Real-Time Inference > Built-in Services tab page. For details, see Subscribing to a Built-in Service.

Chain of Thought Usage Guide

Table 1 CoT switch

Model

CoT Switch Parameter Format

Parameter

Default Configuration

GLM-5

GLM-5.1

GLM-5.2

"thinking": {

"type": "enabled"

}

  • "type": enabled indicates CoT is enabled.
  • "type": disabled indicates CoT is disabled.

CoT enabled

DeepSeek-V4-Flash

DeepSeek-V4-Pro

"thinking": {

"type": "enabled"

}

  • "type": enabled indicates the CoT is enabled.
  • "type": disabled indicates the CoT is disabled.

CoT enabled

DeepSeek-V3.1

DeepSeek-V3.2

"thinking": {

"type": "disabled"

}

  • "type": enabled indicates the CoT is enabled.
  • "type": disabled indicates the CoT is disabled.

CoT disabled

The constraints for DeepSeek-V3.1 are as follows:

  • Function calling is incompatible with the CoT; it is not recommended to use them simultaneously.
  • Enabling the CoT does not support prefix continuation.
  • The ability to truncate only the content and not the CoT is ineffective.
  • After enabling the CoT, guided_choice is unavailable, and reasoning_content is incompatible with guided_decoding.

Getting Started

Run the following code to quickly call DeepSeek-V3.2 with deep thinking enabled via streaming output.

import requests
import json

if __name__ == '__main__':
    url = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions"  # API address
    api_key = "MAAS_API_KEY"  # Replace MAAS_API_KEY with the obtained API key.

    # Send request.
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {api_key}'
    }
    data = {
        "model": "deepseek-v3.2",  # model parameter. The following uses deepseek-v3.2 as an example. You can change the model parameter as needed. For details, see Deep Thinking.
        "messages": [
            {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello"}
        ],
        "thinking": {
            "type": "enabled" # Enable deep thinking mode
         }
       
    }
    response = requests.post(url, headers=headers, data=json.dumps(data), verify=False)

    # Print result.
    print(response.status_code)
    print(response.text)
curl -X POST "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MAAS_API_KEY" \
  -d '{
    "model": "deepseek-v3.2",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello"}
    ],
    "thinking": {
       "type": "enabled"
     }     
  }'
from openai import OpenAI
import httpx

base_url = "https://api-ap-southeast-1.modelarts-maas.com/openai/v1"  # API address
api_key = "MAAS_API_KEY"  # Replace MAAS_API_KEY with the obtained API key.

client = OpenAI(api_key=api_key, base_url=base_url, http_client=httpx.Client(verify=False))

response = client.chat.completions.create(
    model="deepseek-v3.2",  # The following uses deepseek-v3.2 as an example. You can change the model parameter as needed. For details, see Deep Thinking.
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Hello"},
    ],
    extra_body={
         "thinking": {
            "type": "enabled" # Enable deep thinking mode
         }
    }
)

print(response.choices[0].message.content)
print(response.choices[0].message.reasoning_content)

JDK 15 or later is recommended.

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class ChatCompletionsExample {
    public static void main(String[] args) {
        // API URI
        String apiUrl = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions" ;
       // Replace MAAS_API_KEY with the obtained API key.
        String apiKey = "MAAS_API_KEY";
        // Replace it with the model you want to call, for example, "deepseek-v3.2".
        String modelName = "deepseek-v3.2";
        // Construct a request body.
        String requestBody = String.format(
                """
                        {
                            "model": "%s",
                            "messages": [
                                {"role": "system", "content": "You are a helpful assistant."},
                                {"role": "user", "content": "Hello"}
                            ],
                            "thinking": {
                                 "type": "enabled"
                            }
                        }""", modelName);
        // Create an HttpClient.
        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();
        // Create a request.
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(apiUrl))
                .header("Content-Type", "application/json")
                .header("Authorization", "Bearer " + apiKey)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();
        try {
            // Send the request and print the result.
            HttpResponse<String> response = client.send(
                    request, HttpResponse.BodyHandlers.ofString());
            System.out.println("HTTP Status: " + response.statusCode());
            System.out.println("Response Body:\n" + response.body());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Multi-Turn Dialogue

Combining system messages, model messages, and user messages enables multi-turn conversations. To maintain context within a specific topic, you can input historical conversation records to the model.

The following is an example code for a multi-turn conversation with deep thinking enabled. You can replace the model by modifying the model parameter. For details about the model parameter, see Text Generation.

reasoning_content is an output field of the model and should not be used as input. If this field is included in the messages sequence, it will be ignored and not used as model input. During multi-turn conversations, only the role and content fields should be retained. Refer to the example below. For more details, see Sending a Chat Request (Chat/Post).

import requests
import json

if __name__ == '__main__':
    url = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions"  # API address
    api_key = "MAAS_API_KEY"  # Replace MAAS_API_KEY with the obtained API key.

    # Send request.
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {api_key}'
    }
    data = {
        "model": "deepseek-v3.2",# The following uses deepseek-v3.2 as an example. You can change the model parameter as needed. For details, see Deep Thinking.
        "messages": [
             {"role": "system", "content": "You are a helpful assistant."},     
         {"role": "user", "content": "Hello"},
             {"role": "assistant", "content": "Hello! Nice to meet you!"},
         {"role": "user", "content": "Introduce yourself."}
        ],
        "thinking": {
            "type": "enabled" # Enable deep thinking mode
        }
    }
    response = requests.post(url, headers=headers, data=json.dumps(data), verify=False)

    # Print result.
    print(response.status_code)
    print(response.text)
curl -X POST "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MAAS_API_KEY" \
  -d '{
    "model": "deepseek-v3.2",
    "messages": [
         {"role": "system", "content": "You are a helpful assistant."},     
         {"role": "user", "content": "Hello"},
         {"role": "assistant", "content": "Hello! Nice to meet you!"},     
         {"role": "user", "content": "Introduce yourself."}
    ],
    "thinking": {
         "type": "enabled"
     }
  }'
from openai import OpenAI
import httpx

base_url = "https://api-ap-southeast-1.modelarts-maas.com/openai/v1"  # API address
api_key = "MAAS_API_KEY"  # Replace MAAS_API_KEY with the obtained API key.

client = OpenAI(api_key=api_key, base_url=base_url, http_client=httpx.Client(verify=False))

response = client.chat.completions.create(
    model="deepseek-v3.2",  # The following uses deepseek-v3.2 as an example. You can change the model parameter as needed. For details, see Deep Thinking.
    messages=[
        {"role": "user", "content": "Hello"},
        {"role": "assistant", "content": "Hello! Nice to meet you!"},
        {"role": "user", "content": "Introduce yourself."}
    ],
    extra_body={
        "thinking": {
           "type": "enabled" # Enable deep thinking mode
        }
        
    }
)

print(response.choices[0].message.content)

JDK 15 or later is recommended.

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class ChatCompletionsExample {
    public static void main(String[] args) {
        // API URI
        String apiUrl = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions";
       // Replace MAAS_API_KEY with the obtained API key.
        String apiKey = "MAAS_API_KEY";
        // Replace it with the model you want to call, for example, "deepseek-v3.2".
        String modelName = "deepseek-v3.2";
        // Construct a request body.
        String requestBody = String.format(
                """
                        {
                            "model": "%s",
                            "messages": [
                                {"role": "system", "content": "You are a helpful assistant."},
                                {"role": "user", "content": "Hello"},
                                {"role": "assistant", "content": "Hello! Nice to meet you!"},
                                {"role": "user", "content": "Introduce yourself."}
                            ],
                            "thinking": {
                                 "type": "enabled"
                            }
                        }""", modelName);
        // Create an HttpClient.
        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();
        // Create a request.
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(apiUrl))
                .header("Content-Type", "application/json")
                .header("Authorization", "Bearer " + apiKey)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();
        try {
            // Send the request and print the result.
            HttpResponse<String> response = client.send(
                    request, HttpResponse.BodyHandlers.ofString());
            System.out.println("HTTP Status: " + response.statusCode());
            System.out.println("Response Body:\n" + response.body());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Streaming Output

With the LLM output, dynamic content is displayed as it is generated. This allows users to see intermediate outputs without waiting for the entire inference process to complete, improving the user experience by reducing perceived wait times (viewing content as it is produced).

The following is an example code for streaming output with deep thinking enabled. You can replace the model by modifying the model parameter. For details about the model parameter, see Text Generation.

curl -X POST "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MAAS_API_KEY" \
  -d '{
    "model": "deepseek-v3.2",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello"}
    ],
    "thinking": {
       "type": "enabled"
    },
     "stream": true
  }'
from openai import OpenAI
import httpx

base_url = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions"  # API address
api_key = "MAAS_API_KEY" # Replace MAAS_API_KEY with the obtained API key.

client = OpenAI(api_key=api_key, base_url=base_url, http_client=httpx.Client(verify=False))

response = client.chat.completions.create(
    model="deepseek-v3.2", # The following uses deepseek-v3.2 as an example. You can change the model parameter as needed. For details, see Deep Thinking.
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Hello"}
    ],
    stream = True,
    extra_body={
       "thinking": {
           "type": "enabled" # Enable deep thinking mode
        }
        
    }
)

for chunk in response:
    if not chunk.choices:
        continue
    print(chunk.choices[0].delta.content, end="")

JDK 15 or later is recommended.

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class ChatCompletionsExample3 {
    public static void main(String[] args) {
        // API URI
        String apiUrl = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions" ;
       // Replace MAAS_API_KEY with the obtained API key.
        String apiKey = "MAAS_API_KEY";
        // Replace it with the model you want to call, for example, "deepseek-v3.2".
        String modelName = "deepseek-v3.2";
        // Construct a request body.
        String requestBody = String.format(
                """
                        {
                            "model": "%s",
                            "messages": [
                                {"role": "system", "content": "You are a helpful assistant."},
                                {"role": "user", "content": "Hello"}
                            ],
                            "thinking": {
                                 "type": "enabled"
                            },
                            "stream": true
                        }""", modelName);
        // Create an HttpClient.
        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();
        // Create a request.
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(apiUrl))
                .header("Content-Type", "application/json")
                .header("Authorization", "Bearer " + apiKey)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();
        try {
            // Send the request and print the result.
            HttpResponse<String> response = client.send(
                    request, HttpResponse.BodyHandlers.ofString());
            System.out.println("HTTP Status: " + response.statusCode());
            System.out.println("Response Body:\n" + response.body());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Enabling/Disabling Deep Thinking

For details about the models that support enabling or disabling chain-of-thought and the usage instructions, see Chain of Thought Usage Guide.

The following example code demonstrates how to disable deep thinking by replacing the model parameter. For details about the model parameter, see Text Generation. For details about the CoT switch, see Table 1.

import requests
import json

if __name__ == '__main__':
    url = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions"  # API address
    api_key = "MAAS_API_KEY"  # Replace MAAS_API_KEY with the obtained API key.

    # Send request.
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {api_key}'
    }
    data = {
        "model": "qwen3-32b",  # The following uses qwen3-32b as an example. You can change the model parameter as needed. For details, see Deep Thinking.
        "messages": [
            {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello"}
        ],
        "thinking": {
            "type": "enabled" # Specifies whether to enable deep thinking. It is enabled by default.
        }
    }
    response = requests.post(url, headers=headers, data=json.dumps(data), verify=False)

    # Print result.
    print(response.status_code)
    print(response.text)
curl -X POST "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MAAS_API_KEY" \
  -d '{
    "model": "qwen3-32b",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello"}
    ],
     "thinking": {
       "type": "enabled"
     }
  }'

JDK 15 or later is recommended.

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class ChatCompletionsExample {
    public static void main(String[] args) {
        // API URI
        String apiUrl = "https://api-ap-southeast-1.modelarts-maas.com/v2/chat/completions" ;
       // Replace MAAS_API_KEY with the obtained API key.
        String apiKey = "MAAS_API_KEY";
        // Replace it with the model you want to call, for example, "qwen3-32b".
        String modelName = "qwen3-32b";
        // Construct a request body (compatible with OpenAI).
        String requestBody = String.format(
                """
                        {
                            "model": "%s",
                            "messages": [
                                {"role": "system", "content": "You are a helpful assistant."},
                                {"role": "user", "content": "Hello"}
                            ],
                            "thinking": {
                                 "type": "enabled"
                            }
                        }""", modelName);
        // Create an HttpClient.
        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();
        // Create a request.
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(apiUrl))
                .header("Content-Type", "application/json")
                .header("Authorization", "Bearer " + apiKey)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();
        try {
            // Send the request and print the result.
            HttpResponse<String> response = client.send(
                    request, HttpResponse.BodyHandlers.ofString());
            System.out.println("HTTP Status: " + response.statusCode());
            System.out.println("Response Body:\n" + response.body());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}