Skip to content

Invalid Responses API request when using OpenRouter #18307

Closed as not planned
Closed as not planned

Description

@papirosko

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: #12114

Activity

  1. added
    bug
    on Apr 17, 2026
  2. added
    CLI
    custom-model
    on Apr 17, 2026
  3. github-actions commented on Apr 17, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. etraut-openai commented on Apr 17, 2026

    @etraut-openai
    Contributor

    Please report the bug to the openrouter maintainers.

  5. papirosko commented on Apr 17, 2026

    @papirosko
    Author

    quick fix:
    comment all sections, starting with [mcp_servers. in ~/.codex/config.toml

  6. tt-a1i commented on Apr 17, 2026

    @tt-a1i

    Hit by this today too, here's a dump of what I dug up in case it helps others searching for this.

    Narrowing the source. The failing tools[N] indices drop by exactly one when you disable the auto-enabled computer-use@openai-bundled plugin:

    • plugin enabled → tools[17], [18], [19] rejected
    • plugin disabled → tools[17], [18] still rejected

    So there are at least two independent sources of the unknown tool type. One is computer-use (expected — OpenRouter's Responses API zod schema doesn't know OpenAI's computer-use tool). The other two come from core Codex 0.121.0, most likely the MCP Apps tool support from #17364 — apps = true is a stable default now and that's a new tool-injection path. @papirosko's workaround of commenting out [mcp_servers.*] sections is consistent with this — it strips the MCP-originated tool entries from the array.

    Everything it emits has a type that's neither function nor any of the four openrouter:* variants, so the discriminated union throws them out.

    Notes for Codex.app (desktop) users, since that's what I started with before moving to the CLI:

    • The desktop app ships its own bundled codex binary under /Applications/Codex.app/Contents/Resources/codex, independent of npm -g @openai/codex. Downgrading via npm only fixes the CLI — the app is unaffected.
    • Editing ~/.codex/config.toml while the app is running does nothing. The app only reads config at startup, and closing the window isn't enough — you have to ⌘Q the whole app for plugin toggles to take effect.
    • On first launch after today's marketplace auto-sync ([marketplaces.openai-bundled] last_updated bumped to 2026-04-17T07:14:26Z in my config), the computer-use@openai-bundled plugin got auto-enabled without prompting. Its MCP server (SkyComputerUseClient mcp) also stays resident in the background — I saw it persist across sessions even after flipping enabled = false, so pkill SkyComputerUseClient after disabling is worth doing to be safe.
    • resume / resume --last caches the prior session's tool list in the rollout, so even a config change + restart won't help if you re-enter via resume — start a fresh session.

    Workarounds that actually work today:

    • npm i -g @openai/[email protected] for the CLI (confirmed working)
    • for the desktop app, grab the 0.120.0 .dmg from the releases page and reinstall
    • check_for_update_on_startup = false in ~/.codex/config.toml prevents auto-upgrade back to 0.121.0
    • wire_api = "chat" on the openrouter provider block should sidestep this entirely (haven't tested myself, but chat completions has a much looser tool schema)
    • @papirosko's trick (comment out [mcp_servers.*]) also works and is more surgical if you want to stay on 0.121.0

    The root-cause bucket here (new Codex tool types vs. OpenRouter's strict Responses schema) is different from the earlier rounds on #12114, which were about message/input shapes. The tools array is the new surface.

  7. TylonHH commented on Apr 18, 2026

    @TylonHH

    Now I get
    {"type":"error","status":400,"error":{"type":"invalid_request_error","message":"The 'MiniMax: MiniMax M2.5' model is not supported when using Codex with a ChatGPT account."}}

  8. Invoker-liu commented on Apr 27, 2026

    @Invoker-liu

    Down to 120,everything is fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugcustom-model

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions