Problem
When using Codex CLI with OpenRouter as the backend via the Responses API, requests fail with a tool schema validation error. Codex CLI passes its internal tool definitions directly to the OpenRouter Responses API, but OpenRouter only accepts tools with openrouter:-prefixed type names.
Steps to Reproduce
- Configure Codex CLI to use OpenRouter as the provider
- Run any prompt that triggers tool use
- Observe the error returned from OpenRouter
Actual Behavior
{
"error": {
"code": "invalid_prompt",
"message": "Invalid Responses API request"
},
"metadata": {
"raw": [
{
"code": "invalid_union",
"path": ["tools", 12],
"message": "Invalid input",
"errors": [
{ "code": "invalid_value", "values": ["openrouter:datetime"], "message": "Invalid input: expected \"openrouter:datetime\"" },
{ "code": "invalid_value", "values": ["openrouter:image_generation"], "message": "Invalid input: expected \"openrouter:image_generation\"" },
{ "code": "invalid_value", "values": ["openrouter:web_search"], "message": "Invalid input: expected \"openrouter:web_search\"" },
{ "code": "invalid_value", "values": ["openrouter:web_fetch"], "message": "Invalid input: expected \"openrouter:web_fetch\"" }
]
}
]
}
}
Expected Behavior
Codex CLI should either translate its tool definitions to a compatible format, or fall back to the Chat Completions API (/api/v1/chat/completions) when the provider doesn't fully support the Responses API tool schema.
Suggested Fix
Use /api/v1/chat/completions instead of the Responses API when the provider is OpenRouter, as it has broader compatibility with third-party tool formats.
Problem
When using Codex CLI with OpenRouter as the backend via the Responses API, requests fail with a tool schema validation error. Codex CLI passes its internal tool definitions directly to the OpenRouter Responses API, but OpenRouter only accepts tools with
openrouter:-prefixed type names.Steps to Reproduce
Actual Behavior
{ "error": { "code": "invalid_prompt", "message": "Invalid Responses API request" }, "metadata": { "raw": [ { "code": "invalid_union", "path": ["tools", 12], "message": "Invalid input", "errors": [ { "code": "invalid_value", "values": ["openrouter:datetime"], "message": "Invalid input: expected \"openrouter:datetime\"" }, { "code": "invalid_value", "values": ["openrouter:image_generation"], "message": "Invalid input: expected \"openrouter:image_generation\"" }, { "code": "invalid_value", "values": ["openrouter:web_search"], "message": "Invalid input: expected \"openrouter:web_search\"" }, { "code": "invalid_value", "values": ["openrouter:web_fetch"], "message": "Invalid input: expected \"openrouter:web_fetch\"" } ] } ] } }Expected Behavior
Codex CLI should either translate its tool definitions to a compatible format, or fall back to the Chat Completions API (
/api/v1/chat/completions) when the provider doesn't fully support the Responses API tool schema.Suggested Fix
Use
/api/v1/chat/completionsinstead of the Responses API when the provider is OpenRouter, as it has broader compatibility with third-party tool formats.