I was able to figure out a way to work with gpt-5-nano. @_j was correct about this:
Increase
max_output_tokensto larger than the model would ever produce in reasoning + output, considering your requested reasoning effort and maximum task difficulty.
I was getting empty responses with:
const stream = await openai.chat.completions.create({
messages: [
{ role: "system", content: "You are an amazing JavaScript developer. When I send a codeblock of JavaScript, you will return a more reusable and better written version of the code." },
{ role: "user", content: "function add(x, y) { var z = x + y; console.log(z); } add(3, 4);" },
],
model: "gpt-5-nano",
stream: true,
max_completion_tokens: 1000,
});
Setting reasoning_effort to minimal helped:
const stream = await openai.chat.completions.create({
messages: [
{ role: "system", content: "You are an amazing JavaScript developer. When I send a codeblock of JavaScript, you will return a more reusable and better written version of the code." },
{ role: "user", content: "function add(x, y) { var z = x + y; console.log(z); } add(3, 4);" },
],
model: "gpt-5-nano",
stream: true,
max_completion_tokens: 1000,
reasoning_effort: "minimal"
});
I was able to find reasoning_effort through:
Constrains effort on reasoning for reasoning models Currently supported values are
minimal,low,medium, andhigh. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
Note: Thegpt-5-promodel defaults to (and only supports)highreasoning effort.
The
minimalsetting performs especially well in coding and instruction following scenarios, adhering closely to given directions.https://platform.openai.com/docs/guides/latest-model#minimal-reasoning-effort
Hope this helps!