ollama - ✅(Solved) Fix /v1/chat/completions not support think:true [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15029Fetched 2026-04-08 01:21:49
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
commented ×2closed ×1cross-referenced ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #15036: fix: forward think:true to deepseek-r1 via /v1/chat/completions

Description (problem / solution / changelog)

Description

When a client sends think:true (boolean) via /v1/chat/completions, the value was silently ignored because ChatCompletionRequest had no field to capture it and toApiChatRequest only handled reasoning_effort (string effort values). This breaks deepseek-r1 which requires think=true to produce output.

Root Cause

In openai/openai.go, the ChatCompletionRequest struct lacked a Think *bool field, and the toApiChatRequest function only processed reasoning (effort string). The think parameter from the OpenAI API was being dropped.

Fix

  1. Added Think *bool json:"think,omitempty"field toChatCompletionRequest`
  2. Updated toApiChatRequest to forward the boolean think value to the internal api.ChatRequest when present, before falling back to the reasoning_effort logic

This mirrors how the native Ollama API handles think as a boolean (see api.ChatRequest and api.ThinkValue).

Testing

  • think:true is now forwarded to deepseek-r1 via the /v1/chat/completions endpoint
  • Existing reasoning_effort logic is preserved as a fallback

Fixes ollama/ollama#15029

Changed files

  • openai/openai.go (modified, +18/-13)
RAW_BUFFERClick to expand / collapse

What is the issue?

When invoking the deepseek-r1 model via the /v1/chat/completions endpoint, enabling the "think" feature is not possible. In the ollama source code, it is explicitly defined that "think" cannot be set to true, whereas the deepseek-r1 model exclusively supports "think=true". The relevant ollama source code is as follows: var think *api.ThinkValue var effort string

if r.Reasoning != nil {
	effort = r.Reasoning.Effort
} else if r.ReasoningEffort != nil {
	effort = *r.ReasoningEffort
}

if effort != "" {
	if !slices.Contains([]string{"high", "medium", "low", "none"}, effort) {
		return nil, fmt.Errorf("invalid reasoning value: '%s' (must be \"high\", \"medium\", \"low\", or \"none\")", effort)
	}

	if effort == "none" {
		think = &api.ThinkValue{Value: false}
	} else {
		think = &api.ThinkValue{Value: effort}
	}
}

return &api.ChatRequest{
	Model:           r.Model,
	Messages:        messages,
	Format:          format,
	Options:         options,
	Stream:          &r.Stream,
	Tools:           r.Tools,
	Think:           think,
	Logprobs:        r.Logprobs != nil && *r.Logprobs,
	TopLogprobs:     r.TopLogprobs,
	DebugRenderOnly: r.DebugRenderOnly,
}, nil

Relevant log output

OS

No response

GPU

No response

CPU

No response

Ollama version

No response

extent analysis

Fix Plan

To enable the "think" feature for the deepseek-r1 model, we need to modify the ollama source code to allow "think" to be set to true.

Here are the steps:

  • Modify the effort check to include a special case for "think=true" when using the deepseek-r1 model.
  • Update the think assignment to handle this new case.

Code Changes

if r.Model == "deepseek-r1" {
    think = &api.ThinkValue{Value: true}
} else {
    // existing logic for other models
    if effort != "" {
        if !slices.Contains([]string{"high", "medium", "low", "none"}, effort) {
            return nil, fmt.Errorf("invalid reasoning value: '%s' (must be \"high\", \"medium\", \"low\", or \"none\")", effort)
        }

        if effort == "none" {
            think = &api.ThinkValue{Value: false}
        } else {
            think = &api.ThinkValue{Value: effort}
        }
    }
}

Verification

To verify the fix, invoke the /v1/chat/completions endpoint with the deepseek-r1 model and "think=true". The response should indicate that the "think" feature is enabled.

Extra Tips

  • Make sure to test the updated code with different models and "think" values to ensure the fix does not introduce any regressions.
  • Consider adding a configuration option to allow users to specify whether the "think" feature should be enabled for specific models.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING