OpenAI rejects response_format json_schema for the model you chose
Invalid 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.
Fix it fast
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" .2Match what you see, then jump to its fix
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
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
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:
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- MenuloA restaurant discovery platform in Germany, kept current by a Python ingestion pipeline.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
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 fixAI
Azure OpenAI says the API deployment for this resource does not exist
The API deployment for this resource does not exist
Azure OpenAI does not take a model name in the model field.
2 causes, each with a fixAI
Azure OpenAI fails with an SSL certificate verification error
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED]
The client checks the endpoint's certificate against its CA bundle, which is certifi by default.
2 causes, each with a fixAI
The OpenAI client says the API key is missing
Missing credentials. Please pass an `api_key`
OpenAI() looks for an api_key argument first and then the OPENAI_API_KEY environment variable.
3 causes, each with a fixAI
OpenAI says the model is a chat model and not supported in the v1/completions endpoint
This is a chat model and not supported in the v1/completions endpoint
The v1/completions endpoint accepts completion models such as gpt-3.5-turbo-instruct.
3 causes, each with a fixAI
Old openai.ChatCompletion or openai.Embedding code breaks on a new SDK
APIRemovedInV1
The Python SDK was rewritten in version 1.0.
2 causes, each with a fix