How to Run Open Interpreter with Local LLM Models Using LM Studio or Ollama
To run Open Interpreter with local LLM models, configure the ollama/ prefix for Ollama or set api_base and a dummy api_key for OpenAI-compatible servers like LM Studio, with all requests routed through LiteLLM.
You can run Open Interpreter with local LLM models through a unified abstraction layer implemented in the openinterpreter/open-interpreter repository. The Llm class in interpreter/core/llm/llm.py converts internal messages to OpenAI-compatible formats and delegates inference to LiteLLM, enabling seamless switching between cloud and local providers.
Understanding the LLM Architecture
The core abstraction resides in interpreter/core/llm/llm.py. The Llm class handles model loading, context window management, and request construction.
Model naming conventions determine the provider:
- Ollama models use the prefix
ollama/<model-name>orollama_chat/<model-name>for the chat endpoint. - OpenAI-compatible servers (LM Studio, Jan, etc.) accept any placeholder model name like
openai/xwhen paired with a customapi_base.
When initializing, the Llm.load() method detects Ollama prefixes and queries http://localhost:11434 to verify installed models and retrieve context_length for token management. For other local servers, validation occurs in interpreter/terminal_interface/validate_llm_settings.py, which ensures the model is ready before the first chat.
The Llm.run() method converts the internal LMC message format to OpenAI messages, trims them to the model's context window, and yields completions via LiteLLM.
Running Open Interpreter with Ollama
Ollama provides the simplest local setup for Open Interpreter. The framework automatically detects Ollama installations and handles model pulling and context window detection.
CLI Configuration
First, install Ollama and start the server, then pull your desired model:
ollama run llama3
Run Open Interpreter with the Ollama prefix:
interpreter --model ollama/llama3
The --model ollama/<name> flag triggers the loading logic in interpreter/core/llm/llm.py, which contacts the Ollama HTTP API at http://localhost:11434 to list installed models and verify availability.
Python API Configuration
For programmatic use, disable cloud features and configure the Ollama endpoint:
from interpreter import interpreter
interpreter.offline = True
interpreter.llm.model = "ollama_chat/llama3"
interpreter.llm.api_base = "http://localhost:11434"
interpreter.chat()
The ollama_chat/ prefix specifically targets Ollama's /v1/chat/completions endpoint, while interpreter.offline = True ensures no external API calls occur.
Running Open Interpreter with LM Studio
LM Studio and similar OpenAI-compatible local servers require manual configuration of the base URL and API key. Unlike Ollama's automatic detection, these servers rely on explicit endpoint configuration.
CLI Configuration
Start LM Studio and enable the local server (defaults to http://localhost:1234/v1), then run:
interpreter \
--api_base "http://localhost:1234/v1" \
--api_key "fake_key" \
--model "openai/x"
The openai/x placeholder satisfies the model name requirement, while the dummy api_key fulfills LiteLLM's authentication expectations. The api_base redirects requests to your local server.
Python API Configuration
from interpreter import interpreter
interpreter.offline = True
interpreter.llm.model = "openai/x"
interpreter.llm.api_key = "fake_key"
interpreter.llm.api_base = "http://localhost:1234/v1"
interpreter.chat()
This configuration works for any OpenAI-compatible local server, including Jan, LocalAI, or custom implementations. The Llm class formats messages according to the OpenAI specification regardless of the underlying model.
Summary
- Open Interpreter routes all
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →