Symptoms
- The error occurs before any model-specific response.
- A JSON validator reports a missing quote, comma, bracket, or invalid escape.
Likely causes
- Shell quoting changed the body or inserted an unescaped newline.
- The client sent a JavaScript object string, trailing comma, or deeply malformed structure.
How to diagnose
- Validate the exact body bytes with secrets removed.
- Confirm Content-Type is application/json.
- Replace the payload with one short user message and no optional parameters.
Fixes
- Use the SDK serializer or a JSON encoder instead of manual string concatenation.
- Correct quotes, commas, escapes, and brackets.
- Keep shell JSON in a file or a safely quoted heredoc when it becomes complex.
How to verify
The minimal JSON body parses and reaches model validation.