[GH-ISSUE #12180] Can't disable thinking on deepseek-r1 with openai sdk #33860

Closed
opened 2026-04-22 16:58:25 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @gvsolent on GitHub (Sep 4, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12180

Hello,

I need to disable reasoning on deepseek-r1.

I'd like to be able to do this using openai sdk. This would help to call various LLMs/providers in the same way.

I was able to disable reasoning using the post method, but not with open ai sdk.

Note that I use different endpoints for each. i don't know if that's the problem.

Could you help with that?

post methods :

import requests
import json

# URL de ton instance Ollama
OLLAMA_URL = "myurl/api/chat"

# Modèle (ex: deepseek-r1, qwen2.5:7b, etc.) deepseek-r1:70b
MODEL = "deepseek-r1:70b"

# Prompt simple
PROMPT = "how many r in the word strawberry?"

# Payload minimal avec paramètre "think"
payload = {
    "model": MODEL,
    "messages": [
        {"role": "user", "content": PROMPT}
    ],
    "think": False, 
    "stream": False
}

print("➡️ Payload envoyé :")
print(json.dumps(payload, indent=2))

# Appel HTTP POST
resp = requests.post(OLLAMA_URL, json=payload)

print("\n➡️ Status:", resp.status_code)
print("\n➡️ Réponse brute :")
print(resp.text)

try:
    data = resp.json()
    print("\n➡️ Contenu extrait :")
    print(json.dumps(data, indent=2))
except Exception as e:
    print("Erreur parsing JSON:", e)

With openai sdk

from openai import OpenAI
PROMPT = "how many r in the word strawberry?"
client = OpenAI(
    api_key="sk-xxxxxx",
    base_url="myurl/v1"
)

completion = client.chat.completions.create(
    model="deepseek-r1:70b",
    messages=[{"role": "user", "content": PROMPT}],
    temperature=0,
    max_tokens=2000,
    extra_body={"think": False}   # 👈 désactive le raisonnement
)

print(completion.choices[0].message)

Originally created by @gvsolent on GitHub (Sep 4, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12180 Hello, I need to disable reasoning on deepseek-r1. I'd like to be able to do this using openai sdk. This would help to call various LLMs/providers in the same way. I was able to disable reasoning using the post method, but not with open ai sdk. Note that I use different endpoints for each. i don't know if that's the problem. Could you help with that? post methods : ``` import requests import json # URL de ton instance Ollama OLLAMA_URL = "myurl/api/chat" # Modèle (ex: deepseek-r1, qwen2.5:7b, etc.) deepseek-r1:70b MODEL = "deepseek-r1:70b" # Prompt simple PROMPT = "how many r in the word strawberry?" # Payload minimal avec paramètre "think" payload = { "model": MODEL, "messages": [ {"role": "user", "content": PROMPT} ], "think": False, "stream": False } print("➡️ Payload envoyé :") print(json.dumps(payload, indent=2)) # Appel HTTP POST resp = requests.post(OLLAMA_URL, json=payload) print("\n➡️ Status:", resp.status_code) print("\n➡️ Réponse brute :") print(resp.text) try: data = resp.json() print("\n➡️ Contenu extrait :") print(json.dumps(data, indent=2)) except Exception as e: print("Erreur parsing JSON:", e) ``` With openai sdk ``` from openai import OpenAI PROMPT = "how many r in the word strawberry?" client = OpenAI( api_key="sk-xxxxxx", base_url="myurl/v1" ) completion = client.chat.completions.create( model="deepseek-r1:70b", messages=[{"role": "user", "content": PROMPT}], temperature=0, max_tokens=2000, extra_body={"think": False} # 👈 désactive le raisonnement ) print(completion.choices[0].message) ```
GiteaMirror added the feature request label 2026-04-22 16:58:25 -05:00
Author
Owner

@rick-github commented on GitHub (Sep 4, 2025):

#11012

<!-- gh-comment-id:3254057136 --> @rick-github commented on GitHub (Sep 4, 2025): #11012
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#33860