Tool calling turns a chat model into something that can ask your code to do things: look up a value, run a calculation, fetch a record. LM Studio’s OpenAI-compatible chat endpoint supports the standard tools array, so the model can reply with a tool call your app then executes.
Send the tools array and handle the tool call
Start the server and pick a model that supports tool calling — not every local model does, so check the model’s capabilities first. Send a chat completion to http://localhost:1234/v1/chat/completions with a tools array describing one function: its name, a description, and its parameters as a JSON schema. When the model wants the tool, the reply carries a tool_calls entry instead of text; your code runs the function, then sends the result back as a message with role tool so the model can finish the answer.
curl http://localhost:1234/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "<model-id>",
"messages": [{"role": "user", "content": "What is 847 times 293?"}],
"tools": [{"type": "function", "function": {"name": "multiply", "description": "Multiply two numbers", "parameters": {"type": "object", "properties": {"a": {"type": "number"}, "b": {"type": "number"}}, "required": ["a", "b"]}}}]'
The model decides whether to call the tool: a small model may answer in plain text instead, or call the tool with wrong arguments. Validate the arguments before executing anything, and never let a tool call run a destructive action without a human check. Tool support is one of the places where model choice matters most.
Try it: four checks
Check the tool name, arguments and result
Use a simple multiplication function for the first test. Check that the tool name is on your application’s allowlist and that both inputs are numbers. The sample input 847 × 293 gives 248171. Send the result in a tool message with the matching tool_call_id, keeping the assistant message that requested the call in the conversation.
For output that stays inside a fixed data shape, see the LM Studio JSON schema exercise.
| Check | What you should see | If you do not see it |
|---|---|---|
| Server running | GET /v1/models returns your model | Start the server first |
| Tool-capable model | The model supports tool calling | Check the model’s capabilities |
| Tool call returned | The reply has a tool_calls entry | Try a larger or tool-trained model |
| Result fed back | Sending the tool result gets a finished answer | Use role tool for the result message |
Expected result. We checked the LM Studio OpenAI Compatibility Endpoints page, which lists the chat completions endpoint and the model identifier rule. We did not call the API on this machine.
Limits
This guide covers the tools call only. Whether a model actually calls tools well is a property of that model, and tool results must be validated before use. We did not test any call ourselves.
