LM Studio Generate Text:
LMStudioGenerateText sends chat requests to an LM Studio model through its OpenAI-compatible API and returns the model’s response as text. You can use it to write or refine text, or to describe images when the selected model supports vision. For a batch of images, it requests a separate response for each image and combines the results in batch order, making it useful for creating individual captions without setting up a separate workflow for every image. It can reduce the size of images before sending them, helping keep requests more manageable.
LM Studio Generate Text Input Parameters:
connection
A required LM_STUDIO_CONNECTION that supplies the server address, selected model, API key, and, if configured, a request timeout. The node uses these details to contact LM Studio; without a working connection and an available model, it cannot generate a response. This input has no default or numeric range specified in the node.
prompt
A required text instruction sent to the model, such as “Describe this image.” This is the main request that guides what the model writes; when an image is connected, the same prompt accompanies each image in the batch. The default is “Describe this image.” No minimum or maximum length is specified.
max_tokens
The maximum number of tokens requested for each generated response. Tokens are pieces of text, so this limits the response budget rather than setting an exact word count. A small value may cut an answer short; a larger value gives the model more room, including room used by a reasoning model before it writes a final answer. The default is 500, with a minimum of 1 and a maximum of 8192. For an image batch, this setting applies to each image’s separate request.
temperature
A setting passed to the model that influences how varied its responses may be. Lower values are generally useful when you want more consistent wording, while higher values can allow more variation; the exact effect depends on the selected model. The default is 0.7, with a minimum of 0.0, a maximum of 2.0, and steps of 0.01.
top_p
A setting passed to the model that controls how broadly it considers possible next tokens. Lower values narrow that selection, while higher values allow a broader selection; its visible effect depends on the model and other generation settings. The default is 0.95, with a minimum of 0.0, a maximum of 1.0, and steps of 0.01.
seed
An integer sent with every request, including when its value is 0. It can help make generation more repeatable when the model and other settings remain the same, although this node does not guarantee identical responses. The default is 0, with a minimum of 0 and a maximum of 4294967295. The same seed is sent for every image in a batch.
image
An optional IMAGE input that adds an image to the request, allowing a vision-capable model to respond to visual content. Without it, the node sends one text-only request. When it contains a batch, the node sends one request per image and collects the responses in the original batch order. No default, numeric range, or image-count limit is specified for this input.
system_prompt
An optional text instruction sent as a system message before the main request when it is not empty. You can use it to establish a general style or task direction, such as asking for concise descriptions; the selected model determines how it follows that instruction. The default is an empty string, which means no system message is added. No length limit is specified.
max_image_size
The maximum allowed length, in pixels, of an image’s longest side before it is sent. Images larger than this value are downscaled while preserving their proportions; smaller images are not enlarged. Reducing it can make image requests lighter, but it may remove fine visual detail needed for a task. The default is 1024, with a minimum of 256, a maximum of 4096, and steps of 64. It has no effect on text-only requests.
image_format
The format used to encode an attached image for transmission. The options are jpeg and png, with jpeg as the default. JPEG is generally faster to encode and produces a smaller payload, while PNG is lossless and may better preserve text-heavy or pixel-exact details. The node converts images to RGB before encoding, so this setting does not preserve transparency. It has no effect on text-only requests.
batch_separator
The text inserted between responses when an image batch contains more than one image. The default is two newline characters, \n\n, which places a blank line between results. Choose a distinctive separator if you plan to split the combined text into individual captions later. It is not added to a single response, and it has no effect on a text-only request. No length limit is specified.
LM Studio Generate Text Output Parameters:
generated_text
A STRING containing the text returned by the selected LM Studio model. For a text-only request or a single image, it contains one response. For an image batch, it contains one response per image in batch order, joined by the chosen separator. The node removes leading and trailing whitespace from each response before combining them. If the model returns no final content but does return reasoning content, the node uses that reasoning content instead and prints a warning; in that case, the text may not be the polished final answer you expected.
LM Studio Generate Text Usage Tips:
- For image descriptions, select a vision-capable model in your LM Studio connection and use a specific prompt, such as “Describe the subject, colors, and lighting in one sentence.” A text-only model may not handle the attached image.
- Start with the default
max_image_sizeof 1024 andimage_formatofjpegfor general captioning. If small lettering or exact pixel details matter, trypngand a larger image size, accepting a potentially slower request. - If a response ends too early, or the node warns that it used reasoning content instead of a final answer, increase
max_tokens. You can also adjust the model’s thinking mode outside this node if your LM Studio setup provides that option. - For batch captioning, remember that each image creates its own request. Use a prompt that works for every image, and set a recognizable
batch_separatorif another node needs to separate the captions afterward. - Use lower
temperaturewhen you want more consistent descriptions. When experimenting with creative wording, try a higher value and compare the results; keepseedand other settings unchanged when you want a more meaningful comparison.
LM Studio Generate Text Common Errors and Solutions:
LM Studio request failed after ... attempts: ...
- Explanation: The node could not complete a network request after retrying. The included detail may point to a refused connection, an unreachable address, or a timeout.
- Solution: Check that LM Studio’s server is running, the connection uses the correct address and port, and the server is reachable from your workflow. If a large image or slow model is timing out, try a smaller
max_image_sizeor adjust the timeout in the connection configuration, if available.
LM Studio returned HTTP ...: ...
- Explanation: LM Studio responded with an error status. The message includes up to the first 500 characters of its response, which may identify a problem such as a model not being available, an oversized request, or a context limit. The node does not retry HTTP error responses.
- Solution: Read the message after the status code. Confirm the selected model is available, shorten the prompt or reduce
max_tokensif the request exceeds the model’s limits, and reducemax_image_sizeif the image is too large.
Unexpected response from LM Studio: ...
- Explanation: The server returned data without the expected first choice or message, so the node could not find the generated response.
- Solution: Confirm that the connection points to LM Studio’s compatible API and that the server and selected model are responding normally. Inspect the response shown in the error for more detail.
LM Studio returned no content and no reasoning_content. Full response: ...
- Explanation: The response contained neither final text nor reasoning text for the node to return.
- Solution: Inspect the included response, try a clearer prompt, and increase
max_tokensif the model may have run out of response budget. Check the model’s behavior in LM Studio if the problem continues.
[LM Studio] WARNING: 'content' was empty ... Falling back to reasoning_content
- Explanation: This is a warning rather than a failed request. The model returned reasoning text but no final answer, potentially because it used its token budget before finishing.
- Solution: Increase
max_tokensto give the model room for a final answer, or disable thinking mode in your model setup if that option is available. Checkgenerated_textbefore using it as a finished caption.
Image request rejected or image not understood
- Explanation: An attached image is sent as image content, which requires a model that can accept it. A non-vision model may reject the request or fail to respond meaningfully to the image; the exact message depends on LM Studio and the model.
- Solution: Choose a vision-capable model in the connection. If the server reports that the image is too large, lower
max_image_sizeor usejpegfor a smaller payload.
Connection field error such as KeyError: 'base_url', KeyError: 'model', or KeyError: 'api_key'
- Explanation: The supplied connection lacks a field that this node reads before sending its request.
- Solution: Connect a valid
LM_STUDIO_CONNECTIONconfigured with the server address, model, and API key fields required by your connection node.
