--- # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 title: "Use Local Inference with LM Studio" sidebar-title: "Local Inference with LM Studio" slug: "get-started/tutorials/local-inference-lmstudio" description: "Attach a provider profile for a local LM Studio server and call its native compatible endpoints." keywords: "Generative AI, Cybersecurity, Tutorial, LM Studio, Local Inference, Sandbox, Provider Profile" --- This tutorial exposes an LM Studio server on the gateway host to selected sandboxes. The provider attachment grants access; the workload calls LM Studio's OpenAI- or Anthropic-compatible endpoint directly. ## Prerequisites - Complete the [Quickstart](/get-started/quickstart). - Install [LM Studio](https://lmstudio.ai/download) on the gateway host. For a headless installation: ```shell curl -fsSL https://lmstudio.ai/install.sh | bash ``` ```shell irm https://lmstudio.ai/install.ps1 | iex ``` Start the daemon and server: ```shell lms daemon up lms server start --bind 0.0.0.0 ``` Load a model: ```shell lms get qwen/qwen3.5-2b lms load qwen/qwen3.5-2b ``` ## Create the Provider Profile Save this as `lmstudio.yaml`: ```yaml id: lmstudio display_name: LM Studio description: Host-level LM Studio compatible APIs category: inference inference_capable: true credentials: [] endpoints: - host: host.openshell.internal port: 1234 protocol: rest access: read-write enforcement: enforce binaries: - /usr/bin/curl - /usr/local/bin/curl - /usr/bin/python3 - /usr/local/bin/python - /sandbox/.uv/python/** - /sandbox/.venv/** ``` ```shell openshell provider profile lint -f lmstudio.yaml openshell provider profile import -f lmstudio.yaml openshell provider create --name lmstudio --type lmstudio ``` The profile intentionally has no credential. LM Studio does not require one by default, but the provider attachment still supplies its policy boundary. ## Attach and Call the Native Endpoint OpenAI-compatible request: ```shell openshell sandbox create \ --name lmstudio-client \ --provider lmstudio \ -- \ curl http://host.openshell.internal:1234/v1/chat/completions \ --json '{ "model":"qwen/qwen3.5-2b", "messages":[{"role":"user","content":"hello"}], "max_tokens":10 }' ``` Anthropic-compatible request: ```shell openshell sandbox exec lmstudio-client -- \ curl http://host.openshell.internal:1234/v1/messages \ --json '{ "model":"qwen/qwen3.5-2b", "messages":[{"role":"user","content":"hello"}], "max_tokens":10 }' ``` Configure SDKs with the same native base URL. Some SDKs require a non-empty API key even when LM Studio ignores it; use a literal non-secret value such as `unused`. Keep the actual model ID in the client request. ## Troubleshooting - Enable **Serve on Local Network** in the LM Studio Developer tab, or use `lms server start --bind 0.0.0.0`. - Use `host.openshell.internal`, not `127.0.0.1` or `localhost`, in the sandbox. - Confirm the model is loaded with `lms ps`. - Confirm the attachment with `openshell sandbox provider list lmstudio-client`. - Inspect endpoint and binary policy with `openshell policy get lmstudio-client --full`. - A remote gateway cannot reach an LM Studio process on your laptop without a tunnel or shared network path. ## Next Steps - [Provider-backed Inference](/sandboxes/inference-routing) - [Profiles](/providers/profiles) - [LM Studio CLI](https://lmstudio.ai/docs/cli)