chatgpt-api: [Error] ChatGPTError: SyntaxError: Unexpected non-whitespace character after JSON at position 4
Verify latest release
- I verified that the issue exists in the latest
chatgptrelease
Verify webapp is working
- I verify that the ChatGPT webapp is working properly for this account.
Environment details
3.3.1
Describe the Bug
ChatGPTError: SyntaxError: Unexpected non-whitespace character after JSON at position 4 at ChatGPTAPIBrowser.sendMessage
Edited:
unexpected some date response.

Resolved:
add code to node_modules\chatgpt\build\index.js line 153 or wait for merge.
try {
const checkJson = JSON.parse(data);
} catch (error) {
console.log("warning: parse error.");
return;
}
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 7
- Comments: 24 (9 by maintainers)
This is definitely something new; looking into it…
Just released https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v3.3.12 with a potential fix from @czzonet 🔥
Please let me know if this resolves this bug. OpenAI definitely made some changes on their end, so at the very least, this
3.3.12should be slightly more robust against invalid JSON errors.@transitive-bullshit , haven’t even checked yet (will edit comment when I do) - just wanted to say thank you for all your effort on this fantastic little project. You (and the community) are so quick with fixes!