Local models with LM Studio
LM Foundry talks to models through Azure OpenAI or any OpenAI-compatible endpoint. LM Studio serves one on port 1234, and the local stack uses it by default when no cloud model credentials are configured.
How the local stack picks models
Section titled “How the local stack picks models”When the backend has no Azure OpenAI key configured, the service launcher (scripts/dev/run-service.sh, used by stack.sh) switches two services to local models:
| Service | Local model | Used for |
|---|---|---|
| Chat | gemma-4-e4b | chat, agents, conversation titles and query rewriting |
| Chat and knowledge indexer | text-embedding-nomic-embed-text-v1.5 | embeddings (768 dimensions, stored in pgvector) |
The endpoint defaults to http://host.docker.internal:1234/v1, which is LM Studio on the host as seen from the containers. Set LOCAL_LLM_BASE_URL to point somewhere else.
1. Start LM Studio and load the models
Section titled “1. Start LM Studio and load the models”Start LM Studio’s local server, then load both models. Just-in-time loading is off, so a model that isn’t loaded fails with “No models loaded”:
lms load google/gemma-4-e4b
lms load text-embedding-nomic-embed-text-v1.52. Chat
Section titled “2. Chat”In Foundry UI the model picker pre-selects the first deployed chat model, so Gemma is chosen automatically. A model name that isn’t deployed returns 400.
3. Index with local embeddings
Section titled “3. Index with local embeddings”Knowledge bases indexed on the local stack use the nomic embedding model. Vectors from different embedding models aren’t comparable, and the dimensions must match the vector table, so don’t switch embedding models under an existing knowledge base: re-index it instead.
4. AI extraction in the crawler (optional)
Section titled “4. AI extraction in the crawler (optional)”The crawler can use a model to extract text from pages its rules can’t handle. It is off unless you configure it in the backend’s .env:
WEB_CRAWLER_LLM_BASE_URL=http://host.docker.internal:1234/v1
WEB_CRAWLER_LLM_MODEL=google/gemma-4-e4b
WEB_CRAWLER_LLM_API_KEY=<any non-empty value for LM Studio>Load the model with a context length of at least 32k; the 8,192 default is too small for real pages.
Using another OpenAI-compatible server
Section titled “Using another OpenAI-compatible server”Any server that speaks the OpenAI API can take LM Studio’s place: point LOCAL_LLM_BASE_URL (and the crawler’s WEB_CRAWLER_LLM_BASE_URL) at it and serve models under the same names, or change the model list in the backend’s local model configuration.