Error when serving an LLM from LMStudio #644

Closed
opened 2026-02-16 17:27:42 -05:00 by yindo · 4 comments
Owner

Originally created by @codyseally on GitHub (Jul 11, 2025).

I am serving LLMs from a Win 11 machine and using opencode on a linux machine.

First, to test my connection to LMStudio, I ran a curl command

`curl http://192.168.1.xx:1234/v1/chat/completions \

-H "Content-Type: application/json"
-d '{
"model": "loaded-model",
"messages": [
{ "role": "user", "content": "Explain what a fermion is in one sentence." }
],
"temperature": 0.7,
"max_tokens": 256
}'
{
"id": "chatcmpl-nwt0aesq9stjvmb4tk5g",
"object": "chat.completion",
"created": 1752248909,
"model": "deepseek/deepseek-r1-0528-qwen3-8b",
"choices": [
{
"index": 0,
"logprobs": null,
"finish_reason": "length",
"message": {
"role": "assistant",
"content": "\nOkay, the user asked me to explain what a fermion is in just one sentence. Let me start by recalling the basics from quantum mechanics. Fermions are particles that follow Fermi-Dirac statistics and have half-integer spins. They obey the Pauli exclusion principle, which means no two can occupy the same quantum state.\n\nHmm, the user might be someone new to physics or looking for a quick refresher. Since they want it concise, maybe they're checking their understanding before an exam or trying to grasp fundamental concepts quickly. But why one sentence? They probably need a very brief definition without jargon overload, so I should balance clarity with technical accuracy.\n\nWait, the key points are: half-integer spin (1/2), Fermi-Dirac statistics, Pauli exclusion principle. The assistant's answer includes all three but mentions "matter particles" like electrons and quarks, which gives examples. That helps users relate it to things they know. But maybe I should check if that's too informal for the context.\n\nThe user might not just want a definition; perhaps they're confused about fermions versus bosons or other classifications. Including common examples makes it relatable but could be simplified further. Let me see, "anything with half"
}
}
],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 255,
"total_tokens": 268
},
"stats": {},
"system_fingerprint": "deepseek/deepseek-r1-0528-qwen3-8b"`

Ok, so we know LMStudio works, is reachable, now I added the following opencode.json in my project folder:

{ "$schema": "https://opencode.ai/config.json", "provider": { "lmstudio": { "npm": "@ai-sdk/openai-compatible", "name": "LM Studio", "options": { "baseURL": "http://192.168.1.xx:1234/v1" }, "models": { "mistralai/devstral-small-2507": { "name": "devstral_small_2507" }, "deepseek/deepseek-r1-0528-qwen3-8b": { "name": "deepseek r1 8b" } } } } }

(I added the xx to the local ip just out of paranoia :) ) I tested with both of these models by simply typing "Hi" in the chat, to which I get a popup saying :

failed to send message: POST "http://127.0.0.1:44047/session/ses_805e9e45dffe1JZSKeApqmQJ80/message": 400 Bad Request {"name":"UnknownError","data":{"message":"AI_InvalidArgumentError: Invalid argument for parameter maxOutputTokens: maxOutputTokens must be >= 1"}}

and the model then hangs.

Any idea why this is and how to fix it? I even added a profile in LMStudio with MaxOutputTokens = 2048, nothing changed.

Originally created by @codyseally on GitHub (Jul 11, 2025). I am serving LLMs from a Win 11 machine and using opencode on a linux machine. First, to test my connection to LMStudio, I ran a curl command `curl http://192.168.1.xx:1234/v1/chat/completions \ > -H "Content-Type: application/json" \ > -d '{ > "model": "loaded-model", > "messages": [ > { "role": "user", "content": "Explain what a fermion is in one sentence." } > ], > "temperature": 0.7, > "max_tokens": 256 > }' { "id": "chatcmpl-nwt0aesq9stjvmb4tk5g", "object": "chat.completion", "created": 1752248909, "model": "deepseek/deepseek-r1-0528-qwen3-8b", "choices": [ { "index": 0, "logprobs": null, "finish_reason": "length", "message": { "role": "assistant", "content": "<think>\nOkay, the user asked me to explain what a fermion is in just one sentence. Let me start by recalling the basics from quantum mechanics. Fermions are particles that follow Fermi-Dirac statistics and have half-integer spins. They obey the Pauli exclusion principle, which means no two can occupy the same quantum state.\n\nHmm, the user might be someone new to physics or looking for a quick refresher. Since they want it concise, maybe they're checking their understanding before an exam or trying to grasp fundamental concepts quickly. But why one sentence? They probably need a very brief definition without jargon overload, so I should balance clarity with technical accuracy.\n\nWait, the key points are: half-integer spin (1/2), Fermi-Dirac statistics, Pauli exclusion principle. The assistant's answer includes all three but mentions \"matter particles\" like electrons and quarks, which gives examples. That helps users relate it to things they know. But maybe I should check if that's too informal for the context.\n\nThe user might not just want a definition; perhaps they're confused about fermions versus bosons or other classifications. Including common examples makes it relatable but could be simplified further. Let me see, \"anything with half" } } ], "usage": { "prompt_tokens": 13, "completion_tokens": 255, "total_tokens": 268 }, "stats": {}, "system_fingerprint": "deepseek/deepseek-r1-0528-qwen3-8b"` Ok, so we know LMStudio works, is reachable, now I added the following `opencode.json` in my project folder: `{ "$schema": "https://opencode.ai/config.json", "provider": { "lmstudio": { "npm": "@ai-sdk/openai-compatible", "name": "LM Studio", "options": { "baseURL": "http://192.168.1.xx:1234/v1" }, "models": { "mistralai/devstral-small-2507": { "name": "devstral_small_2507" }, "deepseek/deepseek-r1-0528-qwen3-8b": { "name": "deepseek r1 8b" } } } } }` (I added the xx to the local ip just out of paranoia :) ) I tested with both of these models by simply typing "Hi" in the chat, to which I get a popup saying : `failed to send message: POST "http://127.0.0.1:44047/session/ses_805e9e45dffe1JZSKeApqmQJ80/message": 400 Bad Request {"name":"UnknownError","data":{"message":"AI_InvalidArgumentError: Invalid argument for parameter maxOutputTokens: maxOutputTokens must be >= 1"}}` and the model then hangs. Any idea why this is and how to fix it? I even added a profile in LMStudio with MaxOutputTokens = 2048, nothing changed.
yindo closed this issue 2026-02-16 17:27:42 -05:00
Author
Owner

@RichardBray commented on GitHub (Jul 11, 2025):

I'm getting the same error for a remote Ollama instance. Would be good to get this fixed 🙏

@RichardBray commented on GitHub (Jul 11, 2025): I'm getting the same error for a remote Ollama instance. Would be good to get this fixed 🙏
Author
Owner

@RichardBray commented on GitHub (Jul 11, 2025):

Looks like this fixes it for Ollama https://github.com/sst/opencode/issues/858#issuecomment-3059206825

@RichardBray commented on GitHub (Jul 11, 2025): Looks like this fixes it for Ollama https://github.com/sst/opencode/issues/858#issuecomment-3059206825
Author
Owner

@codyseally commented on GitHub (Jul 11, 2025):

Looks like this fixes it for Ollama #858 (comment)

How do you use opencode with ollama ? Is it calling any tools ? Also what do you mean it fixes it for ollama, I'd love to get it working, but in ollama tools do not work (see the other issue here).

@codyseally commented on GitHub (Jul 11, 2025): > Looks like this fixes it for Ollama [#858 (comment)](https://github.com/sst/opencode/issues/858#issuecomment-3059206825) How do you use opencode with ollama ? Is it calling any tools ? Also what do you mean it fixes it for ollama, I'd love to get it working, but in ollama tools do not work (see the other issue here).
Author
Owner

@thdxr commented on GitHub (Jul 11, 2025):

this should be fixed on v0.2.28

@thdxr commented on GitHub (Jul 11, 2025): this should be fixed on [**v0.2.28**](https://github.com/sst/opencode/releases/tag/v0.2.28)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#644