Use LM Studio in Apple Mail
MailTwin can write and rewrite email in Apple Mail using a model served
from your own Mac. LM Studio, llama.cpp’s llama-server
and oMLX all expose the OpenAI chat API, and MailTwin talks to them
through one provider: Local (OpenAI-compatible). For Ollama’s
own provider, see the Ollama guide.
The wider picture is in the provider guide.
What you need
- A Mac running macOS 13 or later.
- MailTwin installed, with Apple Mail set up as usual.
- LM Studio installed, with a model downloaded. A recent 7–14B instruct model is a sensible size for email replies on most Apple Silicon Macs.
Setup with LM Studio
- Load a model and start the local server in LM Studio. LM Studio’s server feature is in its Developer view; check LM Studio’s own documentation for the current menu names. Note the address it shows. LM Studio’s usual port is 1234, so the address is typically
http://127.0.0.1:1234(MailTwin’s source comments name 1234 as LM Studio’s port; confirm the one your install shows). If you enable authentication in LM Studio, copy the token. - Open the provider settings. In MailTwin, right-click the menubar icon, choose Settings, then AI and Providers, and open the Local (OpenAI-compatible) card.
- Enter the address. In Server URL, type the LM Studio address, with or without
/v1on the end:http://127.0.0.1:1234andhttp://127.0.0.1:1234/v1both work. The field’s default ishttp://127.0.0.1:8000, which is oMLX’s port, so change it. - Add a key only if the server asks for one. The API key (optional) field is stored in the macOS Keychain. MailTwin sends it as an
Authorization: Bearerheader, and only when the field is not empty. Leave it blank otherwise. - Choose the model. Open Advanced and look at Model. The default is
auto, which uses the first model id the server lists at/v1/models. That is the model already loaded on a single-model server. To pin a model, type its id exactly as the server lists it. - Save and test. Click Save & Test (Save stores the key without testing). The status should read Ready.
- Make it the active provider. Click Make active (hidden when Local (OpenAI-compatible) is already active).
llama.cpp (llama-server) and oMLX
These use the same card and the same steps; only the address differs. MailTwin’s source names the default ports as 8000 for oMLX and 8080 for llama.cpp’s server, and the Server URL field accepts whichever port you run.
- llama.cpp: start
llama-serverwith a model, for examplellama-server -m your-model.gguf --port 8080, and keep it bound to the local machine. Enterhttp://127.0.0.1:8080. Check the llama.cpp documentation for the flags your build supports. - oMLX: start the server and enter its address; the default
http://127.0.0.1:8000already matches the field’s default. If you started it with an API key, enter that key in API key (optional). MailTwin’s key field was built with oMLX’s--api-keyoption in mind. - mlx-serve and similar servers are named in MailTwin’s own help text and work the same way.
Ollama through its OpenAI-compatible endpoint
The same provider accepts Ollama’s own /v1 endpoint:
enter http://127.0.0.1:11434/v1 as the Server URL. Unlike the dedicated Local (Ollama) card, this route lets you type any model id under Advanced → Model.
How to check it is working
- The provider status reads Ready. MailTwin gets this by asking the server for its model list (
/v1/models) and checking that it lists a model. Withautoany non-empty list is enough. With a typed model id, that id must be on the list. No email text is involved in this check. - In Apple Mail, select a message, press ⌘⇧M to open the MailTwin panel, type a few keywords and generate a reply. The server’s own request log should show a call to
/v1/chat/completions. - This provider streams, so text can appear as the model produces it.
Troubleshooting
“No local server answered. Start your OpenAI-compatible server (oMLX, LM Studio, llama.cpp…), then check the server address in Settings → AI → Providers.”
Nothing is listening at the address. Either the server is not running, or the port is wrong. The most common cause is leaving the default 8000 in place for a server on 1234 or 8080.
“The local server answered, but not with an OpenAI-style model list.”
Something answered at that address, but the response to /v1/models was not an OpenAI-style list. Point the address at the server’s API itself, for example http://127.0.0.1:8000 or …/v1, and not at a web page or another service.
“For privacy, Local (OpenAI-compatible) only connects to this Mac. Use localhost, 127.0.0.1, or ::1 as the server address.”
MailTwin refuses any other host before it builds a request. The rules: scheme http or https; host localhost, 127.0.0.1 or ::1; no username or password, query or fragment; and a path of nothing, /, /v1 or /v1/. A LAN address, a hostname for another machine, or a path such as /api is rejected.
“The local server is running but lists no models. Load a model in the server, then check again.”
The server answered with an empty model list. Load a model in the server, then run Save & Test again.
“The local server is running, but it does not list the model ‘…’.”
You typed a model id that the server does not list. Load that model, type an id from the server’s list, or set the model back to auto.
“The local server rejected the request. It needs an API key, or the stored key is wrong.”
The server replied with HTTP 401 or 403. Enter the server’s key in API key (optional) and save.
What runs where
With a local server, the model runs in LM Studio, llama.cpp or oMLX on your Mac. When you ask for a reply, MailTwin sends the request, including the email text needed for that action, to the address in Server URL. The code accepts only a loopback address for this provider, does not follow redirects, and checks the address before building the request, so a non-loopback value never receives email text. No MailTwin server is involved in the AI request: MailTwin has no AI proxy.
This describes the AI request only. It does not cover what the server software itself does, such as downloading models.
Frequently asked
Can I use LM Studio with Apple Mail?
Yes. Start LM Studio’s local server, choose Local (OpenAI-compatible) in MailTwin under Settings → AI → Providers, and enter the server address. MailTwin generates replies from its panel beside Apple Mail.
Which local servers work?
Any server on the same Mac that speaks the OpenAI chat API: LM Studio, llama.cpp’s llama-server, oMLX, mlx-serve, or Ollama’s /v1 endpoint.
What does the model setting auto mean?
auto, the default, uses the first model id the server lists at /v1/models. To pick a specific model, type its id under Advanced → Model.
Trial
The 30-day trial covers this provider. Get MailTwin. For the other providers, see the provider guide.