Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
AI and LLM integration

OpenAI rejects response_format json_schema for the model you chose

ErrorInvalid parameter: 'response_format' of type 'json_schema' is not supported with model version `gpt-4-turbo`

Short answer

Structured Outputs (json_schema) works only with newer model snapshots, starting with gpt-4o-2024-08-06 and gpt-4o-mini. Older models like gpt-4-turbo cannot take it. Switch to a supported model, or fall back to JSON mode on the older one. In the Responses API the setting lives under text.format.

  • Applies to OpenAI API, openai Python SDK 1.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the model name in your request, then compare it with the list of snapshots that support Structured Outputs in the OpenAI guide.

    grep -rn "gpt-4-turbo\|response_format" .
  2. 2Match what you see, then jump to its fix

    1. 1The error names the model, for example gpt-4-turbo.The model is too old for Structured OutputsFix
    2. 2You call client.responses.create and pass response_format.response_format used with the Responses APIFix

What does the error look like?

  • Invalid parameter: 'response_format' of type 'json_schema' is not supported with model version `gpt-4-turbo`

Cause 1 of 2

The model is too old for Structured Outputs

1Check

The guide says json_schema in response_format is only supported with gpt-4o-mini, gpt-4o-mini-2024-07-18, gpt-4o-2024-08-06 and later snapshots.

grep -rn "model=" .

2Fix

Use a supported model. If you must stay on an older one, use JSON mode (json_object); it guarantees valid JSON but not your schema, so validate the result yourself.

# supported model
model="gpt-4o-mini"
# or older model with JSON mode
response_format={"type": "json_object"}

3Verify

Repeat the request. The call succeeds and the output parses.

import json; json.loads(response.choices[0].message.content)

Confirmed by developers.openai.com

Did this fix it?

Cause 2 of 2

response_format used with the Responses API

1Check

The guide shows the Responses API form as text.format, not response_format.

grep -rn "responses.create" .

2Fix

Move the schema into text.format with type json_schema and strict true.

text={"format": {"type": "json_schema", "strict": True, "schema": my_schema}}

3Verify

The request is accepted. Check the output for a refusal or an incomplete status before parsing.

print(response.status)

Confirmed by developers.openai.com

Did this fix it?

How do I stop it coming back?

  • Pin the model name in one setting, so a downgrade is visible.
  • Always validate parsed output, even with JSON mode.
  • Handle refusals and incomplete output, which the schema does not cover.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

AI

The model's reply breaks JSON.parse

SyntaxError: Unterminated string in JSON at position 1874

JSON.parse rejects model output for a few repeatable reasons: the JSON sits inside markdown fences or next to a sentence, the reply stopped at the token limit mid-object, a stream was parsed before it ended, or the model refused.

5 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.