In Shortcuts on the same Mac as LM Studio, use Get Contents of URL to send a JSON POST to the running server’s loopback chat-completions endpoint. Extract the first choice’s message content and display it. Start with a fixed test prompt so you can tell whether the request and output actions both work.
Identify the local endpoint and model
Start with LM Studio’s local server already running on the same Mac and a text chat model ready to answer. Note the address shown by the server. This guide uses http://127.0.0.1:1234. If your server advertises a different port, change it in the example. Keep the shortcut’s network action on loopback for this one-Mac workflow. A copy of this shortcut running on another device would use that device’s own loopback address.
Use the model identifier LM Studio’s OpenAI-compatible API returns. A name in the chat UI can look different from that identifier. To see the API list from Terminal on the server Mac, run:
curl --noproxy 127.0.0.1 -sS http://127.0.0.1:1234/v1/models
If authentication is enabled, add the server-specific bearer token to this request using your own local credential handling. Use the exact id for the text model you have prepared. The model list can include downloaded models that the server can load on demand, so a visible ID alone does not confirm that its first reply will be immediate. Choose a model already available for chat and keep LM Studio open for the test. LM Studio’s model-list endpoint
The shortcut will use the full path /v1/chat/completions. This endpoint accepts the model ID and a list of chat messages. Choose a model that follows short text instructions, and use Send only the words CEDAR 27. as the first prompt. The expected displayed answer is CEDAR 27. LM Studio’s Chat Completions reference
Build the URL and JSON request in Shortcuts
Create a shortcut called Ask Local LM Test. Add a URL action and enter the complete loopback endpoint:
http://127.0.0.1:1234/v1/chat/completions
Add Get Contents of URL directly after it. Check that the input is the URL action’s output. Expand the request options, set Method to POST, and choose JSON for Request Body. JSON builds named fields that the API can read by type. A request to this endpoint needs a model selection and a message list.
Add the following values to the request body:
- Make model a text field. Paste the ID exactly as returned by the server.
- Make stream a Boolean field and leave it false. This lets the shortcut receive one complete JSON response.
- Make messages an array. Add one dictionary item to that array. Inside it, set role to the text user and content to the text Send only the words CEDAR 27.
The nested message is one dictionary inside a list. Keep that structure even though the test only sends one message. If the shortcut editor lets you use variables to build a field, the array’s item still needs to contain those two named keys. An ordinary text field with bracket characters typed into it is sent to the API as a string. For comparison, this is the JSON structure the API should receive:
{
"model": "replace-with-the-served-id",
"stream": false,
"messages": [
{
"role": "user",
"content": "Send only the words CEDAR 27."
}
]
}
Run the fixed test first before adding any input variable. If the server requires authentication, add the Authorization request header and use the value form Bearer <your local token>. Keep the token out of any copy of the shortcut you intend to share. If adding the token for a personal test, you can collect it at run time and insert that input into the header value. Remove any response previews that could show private content before using the shortcut with real prompts. Apple’s Get Contents of URL request options · LM Studio API authentication
Extract the assistant message
Temporarily add Quick Look after Get Contents of URL and run the shortcut. Inspect the response while using only the synthetic prompt. A successful non-streaming chat reply contains a choices list. The first item contains a message dictionary with the assistant’s content. If you instead see an error object, resolve the request issue before adding the display actions. LM Studio’s OpenAI-compatible response fields
Replace the temporary view with the following sequence. In each action, choose the output from the action named in the previous step:
- Add Get Dictionary from Input if the API output is passed as text or data. Give it the result of the network action. Use this converted dictionary as the first input below. If your editor already treats the response as a dictionary, select that variable directly.
- Add Get Dictionary Value with the key choices.
- Add Get Item from List and choose the first item from that result. Shortcuts counts the first item as 1.
- Add Get Dictionary Value for message using the selected item.
- Add another Get Dictionary Value for content using the message.
- Pass the final value to Show Result so the shortcut displays just the answer.
Take care with the input variable for each lookup. Three dictionary commands in one shortcut can look alike, and the editor can suggest an older result. Expand an action if needed and confirm it is reading the value produced immediately before it. A list of choices and a dictionary holding the message are different data types. Use the list action before asking Shortcuts for the message key. Apple’s dictionary actions · Apple’s list actions
Isolate the output actions with a sample response
If a real server answer arrives but the output actions are hard to check, duplicate the shortcut for an isolated test. In the duplicate, replace the network actions with a Text action containing this sample JSON. Connect Get Dictionary from Input to the Text action. Keep the downstream lookups and display action just as in the original.
{
"choices": [
{
"message": {
"role": "assistant",
"content": "CEDAR 27"
},
"finish_reason": "stop"
}
]
}
Run the duplicate and check for the expected text. Then replace the sample content with BIRCH 19 and run again. This confirms that the display reads the parsed assistant content each time. It gives you a way to trace the output actions independently before returning to the real shortcut. If the sample works and the real response does not, inspect the real result for a missing field or a different type, using the temporary Quick Look action with a synthetic prompt. A successful response might include additional fields. Keep the lookups on the keys you need so extra fields do not affect the result.
Verify a reply, then accept text input
Run the shortcut and check whether the final result says CEDAR 27. Check the local server’s activity or request log around the time you ran it. The visible code confirms Shortcuts found the expected content. A matching entry on the server helps confirm which endpoint received the message. When other apps share the server, repeat with a different code while they are idle so you can identify the new request.
When the fixed case works, duplicate the shortcut before experimenting. To accept a new prompt each time, add Ask for Input before the network action and use a text input. Replace the fixed message content with that input variable in the JSON body. Keep the role and model fields as before. Try a short input with a quotation mark to confirm the dictionary sends it as text. Keep the input as a field value so Shortcuts handles JSON encoding for the punctuation.
For a repeatable personal workflow, give the shortcut a name that identifies the local model connection. Retain the fixed version for troubleshooting and record its expected answer. If the server’s port or model changes later, update those values in the test shortcut and confirm it again before changing the shortcut that is used with your own text.
Run the fixed version after any change to authentication or endpoint settings. You can confirm three separate pieces of evidence in order. The correct URL and model ID identify the intended service. A matching request in LM Studio verifies that the service received the prompt. The text displayed by Shortcuts verifies that the response reached the last action in your chain. When a change breaks the workflow, start with the first piece of evidence you are missing.
Follow the first failing result
- The URL action runs and the network request cannot connect. Check the current LM Studio server address and port. Make sure Shortcuts is running on the same Mac. Try the direct model list and confirm it responds.
- The server refuses access. Check what authentication your local server requires. Confirm the Authorization header is present when needed and that the credential belongs to this server.
- The endpoint reports that a model or field is missing. Compare the model ID with the actual list. Check the method, endpoint path, and JSON body. For a type error, inspect that messages is an array holding a dictionary and that stream is Boolean.
- Quick Look shows an answer and Show Result is empty. Follow the chain from choices to the first item, then message, then content. Check every action’s input variable. If needed, temporarily view one intermediate value at a time to find where the chain stops.
- The request returns text with the wrong content. Check which model handled the message and repeat with a short code. If the model frequently adds extra words, consider whether your later shortcut should display its answer for review before passing it to another action.
Once the basic loopback connection works, you can reuse the same actions for short personal text prompts. If you need to check the selected model in the app first, use the local chat workflow and return to the shortcut after the model replies there. Check an LM Studio model in chat on Mac