OpenAI Chat Model Error - Bad request - please check your parameters

Describe the problem/error/question

Running a workflow in live triggered by a WebHook provides an error, when I execute a test it works fine, but automations after live breaks.

What is the error message (if any)?

{
“errorMessage”: “Bad request - please check your parameters”,
“errorDescription”: “We could not parse the JSON body of your request. (HINT: This likely means you aren’t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)”,
“errorDetails”: {},
“n8nDetails”: {
“time”: “2/5/2025, 10:09:57 AM”,
“n8nVersion”: “1.76.2 (Self Hosted)”,
“binaryDataMode”: “default”,
“cause”: {
“status”: 400,
“headers”: {
“alt-svc”: “h3=”:443"; ma=86400",
“cf-cache-status”: “DYNAMIC”,
“cf-ray”: “90d482d6a9f4ebed-SJC”,
“connection”: “keep-alive”,
“content-length”: “443”,
“content-type”: “application/json; charset=utf-8”,
“date”: “Wed, 05 Feb 2025 17:09:57 GMT”,
“server”: “cloudflare”,
“set-cookie”: “__cf_bm=JGfwy1fwj2WtUw8kFKT_91UY27XiWd05EQT4J6TEhVs-1738775397-1.0.1.1-Ds28tL59SaY4Yg3bvJ.SPYVt2aOVCofRlL4avtuI.oPlWrcAbdKg77kf2TfTyTlhFybbmM6oV4XibiuFVY.uOw; path=/; expires=Wed, 05-Feb-25 17:39:57 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=knWkElZNHUao4JW_pZo_uM3aBpXmlcZ8dU7_0nky5Jk-1738775397017-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None”,
“strict-transport-security”: “max-age=31536000; includeSubDomains; preload”,
“vary”: “Origin”,
“x-content-type-options”: “nosniff”,
“x-request-id”: “req_0e94df1c9b6a8afa43d98799f22efada”
},
“request_id”: “req_0e94df1c9b6a8afa43d98799f22efada”,
“error”: {
“message”: “We could not parse the JSON body of your request. (HINT: This likely means you aren’t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
},
“code”: null,
“param”: null,
“type”: “invalid_request_error”,
“attemptNumber”: 1,
“retriesLeft”: 2
}
}
}

Please share your workflow/screenshots/recording

Image

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
⚠️ WARNING ⚠️ If you have sensitive data in your workflow (like API keys), please remove it before sharing.

{
“nodes”: [
{
“parameters”: {
“promptType”: “define”,
“text”: “=Name of the Book: {{ $json[‘Idea (from Book)’][0] }}\nThe research data you need for the book: {{ $json[‘Research (from Book)’][0] }}\n\n=== CHAPTER ====\nName of the chapter: {{ $json[‘Chapter Name’] }}\n\nResearch about the chapter: {{ $json.Research }}\n\n========= PERFECT NOW WRITE THE CONTENT FOR THE CHAPTER\n”,
“options”: {
“systemMessage”: “=You’re a world class book writer with half a century of experience weaving words that connects with people, you’ll be given specific tasks to write chapters for books, you’ll be given research and the idea, description of the chapter, and you’ll have to comeup with the adecuate anount of content necesary to sake the chapter gold, you*ll filter through all the information and will write the chapter as it connects.\n\nWrite the content in markdown, It’s should be a long chapter and you’ll have to do your word magic to write the chapter in this book.”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.7,
“position”: [
740,
580
],
“id”: “1e05e577-248e-4229-8a7b-4a2447da868f”,
“name”: “AI Agent2”
}
],
“connections”: {
“AI Agent2”: {
“main”: [

]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “dad6575cdc9fb918369bf30cc4905e540fd7e5a48ee08d02082f1e7d7a2abd1c”
}
}

{
“nodes”: [
{
“parameters”: {
“model”: {
“__rl”: true,
“value”: “gpt-4o”,
“mode”: “list”,
“cachedResultName”: “gpt-4o”
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
340,
780
],
“id”: “cd5f4690-5a64-41ba-9329-6f3b7faf692f”,
“name”: “ChatGPT LGE”,
“credentials”: {
“openAiApi”: {
“id”: “lMR6ozBbqztOHaBi”,
“name”: “OpenAi V2 - LGE”
}
}
}
],
“connections”: {
“ChatGPT LGE”: {
“ai_languageModel”: [

]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “dad6575cdc9fb918369bf30cc4905e540fd7e5a48ee08d02082f1e7d7a2abd1c”
}
}

Share the output returned by the last node

Debug info

core

  • n8nVersion: 1.76.2
  • platform: docker (self-hosted)
  • nodeJsVersion: 20.18.2
  • database: postgres
  • executionMode: scaling
  • concurrency: -1
  • license: enterprise (production)

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: memory

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/132.0.0.0 safari/537.36
  • isTouchDevice: false

Log on Railways show:
Worker started execution 379 (job 55)

Feb 05 11:20:07

Worker

400 We could not parse the JSON body of your request. (HINT: This likely means you aren’t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)

n8n Version: 1.76.3
Database: Postgres
n8n EXECUTIONS_PROCESS setting: own
Running n8n via Railway.com
Operating system: Linux

1 Like

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

n8n Version: 1.76.3
Database: Postgres
n8n EXECUTIONS_PROCESS setting: own
Running n8n via Railway.com
Operating system: Linux

1 Like

I have this same error. I am just running a tool agent. If I rerun the execution with pinned node in editor it works fine. Just not the production link. If you get it sorted let me know

Did you manage to solve it?

i have the same issue

Same issue here, very annoying

Has anyone solved it?

I’m assuming its a bug, because it work working well previously

Same thing was happening to me but I just fixed it.

I use railway as well. I was up to date with my main n8n instance, but my worker instance was 6 weeks behind which was causing the problem. The production task goes through the worker first then the main instance.

As soon as i redeployed the other instances to latest version the error was fixed.

3 Likes

I had the same issue and this fixed it for me as well. Thank you!

1 Like

No problem :ok_hand:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.