Invalid URL when calling OpenRouter model (prime-intellect/intellect-3, deepseek/deepseek-r1-0528) #3373

Closed
opened 2026-02-16 17:39:49 -05:00 by yindo · 3 comments
Owner

Originally created by @DamianB-BitFlipper on GitHub (Dec 7, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Description

I’m getting a TypeError [ERR_INVALID_URL]: "undefined/chat/completions" cannot be parsed as a URL when trying to run inference against an OpenRouter-hosted model (prime-intellect/intellect-3, deepseek/deepseek-r1-0528). The failure occurs even though an OpenRouter API key is correctly configured and funded and /connect reports the provider as active. I am able to inference the default provided openrouter models.

The error suggests the client is not resolving the OpenRouter base URL, resulting in "undefined/chat/completions" being passed to the fetch call.

Config

Follows the opencode.ai docs

"provider": {
  "openrouter": {
    "models": {
      "prime-intellect/intellect-3": {},
      "deepseek/deepseek-r1-0528": {}
    }
  }
}

OpenCode version

1.0.134

Steps to reproduce

  1. Add the providers in the config above to the opencode.json
  2. Connect the openrouter provider with an API key
  3. Try to inference, for example opencode run -m openrouter/prime-intellect/intellect-3 hello

Screenshot and/or share link

No response

Operating System

macOS Sequoia 15.5

Terminal

kitty

Originally created by @DamianB-BitFlipper on GitHub (Dec 7, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description ### Description I’m getting a `TypeError [ERR_INVALID_URL]: "undefined/chat/completions" cannot be parsed as a URL` when trying to run inference against an OpenRouter-hosted model (`prime-intellect/intellect-3`, `deepseek/deepseek-r1-0528`). The failure occurs even though an OpenRouter API key is correctly configured and funded and `/connect` reports the provider as active. I am able to inference the default provided openrouter models. The error suggests the client is not resolving the OpenRouter base URL, resulting in `"undefined/chat/completions"` being passed to the fetch call. ### Config Follows the opencode.ai docs ```json "provider": { "openrouter": { "models": { "prime-intellect/intellect-3": {}, "deepseek/deepseek-r1-0528": {} } } } ``` ### OpenCode version 1.0.134 ### Steps to reproduce 1. Add the providers in the config above to the `opencode.json` 2. Connect the openrouter provider with an API key 3. Try to inference, for example `opencode run -m openrouter/prime-intellect/intellect-3 hello` ### Screenshot and/or share link _No response_ ### Operating System macOS Sequoia 15.5 ### Terminal kitty
yindo added the bug label 2026-02-16 17:39:49 -05:00
yindo closed this issue 2026-02-16 17:39:49 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 7, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #195: Attempting to use LM Studio with OpenCode - Same exact error message "TypeError [ERR_INVALID_URL]: "undefined/chat/completions" cannot be parsed as URL" when trying to use a custom provider with baseURL configuration

The root cause appears to be related to how custom provider baseURL configurations are being resolved. Issue #195 also mentions using OpenAI-compatible providers with baseURL, which is similar to your OpenRouter setup.

Feel free to ignore if your specific case differs.

@github-actions[bot] commented on GitHub (Dec 7, 2025): This issue might be a duplicate of existing issues. Please check: - #195: Attempting to use LM Studio with OpenCode - Same exact error message "TypeError [ERR_INVALID_URL]: \"undefined/chat/completions\" cannot be parsed as URL" when trying to use a custom provider with baseURL configuration The root cause appears to be related to how custom provider baseURL configurations are being resolved. Issue #195 also mentions using OpenAI-compatible providers with baseURL, which is similar to your OpenRouter setup. Feel free to ignore if your specific case differs.
Author
Owner

@rekram1-node commented on GitHub (Dec 7, 2025):

fixed in next release:
https://github.com/sst/opencode/commit/c30b1130eea1d2317105b4b3e3f69cfeb5bdc6de

@rekram1-node commented on GitHub (Dec 7, 2025): fixed in next release: https://github.com/sst/opencode/commit/c30b1130eea1d2317105b4b3e3f69cfeb5bdc6de
Author
Owner

@DamianB-BitFlipper commented on GitHub (Dec 7, 2025):

Amazing great. Thanks!

@DamianB-BitFlipper commented on GitHub (Dec 7, 2025): Amazing great. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3373