CLIProxyAPI
CLIProxyAPI copied to clipboard
OpenAI Compatibility with OpenRouter results in invalid JSON response despite 200 OK
I am trying to use OpenRouter via the openai-compatibility provider.
The server logs indicate that the requests are successful with a 200 OK status code. However, the client (e.g., VS Code extension) fails to parse the response and throws a JSON syntax error.
It appears that the response body returned by the proxy is not valid JSON, containing a string starting with : OPENROUT..., which causes the client to crash.
Configuration (config.yaml)
openai-compatibility:
- name: openrouter
base-url: https://openrouter.ai/api/v1
api-key-entries:
- api-key: sk-or-v1-8e54ae900036*************************0e389672acfd377fa08322a865d8e3
models:
- name: amazon/nova-2-lite-v1:free
alias: ""
Server Logs
[2025-12-04 16:08:36] [info] [gin_logger.go:58] [GIN] 2025/12/04 - 16:08:36 | 200 | 0s | 127.0.0.1 | GET "/v1/models"
[2025-12-04 16:08:43] [debug] [manager.go:475] Use API key sk-o...d8e3 for model amazon/nova-2-lite-v1:free
[2025-12-04 16:08:46] [info] [gin_logger.go:58] [GIN] 2025/12/04 - 16:08:46 | 200 | 3.35s | 127.0.0.1 | POST "/v1/chat/completions"
[2025-12-04 16:08:56] [debug] [manager.go:475] Use API key sk-o...d8e3 for model amazon/nova-2-lite-v1:free
[2025-12-04 16:09:00] [info] [gin_logger.go:58] [GIN] 2025/12/04 - 16:09:00 | 200 | 3.081s | 127.0.0.1 | POST "/v1/chat/completions"
[2025-12-04 16:09:14] [info] [gin_logger.go:58] [GIN] 2025/12/04 - 16:09:14 | 200 | 0s | 127.0.0.1 | GET "/v1/models"
[2025-12-04 16:28:21] [debug] [manager.go:475] Use API key sk-o...d8e3 for model amazon/nova-2-lite-v1:free
[2025-12-04 16:28:25] [info] [gin_logger.go:58] [GIN] 2025/12/04 - 16:28:25 | 200 | 3.681s | 127.0.0.1 | POST "/v1/chat/completions"
kilo code Error
Unexpected token ':', ": OPENROUT"... is not valid JSON
using v6.5.40
It's not a bug. OpenRouter sent these tags to keep connection alive.
We just reply to this tag for the client.