You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attempting to use LM Studio with OpenCode - TypeError [ERR_INVALID_URL]: "undefined/chat/completions" cannot be parsed as URL. #195
I am using OpenCode on an M4 Mac on OS Sequoia. I have LM Studio setup with to serve "unsloth/Magistral-Small-2506-GGUF" as the model. When trying to /init, I get the error mentioned above:
TypeError [ERR_INVALID_URL]: "undefined/chat/completions" cannot be parsed as URL.
I believe LM Studio is expecting /v1/chat/completions or /v1/completions but I'm unsure how to work around this for OpenCode.
Below are the the .toml files I created for the opencode.json, model & provider.
Nice! It would be neat to be able to add a full list of all of the locally downloaded models from lm studio into the config automagically.
Agreed! If it could just populate the models list with /v1/models, that would make things so much easier. And also have intelligent model switching where you can allocate certain models for certain tasks. Line one for web research, one for Architect, one for coding, and so on.
Activity
thdxr commentedon Jun 19, 2025
hey we just reworked how config works - can you refer to readme and try again? should be simpler and all in one file now
teslanaut commentedon Jun 19, 2025
Seems to work now. Here is what my config.json looks like. Thank you for your help:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lmstudio": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "http://localhost:1234/v1"
},
"models": {
"lmstudio/unsloth/magistral-small-2506": {}
}
}
},
"model": "lmstudio/unsloth/magistral-small-2506"
}
testacode commentedon Jun 20, 2025
Nice! It would be neat to be able to add a full list of all of the locally downloaded models from lm studio into the config automagically.
teslanaut commentedon Jun 20, 2025
Agreed! If it could just populate the models list with /v1/models, that would make things so much easier. And also have intelligent model switching where you can allocate certain models for certain tasks. Line one for web research, one for Architect, one for coding, and so on.
DimmKirr commentedon Aug 13, 2025
Pasting beautified json just in case someone needs it for visual parsing
{ "$schema": "https://opencode.ai/config.json", "provider": { "lmstudio": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:1234/v1" }, "models": { "lmstudio/unsloth/magistral-small-2506": {} } } }, "model": "lmstudio/unsloth/magistral-small-2506" }TRusselo commentedon Dec 20, 2025
Im getting the same error trying to connect to LiteLLM v 0.174 released 4 hours ago
note litellm is in a docker its internal port is 4000 but outside docker its 4005, docker does the mapping. this is not the faliure.
or should I open a fresh ticket?
feat(workflows): export a workflow as a runnable .claude/workflows/*.…