All guides

Answer with DeepSeek thinking mode and check the reasoning field

Make one thinking-mode request per the official notes, read reasoning_content and content separately, check the answer against your own standard, and know which parameters have no effect.

AINavWritten / Updated Sources checked
On this page

At a glance

DeepSeek's thinking mode outputs a chain of thought before the final answer. Through the API, that text arrives in reasoning_content, at the same level as the final answer in content. This guide covers one complete task: send a single request with thinking enabled, read both fields separately, compare the answer with a standard you wrote beforehand, and decide whether to continue. The sample question comes from the official example. The checking standard is an editorial addition, and no real user data is involved.

Workflow

  1. Is thinking mode on as intended?

    The docs say thinking mode is enabled by default with a default effort of high. With the OpenAI SDK, the thinking parameter must be passed inside extra_body.

  2. Are the two fields read separately?

    reasoning_content is the chain of thought and content is the final answer, at the same level. Extract each one first, then decide which to use for checking.

  3. Do parameters and answer line up?

    temperature, presence_penalty and frequency_penalty have no effect in thinking mode and raise no error. Compare the final answer with your pre-written standard.

Each stage cites official sources.

Before you start

  • A Python environment that can call the DeepSeek API using the openai library and base_url https://api.deepseek.com. Keep the key in a local environment variable, not in prompts, repositories or logs.
  • A short question with an unambiguous answer, plus the answer you believe is correct, written down before you send the request, to serve as your checking standard.

1. Create the client

In your Python script, build client with OpenAI(api_key=..., base_url="https://api.deepseek.com"), reading api_key from an environment variable. This happens only in your own local script, and the key never needs to be pasted into any page.

2. Write the question and the standard

Put a single user message in messages, using the official sample question "9.11 and 9.8, which is greater?". In a script comment, record your standard: the greater number should be 9.8. Writing the standard before reading any output keeps the model's wording from steering you.

3. Set the thinking parameters explicitly

Call client.chat.completions.create with model (the official sample uses deepseek-flash; follow your current documentation), messages, reasoning_effort="high", and extra_body={"thinking": {"type": "enabled"}}. Thinking is already on by default, but writing it out shows anyone reading the script what this run used. Effort can be low, high or max.

4. Read the two fields separately

From response.choices[0].message take reasoning_content and content into two different variables. If you keep logs, record them as separate fields and confirm neither contains a key or personal information.

5. Check the final answer against the standard

Compare content with the predefined standard that 9.8 is greater than 9.11 to check correctness. reasoning_content is supporting diagnostic text. If it visibly contradicts the final answer, follow step 7; reasoning text does not prove correctness.

6. Remove parameters that do nothing

Look for temperature, presence_penalty or frequency_penalty in the request. The docs say they have no effect in thinking mode and do not trigger an error, so the absence of an error does not mean they are working. Delete them so you do not think you are tuning the output.

7. Decide whether to stop

If the answer matches the standard and the reasoning has no contradiction, stop calling. If not, rephrase the question or raise the effort and resend, with a cap of your own such as two attempts. If it still disagrees, keep the record and hand it to a person instead of repeating requests.

Original example

Invented mini task: confirm the model compares two decimals correctly. Checking standard (written before the request): 9.8 is greater than 9.11. Request outline: response = client.chat.completions.create( model="deepseek-flash", messages=[{"role": "user", "content": "9.11 and 9.8, which is greater?"}], reasoning_effort="high", extra_body={"thinking": {"type": "enabled"}}, ) msg = response.choices[0].message reasoning = msg.reasoning_content answer = msg.content How to check (a checking idea, not recorded output): 1. Does answer clearly say 9.8 is greater? 2. Does the comparison inside reasoning reach the same conclusion? 3. If answer disagrees with the standard or contradicts reasoning, mark the attempt failed and handle it under the cap in step 7. When finished there is no need to append more messages; simply end the script. Complete the task only if the final answer matches the predefined standard and no obvious contradiction between reasoning and answer is found. A wrong answer or visible contradiction goes to the limited retry or manual-check procedure in step 7.

Completion checks

  • thinking is passed inside extra_body, not as an ordinary keyword argument of create.
  • reasoning_content and content are read separately and not merged into one string.
  • The checking standard was written before the output was viewed.
  • No temperature, presence_penalty or frequency_penalty remains in the request, and you are not treating them as working controls.
  • The retry count has a cap, and logs hold no key or real personal information.
  • Complete the task only if the final answer matches the predefined standard and no obvious contradiction between reasoning and answer is found. A wrong answer or visible contradiction goes to the limited retry or manual-check procedure in step 7.

Limits

  • The official material says thinking mode aims to improve the accuracy of the final response. It does not promise every answer is correct, so you must check it yourself.
  • reasoning_content is text for inspection. This guide does not treat it as proof that the answer is right, and says nothing about how stable its wording is.
  • If a request carries the tools parameter, the reasoning_content of all earlier turns must be passed back to the API or it returns a 400 error. That belongs to tool-call workflows, and this guide covers one plain question only.
  • In streaming, the chain of thought and the answer arrive in different delta fields. Streaming code is not demonstrated here, and concatenating multi-turn messages is outside this guide.

Verification scope

Only the official DeepSeek thinking mode documentation was read. Login, installation, product API execution, file upload and generated output were not tested; the code and checking standard are original illustrative samples, not real run output.

Article sources

Original editorial content; official descriptions and checking suggestions are distinguished.

  1. DeepSeek · Official sources
    View details