> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prismml.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LM Studio

> Run and serve Ternary Bonsai 27B locally with LM Studio on Apple Silicon.

[LM Studio](https://lmstudio.ai) is a desktop app for running local models, with a bundled `lms` CLI and an OpenAI-compatible HTTP server. It's the fastest way to get Bonsai running on a Mac — and because it serves `/v1/chat/completions`, the same instance doubles as the backend for any OpenAI-compatible client or agent.

<Warning>
  LM Studio support is **MLX only**. Use [`prism-ml/Ternary-Bonsai-27B-mlx-2bit`](https://huggingface.co/prism-ml/Ternary-Bonsai-27B-mlx-2bit), which requires an **Apple Silicon Mac** (M-series).
</Warning>

## Requirements

|                 |                                                                   |
| --------------- | ----------------------------------------------------------------- |
| Hardware        | Apple Silicon Mac (M1 or newer)                                   |
| Memory          | 16 GB unified memory minimum; 24 GB+ recommended for long context |
| Weights on disk | \~8.52 GB                                                         |

Weights are \~8.52 GB, but KV cache grows with context length and concurrency — budget headroom above the weight footprint.

## Step 1: Install LM Studio

Download the macOS build from [lmstudio.ai](https://lmstudio.ai/download).

## Step 2: Download the model

<CodeGroup>
  ```text Desktop app theme={null}
  Discover (magnifying glass) → search "Ternary-Bonsai-27B-mlx-2bit"
  → select "Ternary-Bonsai-27B-mlx-2bit" → Download
  ```
</CodeGroup>

## Step 3: Load and chat

<Steps>
  <Step title="Load the model">
    Pick it from the model selector at the top of the app's Chat tab. Set context length in the load panel; start at 32K–64K and raise it once you've seen memory pressure at your workload.
  </Step>

  <Step title="Chat">
    Go the Chat tab from the panel, and select the 'Ternary-Bonsai-27B-mlx-2bit' at top.
  </Step>
</Steps>

## Step 4: Serve the model

The same install exposes an OpenAI-compatible server, so LM Studio can act as the Bonsai endpoint for external tools.

<CodeGroup>
  ```text Desktop app theme={null}
  Developer tab → toggle "Status: Running"
  # Base URL: http://localhost:1234/v1
  ```
</CodeGroup>

Available endpoints: `GET /v1/models`, `POST /v1/chat/completions`, `POST /v1/completions`, `POST /v1/embeddings`, `POST /v1/responses`.

Don't hardcode the model ID — read it back from the server:

```bash theme={null}
curl http://localhost:1234/v1/models
```

Then call it:

```bash theme={null}
curl http://localhost:1234/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "prism-ml/ternary-bonsai-27b-mlx-2bit",
    "messages": [{"role": "user", "content": "Summarize this repo in three bullets."}],
    "temperature": 0.9
  }'
```

Authentication is off by default and the server binds to localhost. To reach it from another machine, enable network serving in the Developer tab and put it behind a reverse proxy with auth — don't expose it directly.

<Tip>
  Anywhere our docs ask for an OpenAI-compatible Bonsai endpoint, `http://localhost:1234/v1` works. For [Hermes](/integrations/hermes), substitute it for the demo-repo base URL in Step 1 and use any non-empty string as the API key.
</Tip>
