跳到主要内容

深度思考

深度思考模型是具有复杂推理能力的 AI 系统,通过多步逻辑分析、自我反思和思维链推理,解决需要深度认知处理的问题。本文档介绍如何调用支持深度思考的模型,包括 GLM、Deepseek 和 Minimax。

GLM 模型 - 混合思考模式,默认开启思考:GLM-5.1、GLM-5、GLM-4.7

MiniMax 模型 - 仅思考模式:MiniMax-M2.5、MiniMax-M2.1

1. 在 curl 中使用深度思考​

curl --request POST \
--url https://api.jalapeno-cloud.ai/v1/chat/completions \
--header 'Authorization: Bearer ${API_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"model": "${MODEL_NAME}",
"messages": [{
"role": "user",
"content": "Who are you"
}],
"stream": true,
"stream_options":{"include_usage": true},
"chat_template_kwargs": {"thinking": true}
}'

2. 在 Python 中使用深度思考​

import requests

url = "https://api.jalapeno-cloud.ai/v1/chat/completions"

payload = {
"model": "${MODEL_NAME}",
"messages": [
{
"role": "user",
"content": "Please give a travel plan"
}
],
"stream": True,
"stream_options":{"include_usage": True},
"chat_template_kwargs": {"thinking": True}
}
headers = {
"Authorization": "Bearer ${API_KEY}",
"Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)

3. 在 JavaScript 中使用深度思考​

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer ${API_KEY}");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"messages": [
{
"role": "user",
"content": "Please give a travel plan"
}
],
"model": "${MODEL_NAME}",
"stream": true,
"chat_template_kwargs": {"thinking": true}
});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://api.jalapeno-cloud.ai/v1/chat/completions", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

4. 在 Golang 中使用深度思考​

package main

import (
"bytes"
"encoding/json"
"net/http"
)

func main() {
url := "https://api.jalapeno-cloud.ai/v1/chat/completions"
payload := map[string]interface{} {
"model": "${MODEL_NAME}",
"messages": []map[string]string{
{"role": "user", "content": "Please give a travel plan"},
},
"stream": true,
"chat_template_kwargs": {"thinking": true}
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer ${API_KEY}")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
}