Model setup recipes

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.

Requirements and key details
  • Download a model file supported by an LM Studio runtime and load it into memory. Complete any runtime installation prompt on the first run.
  • Check the server address in the Developer tab and the /v1/models response; enter a model ID shown in that list in your app.
  • Keep a separate local profile and new chat instead of overwriting the OpenRouter profile. If server authentication is enabled, enter only its local token; do not send an external service key.

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.

Short Python example to review
def percentage(part, total):
    return part / total * 100
Division fails when total is 0. Ask the model to identify that input case and suggest a fix.
An illustration links colored blocks in a drawer cabinet to an app-shaped panel, with a writing hand and notebook in front
To connect a local model to an app, first run the API server that serves it.

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

Check the model list
curl http://localhost:1234/v1/models
This baseline assumes localhost authentication is off. If enabled, add your LM Studio token in the Authorization header.

Create 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.

An illustrated workbench connects a laptop with code to several interfaces through a central device
The server passes a request to the local model and returns its answer in a compatible format.

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.

Check the LM Studio server log
lms log stream --source server
A request appearing in the server log confirms the app reached the localhost server.

If 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

First place to check for each visible symptom
SymptomFirst checkNext
Connection refused or timeoutServer status in the Developer tablocalhost and port in the app's Base URL
Model not foundThe id value in /v1/modelsApp's model field and loading state
401 or authentication errorRequire Authentication settingLocal token, not a cloud key
Response arrives but tools or context differModel and app feature supportRetest 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.

A monitor shows a code editor beside a chat panel with a review response
Send the same public code review in a new chat to check the local profile's connection.

Terminology notes

  1. API — A defined interface that lets other code call a program’s functions.

    Back to the text
  2. Runtime — 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 text
  3. GGUF — A file format for model data, widely used by llama.cpp-based tools.

    Back to the text
  4. MLX — Apple’s machine-learning framework, which runs models using memory shared by the CPU and GPU on Apple Silicon.

    Back to the text
  5. Tool 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 text
  6. Prompt — The input text sent to a model. For generative models it describes the desired result and strongly shapes the output.

    Back to the text
  7. Token — A unit into which a model divides input or output for processing.

    Back to the text
  8. Context 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)