Integration Guides

Enable Thinking on an OpenAI-Compatible API (2026)

ROIBest AI

What "enable thinking" means on an OpenAI-compatible API

The query openai compatible api enable thinking is usually a client question, not a model-card question. You already have an endpoint that speaks POST /v1/chat/completions, and you want the model to produce a reasoning trace — or you want to turn that trace off because it is slow, expensive, or noisy in logs.

That is a different job from pointing a client at a compatible base URL. The contract, the /v1 path, and the usual client switch are covered in What Is an OpenAI-Compatible API?. This article stays on the thinking switch: which field actually turns it on, why the official OpenAI API does not use enable_thinking, and how to tell whether the server honored the flag.

"Thinking" here means the extra reasoning tokens a model generates before (or between) the visible answer. Compatible servers often expose that text in a separate field. Official OpenAI reasoning models also think, but they control it with a different parameter, and the reasoning tokens are not returned the same way.

Official OpenAI has no enable_thinking field

If your base_url is the official OpenAI API, do not send enable_thinking. It is not part of the Chat Completions schema.

OpenAI's Chat Completions reference documents reasoning_effort for reasoning models. Supported values are model-dependent and include none, minimal, low, medium, high, xhigh, and max. The default, when the field is accepted, is medium. Lower effort favors speed and fewer reasoning tokens; higher effort asks the model to think more completely. The reasoning guide also documents reasoning.effort on the Responses API — same idea, different request shape.

Some official models reject none (and sometimes minimal) with HTTP 400. Check the reasoning guide for the model you are calling rather than assuming every value works.

Reasoning tokens count toward the context window and are billed as output tokens. OpenAI reports them under usage details such as usage.completion_tokens_details.reasoning_tokens. That is the official verification signal: the effort parameter changed, and the reasoning token count moved with it.

from openai import OpenAI

client = OpenAI()  # official API; no compatible base_url

resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Which is larger, 9.11 or 9.8? Explain briefly."}],
    reasoning_effort="high",
)
print(resp.choices[0].message.content)
print(getattr(resp.usage, "completion_tokens_details", None))

The model ID in that example is only an illustration. Use a reasoning model your project actually has, and confirm the effort values that model accepts.

The compatible-server flag is enable_thinking

On many OpenAI-compatible servers, especially vLLM serving Qwen3-class models, thinking is toggled with chat_template_kwargs.enable_thinking. Qwen's own vLLM deployment notes are explicit: passing enable_thinking is not OpenAI API compatible, and the exact method differs among frameworks.

In the official OpenAI Python SDK, non-standard fields go in extra_body. The Qwen documentation's disable example looks like this:

from openai import OpenAI

client = OpenAI(
    api_key="EMPTY",
    base_url="http://localhost:8000/v1",
)

resp = client.chat.completions.create(
    model="Qwen/Qwen3-8B",
    messages=[
        {"role": "user", "content": "Give me a short introduction to large language models."},
    ],
    max_tokens=8192,
    extra_body={
        "chat_template_kwargs": {"enable_thinking": False},
    },
)
print(resp.choices[0].message.content)

The same payload works in curl, without the SDK wrapper:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen3-8B",
    "messages": [
      {"role": "user", "content": "Give me a short introduction to large language models."}
    ],
    "chat_template_kwargs": {"enable_thinking": true}
  }'

Two details matter immediately:

  1. A top-level "enable_thinking": true is not what these servers document. The flag sits inside chat_template_kwargs.
  2. Qwen3-class models often think by default. If you want a short, non-reasoning answer, you must send enable_thinking: false (or change the server default). Some other models do the opposite: vLLM's reasoning outputs guide notes that templates such as Gemma 4 require enable_thinking: true before reasoning tokens are generated at all.

vLLM can also set a server-wide default:

vllm serve Qwen/Qwen3-8B \
  --reasoning-parser qwen3 \
  --default-chat-template-kwargs '{"enable_thinking": false}'

Request-level chat_template_kwargs still win over that default.

Current vLLM documentation also describes an automatic bridge: if you send official-style reasoning_effort (low / medium / high), the server may inject enable_thinking: true; reasoning_effort: "none" injects false. If you set enable_thinking yourself, that explicit value takes priority. This is a server convenience, not a promise that every compatible endpoint implements the same mapping.

How to tell whether thinking actually ran

Sending the flag is not the same as seeing a reasoning trace.

On vLLM, extracted thinking usually requires starting the server with --reasoning-parser (for Qwen3, --reasoning-parser qwen3). The reasoning outputs guide then reads the trace from the message object — current docs show message.reasoning. Some servers and older clients expose reasoning_content instead. Inspect the message rather than assuming a single field name.

msg = resp.choices[0].message
reasoning = getattr(msg, "reasoning", None) or getattr(msg, "reasoning_content", None)
print("reasoning:", reasoning)
print("content:", msg.content)

Use a prompt that should produce a short chain of thought when thinking is on, such as a comparison or a multi-step calculation. Then send the same prompt with thinking disabled.

A working toggle looks like this:

  • On: a non-empty reasoning field (or reasoning tags inside content if the server does not parse them), and a longer completion.
  • Off: empty or missing reasoning, and a direct answer.

If both requests look identical, the flag never reached the chat template, the model ignores that kwarg, or you are not calling the server you think you are. The last case is often a base URL problem — a doubled /v1, or a client that still points at api.openai.com.

The usual reasons the flag appears to do nothing

Most "I enabled thinking and nothing changed" reports collapse into one of these:

  1. The field was sent in the wrong place. Official OpenAI wants reasoning_effort or reasoning.effort. vLLM/Qwen want chat_template_kwargs.enable_thinking, typically via extra_body in the SDK. A raw enable_thinking at the top level is easy to write and easy for a strict server to ignore or reject.
  2. You are on the official API. A compatible-looking client can still use the default OpenAI base URL. The official API will not honor enable_thinking.
  3. The reasoning parser is off. The model may still be thinking, but the text is mixed into content, wrapped in model-specific tags, or discarded before it reaches your client. Start the server with the parser that matches the model, then read the reasoning field.
  4. The model template does not declare enable_thinking. vLLM notes that injected kwargs are filtered out when the template does not accept them. A DeepSeek R1-style model may need a different parser and a different switch than Qwen3.
  5. The vendor uses another dialect. Some APIs document a thinking object such as { "type": "enabled" } instead of enable_thinking. The compatibility issues article is the right background here: optional fields are the part of "compatible" that is not guaranteed. Use the parameter the server you are calling actually publishes.
  6. Silent ignore. Some compatible endpoints accept unknown fields and drop them. That is more confusing than a 400. If a toggle request returns 200 and the output does not change, log the exact JSON you sent and compare it with that server's docs, not with OpenAI's schema.

Local apps that advertise an OpenAI-compatible server (LM Studio is a common example in search suggestions) have the same rule: the product may have a UI toggle and a request-level flag. Use the names in that product's documentation. Do not copy enable_thinking into a server that never documented it.

Which control to send

You are calling

Control that actually matters

Official OpenAI Chat Completions

reasoning_effort

Official OpenAI Responses API

reasoning.effort

vLLM / Qwen3-style compatible server

chat_template_kwargs.enable_thinking (often via extra_body)

A vendor that documents a thinking object

The object in that vendor's docs, not a guessed enable_thinking flag

The first two rows are the official contract. The last two are extensions. Mixing them is the usual failure.

FAQ

Is enable_thinking an official OpenAI API parameter?

No. Official Chat Completions uses reasoning_effort. The Responses API uses reasoning.effort. enable_thinking is a vendor extension used by some OpenAI-compatible servers, notably vLLM serving models whose chat template defines that kwarg.

How do I enable thinking on an OpenAI-compatible API with the Python SDK?

Point the official OpenAI client at the compatible base_url, then pass the server's flag in extra_body. For Qwen3 on vLLM, that is extra_body={"chat_template_kwargs": {"enable_thinking": True}}. Confirm the model ID with GET /v1/models first.

How do I disable thinking on Qwen3 via a compatible endpoint?

Send chat_template_kwargs.enable_thinking as false, or start vLLM with --default-chat-template-kwargs '{"enable_thinking": false}'. Qwen also documents a non-thinking chat template if you need a hard off switch that ignores /think-style prompts.

Why is message.reasoning empty even though I turned thinking on?

The server may not be parsing reasoning, the field may be named reasoning_content, the template may have ignored the kwarg, or thinking text may still be sitting inside content. Check the parser flag, dump the raw message, and compare on versus off with the same prompt.

Can I use the same flag when I switch back to OpenAI's official API?

No. Drop enable_thinking and set reasoning_effort (or reasoning.effort on Responses). A field that works on a local vLLM server is not part of the official schema, which is exactly the kind of gap described in OpenAI compatibility issues.

Set the flag the server documents, then verify it

An OpenAI-compatible API lets you reuse a client. It does not mean every thinking control is portable. On the official API, use reasoning_effort or reasoning.effort and check reasoning token usage. On vLLM and Qwen-style servers, send chat_template_kwargs.enable_thinking, enable a reasoning parser if you need a separate trace, and confirm the output changed. If the toggle does nothing, fix the field path, the base URL, or the dialect before you assume the model cannot think.