codex - 💡(How to fix) Fix Codex CLI sends invalid tools schema with OpenRouter (works in Codex IDE with identical config) [6 comments, 3 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#18330Fetched 2026-04-18 05:55:53
View on GitHub
Comments
6
Participants
3
Timeline
14
Reactions
0
Author
Timeline (top)
commented ×6labeled ×5closed ×1cross-referenced ×1

Error Message

When using Codex CLI (codex in PowerShell) with an OpenRouter model, every prompt fails with an invalid_prompt error. Returned error: "error": { Relevant part of the error details: The error points to invalid entries in: Request fails with invalid_prompt error Error indicates invalid tools schema

Root Cause

Disabling tools (if possible) appears to resolve the issue, indicating tool serialization is the root cause.

Code Example

{
  "error": {
    "code": "invalid_prompt",
    "message": "Invalid Responses API request"
  },
  "metadata": {
    "raw": "[ ... ]"
  }
}

---

Invalid input: expected "openrouter:web_search"
Invalid input: expected "openrouter:datetime"
Invalid input: expected "openrouter:image_generation"
Invalid input: expected "openrouter:experimental__search_models"
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

v0.121.0)

What subscription do you have?

plus

Which model were you using?

custom

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

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

PowerShell

What issue are you seeing?

When using Codex CLI (codex in PowerShell) with an OpenRouter model, every prompt fails with an invalid_prompt error.

Example prompt:

ping

Returned error:

{
  "error": {
    "code": "invalid_prompt",
    "message": "Invalid Responses API request"
  },
  "metadata": {
    "raw": "[ ... ]"
  }
}

Relevant part of the error details:

Invalid input: expected "openrouter:web_search"
Invalid input: expected "openrouter:datetime"
Invalid input: expected "openrouter:image_generation"
Invalid input: expected "openrouter:experimental__search_models"

The error points to invalid entries in:

tools[13] through tools[17]

The same prompt and configuration works correctly in Codex IDE.

What steps can reproduce the bug?

  1. Use Codex CLI (v0.121.0) in PowerShell
  2. Configure OpenRouter as provider:
  1. Run: codex
  2. Enter any prompt (e.g. ping)

Result:

Request fails with invalid_prompt error Error indicates invalid tools schema

What is the expected behavior?

The model should return a normal response.

This works correctly in Codex IDE using:

  • the same model
  • the same config.toml
  • the same preset

Additional information

Analysis suggests:

  • Codex CLI is sending a tools array containing unsupported tool types
  • OpenRouter only accepts:
    • type: "openrouter:*"
    • type: "function"
  • Codex IDE likely normalizes or filters tools before sending
  • Codex CLI appears to forward internal or unsupported tool definitions directly

Disabling tools (if possible) appears to resolve the issue, indicating tool serialization is the root cause.

This prevents using Codex CLI with OpenRouter, despite identical configurations working in Codex IDE.

extent analysis

TL;DR

Disable or filter unsupported tool types in the tools array to resolve the invalid_prompt error when using Codex CLI with OpenRouter.

Guidance

  • Verify that the tools array sent by Codex CLI contains only supported tool types (openrouter:* or function) to ensure compatibility with OpenRouter.
  • Check the Codex CLI configuration and preset to identify any tool definitions that may be causing the issue.
  • Consider modifying the config.toml file to exclude or normalize unsupported tool types before sending the request to OpenRouter.
  • If possible, disable tools altogether to confirm that tool serialization is the root cause of the issue.

Example

No code snippet is provided as the issue does not imply a specific code change, but rather a configuration or filtering adjustment.

Notes

The solution may require adjustments to the Codex CLI configuration or preset to ensure compatibility with OpenRouter's supported tool types. The exact steps may vary depending on the specific configuration and tools used.

Recommendation

Apply a workaround by disabling or filtering unsupported tool types in the tools array, as this is likely to resolve the invalid_prompt error and allow Codex CLI to work with OpenRouter.

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 Codex CLI sends invalid tools schema with OpenRouter (works in Codex IDE with identical config) [6 comments, 3 participants]