codex - 💡(How to fix) Fix Invalid Responses API request when using OpenRouter [4 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18307Fetched 2026-04-18 05:56:24
View on GitHub
Comments
4
Participants
4
Timeline
12
Reactions
0
Author
Timeline (top)
commented ×4labeled ×3cross-referenced ×2closed ×1

Error Message

{"error":{"code":"invalid_prompt","message":"Invalid Responses API request"},"metadata":{"raw":"[\n {\n "code": "invalid_union",\n "errors": here is the same error: https://github.com/openai/codex/issues/12114

Code Example

{"error":{"code":"invalid_prompt","message":"Invalid Responses API request"},"metadata":{"raw":"[\n  {\n    \"code\": \"invalid_union\",\n    \"errors\":
[\n      [\n        {\n          \"code\": \"invalid_union\",\n          \"errors\": [],\n          \"note\": \"No matching discriminator\",\n
\"discriminator\": \"type\",\n          \"path\": [\n            \"type\"\n          ],\n          \"message\": \"Invalid input\"\n        }\n      ],\n
[\n        {\n          \"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:datetime\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:datetime\\\"\"\n        }\n      ],\n      [\n        {\n
\"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:image_generation\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:image_generation\\\"\"\n        }\n      ],\n      [\n        {\n
\"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:experimental__search_models\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:experimental__search_models\\\"\"\n        }\n      ],\n      [\n
{\n          \"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:web_search\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:web_search\\\"\"\n        }\n      ]\n    ],\n    \"path\": [\n
\"tools\",\n      16\n    ],\n    \"message\": \"Invalid input\"\n  },\n  {\n    \"code\": \"invalid_union\",\n    \"errors\": [\n      [\n        {\n
\"code\": \"invalid_union\",\n          \"errors\": [],\n          \"note\": \"No matching discriminator\",\n          \"discriminator\": \"type\",\n
\"path\": [\n            \"type\"\n          ],\n          \"message\": \"Invalid input\"\n        }\n      ],\n      [\n        {\n          \"code\":
\"invalid_value\",\n          \"values\": [\n            \"openrouter:datetime\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n
\"message\": \"Invalid input: expected \\\"openrouter:datetime\\\"\"\n        }\n      ],\n      [\n        {\n          \"code\": \"invalid_value\",\n
\"values\": [\n            \"openrouter:image_generation\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n          \"message\":
\"Invalid input: expected \\\"openrouter:image_generation\\\"\"\n        }\n      ],\n      [\n        {\n          \"code\": \"invalid_value\",\n
\"values\": [\n            \"openrouter:experimental__search_models\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n
\"message\": \"Invalid input: expected \\\"openrouter:experimental__search_models\\\"\"\n        }\n      ],\n      [\n        {\n          \"code\":
\"invalid_value\",\n          \"values\": [\n            \"openrouter:web_search\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n
\"message\": \"Invalid input: expected \\\"openrouter:web_search\\\"\"\n        }\n      ]\n    ],\n    \"path\": [\n      \"tools\",\n      17\n    ],\n
\"message\": \"Invalid input\"\n  }\n]"}}
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.121.0

What subscription do you have?

Plus

Which model were you using?

No response

What platform is your computer?

macos

What terminal emulator and version are you using (if applicable)?

Iterm2

What issue are you seeing?

{"error":{"code":"invalid_prompt","message":"Invalid Responses API request"},"metadata":{"raw":"[\n  {\n    \"code\": \"invalid_union\",\n    \"errors\":
[\n      [\n        {\n          \"code\": \"invalid_union\",\n          \"errors\": [],\n          \"note\": \"No matching discriminator\",\n
\"discriminator\": \"type\",\n          \"path\": [\n            \"type\"\n          ],\n          \"message\": \"Invalid input\"\n        }\n      ],\n
[\n        {\n          \"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:datetime\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:datetime\\\"\"\n        }\n      ],\n      [\n        {\n
\"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:image_generation\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:image_generation\\\"\"\n        }\n      ],\n      [\n        {\n
\"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:experimental__search_models\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:experimental__search_models\\\"\"\n        }\n      ],\n      [\n
{\n          \"code\": \"invalid_value\",\n          \"values\": [\n            \"openrouter:web_search\"\n          ],\n          \"path\": [\n
\"type\"\n          ],\n          \"message\": \"Invalid input: expected \\\"openrouter:web_search\\\"\"\n        }\n      ]\n    ],\n    \"path\": [\n
\"tools\",\n      16\n    ],\n    \"message\": \"Invalid input\"\n  },\n  {\n    \"code\": \"invalid_union\",\n    \"errors\": [\n      [\n        {\n
\"code\": \"invalid_union\",\n          \"errors\": [],\n          \"note\": \"No matching discriminator\",\n          \"discriminator\": \"type\",\n
\"path\": [\n            \"type\"\n          ],\n          \"message\": \"Invalid input\"\n        }\n      ],\n      [\n        {\n          \"code\":
\"invalid_value\",\n          \"values\": [\n            \"openrouter:datetime\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n
\"message\": \"Invalid input: expected \\\"openrouter:datetime\\\"\"\n        }\n      ],\n      [\n        {\n          \"code\": \"invalid_value\",\n
\"values\": [\n            \"openrouter:image_generation\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n          \"message\":
\"Invalid input: expected \\\"openrouter:image_generation\\\"\"\n        }\n      ],\n      [\n        {\n          \"code\": \"invalid_value\",\n
\"values\": [\n            \"openrouter:experimental__search_models\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n
\"message\": \"Invalid input: expected \\\"openrouter:experimental__search_models\\\"\"\n        }\n      ],\n      [\n        {\n          \"code\":
\"invalid_value\",\n          \"values\": [\n            \"openrouter:web_search\"\n          ],\n          \"path\": [\n            \"type\"\n          ],\n
\"message\": \"Invalid input: expected \\\"openrouter:web_search\\\"\"\n        }\n      ]\n    ],\n    \"path\": [\n      \"tools\",\n      17\n    ],\n
\"message\": \"Invalid input\"\n  }\n]"}}

What steps can reproduce the bug?

I use OpenRouter for models. Just upgraded to latest codex cli version and started to receive this message on any prompt

What is the expected behavior?

No response

Additional information

here is the same error: https://github.com/openai/codex/issues/12114

extent analysis

TL;DR

The issue is likely due to an invalid prompt request to the Responses API, and checking the prompt format and model compatibility may resolve the issue.

Guidance

  • Verify that the prompt format is correct and compatible with the OpenRouter models, as the error message suggests an "Invalid input" with expected values including "openrouter:datetime", "openrouter:image_generation", etc.
  • Check the OpenRouter documentation to ensure that the prompt is correctly formatted and that the model being used supports the requested functionality.
  • Review the GitHub issue linked in the additional information section (https://github.com/openai/codex/issues/12114) to see if others have experienced similar issues and found resolutions.
  • Consider downgrading to a previous version of the Codex CLI to see if the issue is specific to the latest version.

Example

No code snippet is provided as the issue is related to the prompt format and model compatibility, rather than a specific code error.

Notes

The issue may be related to changes in the latest Codex CLI version or compatibility issues with the OpenRouter models. Further investigation into the prompt format and model documentation is necessary to resolve the issue.

Recommendation

Apply workaround: Check the prompt format and model compatibility to resolve the issue, as the problem may be specific to the latest Codex CLI version or OpenRouter model configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Invalid Responses API request when using OpenRouter [4 comments, 4 participants]