/v1/models returns OpenAI list schema but Codex clients expect a model catalog
Summary
9Router's /v1/models endpoint currently returns an OpenAI-compatible model list:
{
"object": "list",
"data": []
}
That is valid for generic OpenAI-compatible clients. However, Codex clients use the provider models endpoint as a Codex model catalog and expect a different schema:
{
"models": []
}
where each model entry includes Codex model capability metadata such as slug, display_name, supports_search_tool, tool_mode, and multi_agent_version.
Affected code
src/app/api/v1/models/route.js
The route currently returns:
return Response.json({ object: "list", data }, ...)
Reproduction
With 9Router running:
curl -sS http://127.0.0.1:20128/v1/models \
| jq '{top_keys: keys, has_models: has("models"), has_data: has("data"), first: .data[0]}'
Actual result:
{
"top_keys": ["data", "object"],
"has_models": false,
"has_data": true,
"first": {
"id": "...",
"object": "model",
"owned_by": "..."
}
}
When a Codex client tries to refresh the model catalog through this provider, decoding fails with:
failed to decode models response: missing field `models`
Expected behavior
For Codex-compatible provider usage, 9Router should expose a Codex-compatible model catalog response, for example:
{
"models": [
{
"slug": "gpt-5.5",
"display_name": "GPT-5.5",
"supported_in_api": true,
"supports_search_tool": true,
"tool_mode": "...",
"multi_agent_version": "..."
}
]
}
The exact fields should match the Codex ModelInfo schema expected by the client.
Impact
- Codex model catalog refresh fails against 9Router's provider
/modelsendpoint. - Capability metadata such as
supports_search_tool,tool_mode, andmulti_agent_versioncannot be delivered through the provider model catalog. - Clients may fall back to cached or bundled metadata, which can mask the issue and make behavior vary by local state.
Related but separate issues
There are existing /v1/models issues about missing or extra model IDs, such as #1046 and #1553. This issue is about the response schema expected by Codex clients, not about which specific model IDs are included in the OpenAI-compatible list.
Suggested fix
Keep the existing OpenAI-compatible /v1/models behavior for generic clients, but add Codex-compatible model catalog support for Codex clients. Possible approaches:
- detect Codex clients and return
{ "models": [...] } - expose a separate Codex model catalog endpoint and document how to configure Codex clients to use it
- map selected 9Router model entries to Codex
ModelInforecords with required capability fields
This should be covered by tests that validate both:
- OpenAI-compatible
{ object, data }behavior - Codex-compatible
{ models }behavior
Confirmed this is still reproducible with newer versions.
Environment:
- 9Router: v0.5.50 (
npm install -g 9router) - Codex CLI: v0.147.0-alpha.1.2
- OS: Windows
- Custom provider base URL:
http://127.0.0.1:20128/v1 - Wire API:
responses
Codex requests:
GET /v1/models?client_version=0.147.0-alpha.1.2
9Router returns an OpenAI-compatible list response:
{"object":"list","data":[{"id":"gpt-5.6-sol","object":"model","owned_by":"combo"}]}
Codex logs:
failed to refresh available models: stream disconnected before completion:
failed to decode models response: missing field `models`
The model catalog refresh fails, but normal POST /v1/responses traffic still works: a minimal request using the gpt-5.6-sol combo returned OK. This confirms the issue is isolated to the models catalog response schema rather than authentication or Responses API routing.
No credentials are included in this report.
Still reproducible on the current stack, and I think this issue is the upstream cause of #4405.
Environment
- 9Router: 0.5.86 (npm, systemd user service,
DATA_DIR=~/.9router) - Codex CLI: 0.159.0 (
codex app-server --remote-control) - Linux, provider base URL
http://127.0.0.1:20128/v1,wire_api = "responses"
Codex log, every app-server start:
ERROR codex_models_manager::manager: failed to refresh available models:
stream disconnected before completion: failed to decode models response:
missing field `models` at line 1 column 13740
Same missing field \models`` as @psympsym reported on 0.5.50 / codex 0.147, so nothing has shifted in three minor versions of each side.
The part I'd add to the report: what the failed refresh costs downstream.
Because the catalog never loads, Codex's /model picker cannot offer routable 9Router ids. The session therefore keeps whatever is in ~/.codex/config.toml — and the value Codex writes there itself is a bare slug (model = "gpt-5.6-sol"). 9Router resolves an unprefixed gpt-* to provider openai, which most users have no connection for, so the next request dies:
HTTP 404 {"error":{"message":"No active credentials for provider: openai",
"type":"invalid_request_error","code":"model_not_found"}}
Measured on this install (identical request body, only model changed):
| model sent | result |
|---|---|
gpt-5.6-sol |
404 No active credentials for provider: openai |
cx/gpt-5.6-sol |
200, normal completion |
gpt-6-astra |
404 |
cx/gpt-6-astra |
200 |
That 404 is what #4405 reports. So the two are one chain: catalog refresh fails here → picker falls back to bundled bare slugs → unprefixed slug routes to openai → 404. Fixing the schema here would remove the mechanism that produces #4405, since the picker could then list the cx/… ids that actually route.
Worth noting for anyone debugging this: the 404 path writes no row to the requestDetails table (no connection is ever selected), so it is invisible in the dashboard request log — it only appears in the service journal as ⚠️ [AUTH] No active credentials for provider: openai.
No credentials included in this report.