Model setup recipes
Last updated
When OpenRouter Is Unavailable, How Do You Switch Your App to a Local LLM?
Send questions from your usual app to a model on your computer.
LM Studio runs models on your PC or Mac and can answer questions from other apps. If your app supports a custom OpenAI-compatible connection, create a separate local profile that connects to LM Studio. Prepare the model in advance, then test the connection and response with a short code review.
A local API server receives app requests and returns answers
LM Studio's API1 server receives code and questions from the app, runs them through the local model, and sends the answer back. First check whether your app's settings offer OpenAI-compatible or Custom provider. This is where you will enter LM Studio's server address (Base URL) and model ID. LM Studio server guide · Compatible API and Base URL
The function below calculates what percentage part represents of total. Send it to the local model and ask what happens when total is zero and how to fix it.
def percentage(part, total):
return part / total * 100
Prepare the model and runtime while you have a connection
Install LM Studio and find a model in the Discover tab. Check its model card for a format supported by an LM Studio runtime2, such as GGUF3 or MLX4, and choose a quantized file that fits your memory. If your task needs tool calls5, check that the selected model supports them. Model download guide
After downloading, select the model in the Chat tab and load it into memory. Complete any runtime installation prompt6 on the first run. You can import an external GGUF into LM Studio's model folder with lms import --copy. If only OpenRouter is unavailable but your internet connection works, you can still prepare the model. To prepare for losing internet access too, download the model and runtime in advance. Model search, downloads, runtime installation, and updates require a connection. Offline operation · Import models
Check the localhost server and actual model ID
Open the Developer tab in LM Studio and turn on Start server. The default example port is 1234, and Server Settings can change it, so use the actual API address shown in the app. Leave Serve on Local Network off and keep the server on this computer's localhost. Start the server · Server settings
Open http://localhost:1234/v1/models in a browser or terminal and copy an id from its data array into the app. If you changed the port, replace 1234 with the actual number. With JIT loading enabled, the list may include models stored on disk but not yet loaded into memory. Load the model first from the Chat tab's model loader, or enable JIT in Server Settings. List models API · Server settings
With the default authentication setting, this model-list request needs no external API key. If you enabled Require Authentication in LM Studio, use a local API token7 created through Manage Tokens in Server Settings, and enter it in the app only if its authentication field requires one. Never put an OpenRouter or other cloud key in a localhost request. LM Studio authentication
curl http://localhost:1234/v1/modelsCreate a separate local profile and open a new chat
Create a local profile by choosing OpenAI-compatible or Custom provider in your app's model-provider settings. Do not duplicate the OpenRouter profile because its provider type or automatic routing may remain. Set Base URL to http://localhost:1234/v1 and use the ID copied from /v1/models. If the app offers automatic provider fallback or a model router, turn it off so failed requests are not sent to an external service. LM Studio Base URL format
After saving the profile, select the local profile and open a new chat. Review the messages and attachments the app includes, then enter the code and question you want reviewed. Bring over any code or conditions from the previous cloud conversation that are needed for this review.

Check the connection with a short question, then review the code
Ask What is 1 + 1? in the app. If an answer returns, the basic request-and-response connection works. If no answer arrives, use the error table in the next section. To also check that the request actually reached LM Studio, use the optional log check below.
To inspect request logs, run lms --help in a terminal and check that the command list appears. If the command is not found, follow the LM Studio CLI setup guide. Then run the log command below and leave the terminal open.
lms log stream --source serverIf you started the log stream, repeat the same short question and check that the request appears. Log command guide Once the connection is checked, send the example function with Find the bug and suggest a minimal fix. What happens when total is 0? After the model identifies ZeroDivisionError when total == 0 and proposes a fix, compare how the code handles zero and what it returns.
A local model may have a different context limit or tool-calling support from the cloud model. For a long request, keep the code and question but shorten the input; for a task that needs tools, compare results with the app's tool integration off and on. For this example, check that the model finds the division-by-zero issue and that its proposed handling produces the intended return value.
Check the address, model ID, and authentication when an error occurs
When an error occurs, note the first status code or message in the app and LM Studio logs. Find the symptom in the table, change one item at a time, and repeat the same short question. Check whether a request appears in the server log to help distinguish an app connection problem from a model response problem. If task results differ after a valid response, also check context length8, tool support, and output limits. Server status guide
| Symptom | First check | Next |
|---|---|---|
| Connection refused or timeout | Server status in the Developer tab | localhost and port in the app's Base URL |
| Model not found | The id value in /v1/models | App's model field and loading state |
| 401 or authentication error | Require Authentication setting | Local token, not a cloud key |
| Response arrives but tools or context differ | Model and app feature support | Retest with short public code in a new chat |
Record the connection details and resume later
Note the server port, model ID, and runtime so you can continue the same check in a new chat later. For preserving model files with runtime settings, see the local LLM backup and restore guide; for the scope of related policy, see the AI export controls and local models guide.

Terminology notes
API — A defined interface that lets other code call a program’s functions.
Back to the textRuntime — The software environment that provides facilities needed while a program runs. In local AI, it can also refer to a model execution engine.
Back to the textGGUF — A file format for model data, widely used by llama.cpp-based tools.
Back to the textMLX — Apple’s machine-learning framework, which runs models using memory shared by the CPU and GPU on Apple Silicon.
Back to the textTool call — A structured request from a model for an external function such as reading a file, searching, or running a command. The agent runtime and its permission settings decide whether the request is actually executed.
Back to the textPrompt — The input text sent to a model. For generative models it describes the desired result and strongly shapes the output.
Back to the textToken — A unit into which a model divides input or output for processing.
Back to the textContext window — The token span of input and generated content a model can handle in one request. The supported limit and memory use depend on the model and runtime settings.
Back to the text
Frequently asked questions
- What should you check first in this article?
- LM Studio runs models on your PC or Mac and can answer questions from other apps. If your app supports a custom OpenAI-compatible connection, create a separate local profile that connects to LM Studio. Prepare the model in advance, then test the connection and response with a short code review.
- How much memory does it need?
- Install LM Studio and find a model in the Discover tab. Check its model card for a format supported by an LM Studio runtime, such as GGUF or MLX, and choose a quantized file that fits your memory. If your task needs tool calls, check that the selected model supports them. [Model download guide](https://lmstudio.ai/docs/app/basics/download-model)
- Where can you check the conditions and sources?
- Install LM Studio and find a model in the Discover tab. Check its model card for a format supported by an LM Studio runtime, such as GGUF or MLX, and choose a quantized file that fits your memory. If your task needs tool calls, check that the selected model supports them. [Model download guide](https://lmstudio.ai/docs/app/basics/download-model)
Read next
Model setup recipes
Connect a Free Open-Weight Model on OpenRouter for Code Review
Executable programs and extensions
Which local LLM app or serving engine should you start with?
Executable programs and extensions
Building Fully Offline Local AI: Air-Gap Installation and Update Procedures
read first
China's AI Export Controls: What Happens to the Models You Use on OpenRouter?
