Reasoning
Control how reasoning-capable models think before answering, read the reasoning content, and budget its cost and latency.
Some models on Blackfuel produce reasoning content before their final answer — an intermediate thinking pass the model uses on math, code, multi-step logic, and tool planning. You control it with the reasoning_effort request parameter, and the model returns its thinking in a reasoning field alongside the final answer in content.
reasoning_effort is the OpenAI-compatible control, so OpenAI clients send it unchanged. The Chat Completions body parameters list the levels Blackfuel accepts; each model declares the subset it takes.
Which Models Support Reasoning
A model is reasoning-capable when GET /v1/models lists reasoning_effort in its supported_parameters. Models Blackfuel hosts also carry a reasoning object whose supported_efforts array is the set of reasoning_effort values that model accepts.
List the reasoning models available to your key:
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.blackfuel.ai/v1", api_key=os.environ["BLACKFUEL_API_KEY"])
for model in client.models.list().data:
# both fields are extensions, so the SDK keeps them in model_extra
extra = model.model_extra or {}
if "reasoning_effort" not in (extra.get("supported_parameters") or []):
continue
reasoning = extra.get("reasoning")
print(model.id, reasoning["supported_efforts"] if reasoning else "efforts not declared")import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.blackfuel.ai/v1",
apiKey: process.env.BLACKFUEL_API_KEY,
});
const models = await client.models.list();
for (const model of models.data) {
if (!model.supported_parameters?.includes("reasoning_effort")) continue;
console.log(model.id, model.reasoning?.supported_efforts ?? "efforts not declared");
}curl -s https://api.blackfuel.ai/v1/models \
-H "Authorization: Bearer $BLACKFUEL_API_KEY" \
| jq '.data[] | select(.supported_parameters | index("reasoning_effort")) | {id, efforts: .reasoning.supported_efforts}'Read that list per request path — it changes as the catalog evolves:
| Question | Read |
|---|---|
| Does this model reason at all? | supported_parameters contains reasoning_effort |
| How much depth can I ask for? | The graded levels in supported_efforts |
| Can I switch reasoning off? | none is present in supported_efforts — see Turning Reasoning Off |
Enable Reasoning
Send reasoning_effort with a value from that model's supported_efforts:
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.blackfuel.ai/v1", api_key=os.environ["BLACKFUEL_API_KEY"])
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Flash-0731",
messages=[{"role": "user", "content": "Plan a 3-step search strategy."}],
reasoning_effort="high",
max_tokens=4096,
)
msg = response.choices[0].message
print(msg.reasoning) # the thinking pass
print(msg.content) # the final answerimport OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.blackfuel.ai/v1",
apiKey: process.env.BLACKFUEL_API_KEY,
});
const response = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Flash-0731",
messages: [{ role: "user", content: "Plan a 3-step search strategy." }],
reasoning_effort: "high",
max_tokens: 4096,
});
const msg = response.choices[0].message;
console.log(msg.reasoning); // the thinking pass
console.log(msg.content); // the final answercurl -s https://api.blackfuel.ai/v1/chat/completions \
-H "Authorization: Bearer $BLACKFUEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-ai/DeepSeek-V4-Flash-0731",
"messages": [{"role": "user", "content": "Plan a 3-step search strategy."}],
"reasoning_effort": "high",
"max_tokens": 4096
}'Choosing an Effort
Two rules cover every reasoning model:
- Send
reasoning_efforton every request. Without it, a reasoning-capable model decides for itself whether to think and how deeply. Sending the level puts that decision in your hands. - Send a supported effort. Use a value from that model's
supported_efforts.
Each step up the scale spends more output tokens and more wall-clock time before the answer arrives. Start at the lowest level that passes your evaluations and raise it only where accuracy demands it.
Turning Reasoning Off
When none is present in a model's supported_efforts, sending reasoning_effort: "none" skips the reasoning pass: reasoning comes back null, and the answer arrives in content as usual.
Hiding reasoning from your users is separate from generating it. Reasoning arrives in its own field precisely so you can withhold it: render message.content and drop message.reasoning in your presentation layer, on any model.
Reading the Reasoning Content
A reasoning response splits its output across two fields of the message:
{
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"reasoning": "The user wants a search strategy. Three steps means...",
"content": "1. Define the query scope...\n2. ...\n3. ..."
},
"finish_reason": "stop"
}
]
}| Field | Type | Contains |
|---|---|---|
message.reasoning | string | null | The model's thinking, planning, and scratch work. May be long. |
message.content | string | The final answer produced after thinking. This is what you show to end users. |
On a non-streaming response, message.reasoning is present whether or not the model reasoned: it holds null when the request ran no reasoning pass — a non-reasoning model, or reasoning_effort="none" — and the answer is in content as usual. A truthiness check covers both cases. Streaming deltas carry the field only on chunks that hold reasoning.
SDK Access Patterns
Reasoning content extends the standard OpenAI Chat Completions schema, so client libraries surface it differently:
| Client | How to read it |
|---|---|
| OpenAI Python SDK | message.reasoning works at runtime, as the samples on this page use it. The SDK's response type does not declare the field, so a type checker follows it through message.model_extra instead. |
| OpenAI JS SDK | The field is present at runtime but absent from the SDK's TypeScript types, so read it with a cast (for example (message as any).reasoning). |
| LiteLLM | message.reasoning_content — LiteLLM renames the field when normalising reasoning across providers. |
| LangChain / LangGraph | ChatOpenAI drops extension fields — as of langchain-openai 1.4.1, reasoning reaches neither content, additional_kwargs, nor response_metadata. Call the model with the OpenAI client where you need it. |
Streaming Reasoning Content
Streaming chunks carry delta.reasoning and delta.content independently. Reasoning content streams first, then the final answer; a chunk may carry both if the model transitions mid-chunk.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.blackfuel.ai/v1", api_key=os.environ["BLACKFUEL_API_KEY"])
stream = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Flash-0731",
messages=[{"role": "user", "content": "Prove that sqrt(2) is irrational."}],
reasoning_effort="high",
max_tokens=4096,
stream=True,
)
for chunk in stream:
# The stream ends with a usage chunk whose choices array is empty
if not chunk.choices:
continue
delta = chunk.choices[0].delta
# content-only chunks carry no reasoning attribute at all
reasoning = getattr(delta, "reasoning", None)
if reasoning:
print(reasoning, end="", flush=True) # show thinking inline if you want
if delta.content:
print(delta.content, end="", flush=True)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.blackfuel.ai/v1",
apiKey: process.env.BLACKFUEL_API_KEY,
});
const stream = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Flash-0731",
messages: [{ role: "user", content: "Prove that sqrt(2) is irrational." }],
reasoning_effort: "high",
max_tokens: 4096,
stream: true,
});
for await (const chunk of stream) {
const delta = chunk.choices[0]?.delta; // empty on the terminal usage chunk
if (!delta) continue;
if (delta.reasoning) process.stdout.write(delta.reasoning); // show thinking inline if you want
if (delta.content) process.stdout.write(delta.content);
}The Streaming reference documents the terminal usage chunk and the response timeout.
Cost, Latency, and Token Budgets
Reasoning tokens are real generated tokens: they are counted in usage.completion_tokens and billed at the model's output-token rate, listed in Available Models. Raising reasoning_effort raises both the token count and the time to the first character of the answer.
max_tokens caps total generated tokens — reasoning plus the final answer.
When reasoning consumes the whole max_tokens budget, the request returns finish_reason: "length" with an empty content. Give thinking workloads room: reasoning content plus a concise answer runs to several thousand tokens, so the samples on this page set max_tokens to 4096. Size yours against the model's context window.
The usage object counts reasoning content and the final answer together:
| Field | Counts |
|---|---|
usage.prompt_tokens | Tokens in the input. |
usage.completion_tokens | Every token the model generated — reasoning content and final answer. |
usage.total_tokens | prompt_tokens plus completion_tokens. |
Reasoning tokens are counted inside completion_tokens. To size the reasoning cost of a workload, compare completion_tokens across efforts on the same prompt.
A high max_tokens on a non-streaming request is the common way to hit the response timeout — stream it, cap it, or both. See Streaming.
Reasoning with Tool Calling
A model that supports both reasoning and tool calling can think through which tool to invoke before emitting tool_calls. Pass reasoning_effort and tools together in the same request. Confirm the model lists both reasoning_effort and tools in supported_parameters first.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.blackfuel.ai/v1", api_key=os.environ["BLACKFUEL_API_KEY"])
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Flash-0731",
messages=[
{"role": "system", "content": "You are an agent. Use tools when helpful."},
{"role": "user", "content": "What's the weather in Paris and Tokyo right now?"},
],
reasoning_effort="high",
max_tokens=4096,
tools=[
{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}
],
)
msg = response.choices[0].message
print(msg.reasoning)
print(msg.tool_calls) # the tools it decided to invoke
print(msg.content) # usually None when tool_calls is presentimport OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.blackfuel.ai/v1",
apiKey: process.env.BLACKFUEL_API_KEY,
});
const response = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Flash-0731",
messages: [
{ role: "system", content: "You are an agent. Use tools when helpful." },
{ role: "user", content: "What's the weather in Paris and Tokyo right now?" },
],
reasoning_effort: "high",
max_tokens: 4096,
tools: [{
type: "function",
function: {
name: "get_weather",
parameters: {
type: "object",
properties: { city: { type: "string" } },
required: ["city"],
},
},
}],
});
const msg = response.choices[0].message;
console.log(msg.reasoning); // the model's reasoning content
console.log(msg.tool_calls); // the tools it decided to invoke
console.log(msg.content); // usually null when tool_calls is presentWhen you feed the tool's output back on the next turn, append the assistant message with its tool_calls and the matching tool result messages, and drop the earlier reasoning — see Pitfalls.
Reasoning with Structured Output
A reasoning model can also constrain its final answer to a JSON schema. Pass reasoning_effort and response_format together: the model reasons first, then produces a content that conforms to the schema. Only content is constrained; reasoning stays free-form in its own field.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.blackfuel.ai/v1", api_key=os.environ["BLACKFUEL_API_KEY"])
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Flash-0731",
messages=[{"role": "user", "content": "Extract the address: Ada Lovelace, 12 Analytical Ave, London, UK."}],
reasoning_effort="high",
max_tokens=4096,
response_format={
"type": "json_schema",
"json_schema": {
"name": "postal_address",
"strict": True,
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"street": {"type": "string"},
"city": {"type": "string"},
"country": {"type": "string"},
},
"required": ["name", "street", "city", "country"],
"additionalProperties": False,
},
},
},
)
msg = response.choices[0].message
print(msg.reasoning)
print(msg.content) # JSON conforming to the schemaimport OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.blackfuel.ai/v1",
apiKey: process.env.BLACKFUEL_API_KEY,
});
const response = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Flash-0731",
messages: [{ role: "user", content: "Extract the address: Ada Lovelace, 12 Analytical Ave, London, UK." }],
reasoning_effort: "high",
max_tokens: 4096,
response_format: {
type: "json_schema",
json_schema: {
name: "postal_address",
strict: true,
schema: {
type: "object",
properties: {
name: { type: "string" },
street: { type: "string" },
city: { type: "string" },
country: { type: "string" },
},
required: ["name", "street", "city", "country"],
additionalProperties: false,
},
},
},
});
const msg = response.choices[0].message;
console.log(msg.reasoning); // the model's reasoning content (free-form)
console.log(msg.content); // JSON conforming to the schemaresponse_format also accepts {"type": "json_object"} for JSON mode without a schema.
Pitfalls
Don't send reasoning back as input. On multi-turn conversations, append only message.content from earlier assistant turns and drop their reasoning. Prior reasoning is not meant to be replayed: some models ignore it and some reject the request outright, so re-sending it can degrade quality or fail the call.
Treat reasoning content as a debugging aid and a UX affordance. It reflects what the model emitted under its reasoning template, which is a different thing from an account of how the model reached its answer.
See Also
- Chat Completions: the
reasoning_effortparameter definition and the request and response shape. - Models: the
GET /v1/modelsresponse, includingsupported_parametersand thereasoningobject. - Streaming: the terminal usage chunk and the response timeout contract.
- Error Handling: retries, 429 backoff, and error response shapes.
- Available Models: the current catalog with per-token pricing.