codex - 💡(How to fix) Fix Using codex-cli 0.121.0 with openrouter fails [1 comments, 2 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#18228Fetched 2026-04-17 08:31:09
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×3closed ×1commented ×1cross-referenced ×1

Error Message

■ {"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 15\n ],\n "message": "Invalid input"\n }\n]"}}

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      15\n    ],\n    \"message\": \"Invalid input\"\n  }\n]"}}
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

0.121.0

What subscription do you have?

pro

Which model were you using?

gpt-5.3-codex

What platform is your computer?

Darwin 25.3.0 arm64 arm

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

ghostty

What issue are you seeing?

I did the official suggestions: https://openrouter.ai/docs/guides/coding-agents/codex-cli

I can start and when I issue any message at the cli I get:

■ {"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      15\n    ],\n    \"message\": \"Invalid input\"\n  }\n]"}}

When I downgrade back to 0.120.0 it works as expected.

What steps can reproduce the bug?

Install 0.121.0, set up a ~/.codex/config.toml matching: https://openrouter.ai/docs/guides/coding-agents/codex-cli and then start with your openrouter API key.

What is the expected behavior?

It should respond to the message without hitting any errors.

Additional information

No response

extent analysis

TL;DR

Downgrade to Codex CLI version 0.120.0 as a temporary workaround to resolve the "invalid_prompt" error.

Guidance

  • The error message indicates an "invalid_union" issue with the "type" discriminator, suggesting a compatibility problem between the Codex CLI version and the API expectations.
  • Verify that the ~/.codex/config.toml file is correctly set up according to the official documentation, as any misconfiguration could exacerbate the issue.
  • Consider waiting for an update to the Codex CLI that addresses this compatibility issue, as downgrading might not be a long-term solution.
  • If the issue persists after downgrading, re-check the API key and configuration for any potential mismatches or updates required for version 0.120.0.

Notes

The provided error message and the fact that downgrading to version 0.120.0 resolves the issue suggest a version-specific problem. Without further details on the changes between versions 0.120.0 and 0.121.0, it's challenging to provide a more targeted fix.

Recommendation

Apply the workaround by downgrading to version 0.120.0, as it has been confirmed to work as expected, allowing for temporary resolution of the issue until a more permanent fix is available.

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