Clatter LabsHelp Center

What does 400 invalid_json mean?

TroubleshootingUpdated

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#

  1. Validate the body with a JSON tool (python -m json.tool body.json or jq . body.json).
  2. In cURL, put the body in a file and send it with -d @body.json.
  3. Set Content-Type: application/json.
  4. With an OpenAI SDK this error almost never happens; if it does, check any custom extra_body you 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?#

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.xyz
For deleting your whole account or the data of one service.