What does 400 invalid_json mean?
The body couldn't be read as JSON, so the API never got as far as looking at your fields.
Code: invalid_json · HTTP status: 400
The Model API expects a JSON body with Content-Type: application/json.
Common causes#
- a trailing comma or a missing quote
- shell quoting that broke the body in a cURL command (single quotes inside a single-quoted
-d) - sending form data or plain text instead of JSON
- an empty body
How to fix it#
- Validate the body with a JSON tool (
python -m json.tool body.jsonorjq . body.json). - In cURL, put the body in a file and send it with
-d @body.json. - Set
Content-Type: application/json. - With an OpenAI SDK this error almost never happens; if it does, check any custom
extra_bodyyou pass.
Should my code retry?#
Not retryable as is: fix the body first.
The error body uses the OpenAI shape, so OpenAI SDKs raise it as an exception you can catch:
{"error": {"message": "...", "type": "...", "code": "invalid_json", "param": null}}
Every response also carries an X-Request-Id. Keep it in your logs; it's the quickest way for support to find a request.
See the full list in the Model API reference.
Still need help?#
- General support: support@clatterlabs.com or team@clatterlabs.xyz
- Infrastructure questions, or permanent deletion of your data (your whole account or one service): infrastructure@clatterlabs.xyz
We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Related articles
Still need help?
Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyzFor deleting your whole account or the data of one service.