Skip to content

Error when serving an LLM from LMStudio #889

Closed
@codyseally

Description

@codyseally

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions