Self-hosting

Use local AI models

Run every model Oatmilk uses on your own hardware with Ollama, LM Studio, vLLM or llama.cpp.

15 minutes · Intermediate

Oatmilk uses AI models to read statements, receipts and documents, to sort mail and match receipts, and for Ask AI. By default it calls hosted models through Vercel AI Gateway. Pointed at a model server on your own hardware instead, every one of those calls stays with you, nothing is billed, and no API key is needed.

This works with Ollama, LM Studio and any server that speaks the OpenAI chat completions API, such as vLLM, llama.cpp's llama-server and LocalAI.

What your computer needs

A rough guide to the memory the models need, on top of Oatmilk's own 4 GB:

SetupMemoryGood for
A 9B chat model and a 4B classifier16 GB, more is betterReal books on one computer
4B models8 GBTrying it out; slower and less accurate
0.8B models4 GBChecking that everything is connected, not real use
30B models and larger, on a GPU server32 GB of GPU memory or moreA team, faster and more accurate

A Mac with Apple silicon, or an NVIDIA GPU, makes answers much faster than a CPU alone.

Option 1: Ollama

Use Ollama 0.35 or newer, which adds decision models that answer Oatmilk's classifier questions with a confidence, as the hosted classifier does.

1. Install Ollama and pull the models

Shell
ollama pull qwen3.5:9b   # chat, tools, extraction and receipt images
ollama pull tev1         # classifiers: a decision model (nimble is larger and more accurate)

2. Start it with a longer context

Ollama loads models with a short context by default. Long statements and the agents need more:

Shell
OLLAMA_CONTEXT_LENGTH=32768 ollama serve

On Linux, Oatmilk's container reaches your computer through Docker's network, not 127.0.0.1, so Ollama must listen on every address:

Shell
OLLAMA_HOST=0.0.0.0 OLLAMA_CONTEXT_LENGTH=32768 ollama serve

With Ollama's systemd service, set both with sudo systemctl edit ollama instead. Docker Desktop on macOS and Windows reaches Ollama either way.

3. Point Oatmilk at it

In bun run self-host setup, choose Ollama on this computer, and keep qwen3.5:9b and tev1 as the models. Setup writes:

self-host/.env
OATMILK_MODEL_PROVIDER=ollama
OATMILK_LOCAL_BASE_URL=http://host.docker.internal:11434/v1
OATMILK_LOCAL_MODEL=qwen3.5:9b
OATMILK_LOCAL_CLASSIFIER_MODEL=tev1
OATMILK_LOCAL_CLASSIFIER_API=systemone

On an older Ollama, remove the last line, and the chat model answers the classifier questions too.

Option 2: LM Studio

  1. Download a model in LM Studio, for example Qwen3.5 9B (it reads images too) and, for classifiers, Qwen3.5 4B. Set each one's context length to 32768 or more when you load it.
  2. Open the Developer tab and start the server, or run lms server start. It listens on port 1234.
  3. On Linux, turn on Serve on Local Network in the server settings, so Oatmilk's container can reach it.
  4. In bun run self-host setup, choose LM Studio on this computer, with the model identifiers LM Studio shows.
self-host/.env
OATMILK_MODEL_PROVIDER=lmstudio
OATMILK_LOCAL_BASE_URL=http://host.docker.internal:1234/v1
OATMILK_LOCAL_MODEL=qwen/qwen3.5-9b
OATMILK_LOCAL_CLASSIFIER_MODEL=qwen/qwen3.5-4b
OATMILK_LOCAL_CLASSIFIER_API=chat

Option 3: vLLM, llama.cpp or another server

Any server with an OpenAI-compatible /v1 address works, on this computer or another one on your network. For example, vLLM on a GPU server:

Shell
vllm serve Qwen/Qwen3-8B --enable-auto-tool-choice --tool-call-parser hermes --max-model-len 32768

In setup, choose Another OpenAI-compatible server and give its address, ending in /v1, and the model's name. An address typed as localhost is pointed back at your computer from inside the container.

self-host/.env
OATMILK_MODEL_PROVIDER=openai-compatible
OATMILK_LOCAL_BASE_URL=http://192.168.1.50:8000/v1
OATMILK_LOCAL_MODEL=Qwen/Qwen3-8B
OATMILK_LOCAL_API_KEY=            # only if your server asks for one

Choose a model that supports tool calling and structured output, and start the server with tool calling turned on.

Change models later

From the terminal app, try a model on Oatmilk's own tasks before you switch to it:

Shell
oatmilk models pull gemma4:12b                                        # download it into Ollama
oatmilk models eval --only receipts --vision-model gemma4:12b         # check it first
oatmilk models use --vision-model gemma4:12b --restart                # switch, and restart Oatmilk

models use takes the same flags as setup: --model for chat and Ask AI, --vision-model for reading documents, --classifier-model and --classifier-api for classifiers, --embedding-model, and --models lmstudio to move to LM Studio. A model you don't name goes back to the one setup picks. It checks that every model is on the server before it changes anything; without --restart, Oatmilk uses the new models after oatmilk local restart. Run oatmilk models to see which model does each job now. Run Oatmilk on this computer has the rest of the models commands.

If you set Oatmilk up with bun run self-host setup instead, edit self-host/.env, then apply it:

Shell
bun run self-host up
bun run self-host doctor   # checks that the app container reaches the model server

Then check the new models with oatmilk models eval, naming them as above, since the terminal app didn't set them up.

Settings

SettingDefaultWhat it does
OATMILK_MODEL_PROVIDERgatewaygateway, ollama, lmstudio or openai-compatible
OATMILK_LOCAL_BASE_URLOllama's or LM Studio's usual addressThe server's /v1 address. Required for openai-compatible.
OATMILK_LOCAL_API_KEYnoneSent as a bearer token when set
OATMILK_LOCAL_MODELrequiredAnswers every chat, tool, extraction and review call
OATMILK_LOCAL_VISION_MODELthe chat modelUsed whenever a prompt has an image, a PDF page or another file
OATMILK_LOCAL_REASONINGeach call's ownCaps thinking: none, minimal, low, medium, high or xhigh. none answers fastest on a laptop.
OATMILK_LOCAL_CLASSIFIER_MODELthe chat modelAnswers classifier questions: document kinds, mail routing, receipt matches, categories
OATMILK_LOCAL_CLASSIFIER_APIchatsystemone for an Ollama decision model, chat to ask a chat model
OATMILK_LOCAL_CLASSIFIER_BASE_URLOATMILK_LOCAL_BASE_URLWhen classifiers run on another server, such as Ollama next to LM Studio
OATMILK_LOCAL_EMBEDDING_MODELnoneFor embeddings, for example nomic-embed-text
OATMILK_LOCAL_TRANSCRIPTION_MODELnoneVoice input in Ask AI, from a server with /audio/transcriptions such as a whisper.cpp server
OATMILK_LOCAL_TRANSCRIPTION_BASE_URLOATMILK_LOCAL_BASE_URLWhen transcription runs on another server
OATMILK_LOCAL_MODEL_MAPnonePins particular hosted model ids to particular local models, such as typesafe-ai/jev=qwen3:4b

An invalid setting stops Oatmilk at start-up with a message that names the setting to fix.

Classifiers and automatic matching

Oatmilk's classifiers answer typed questions with probabilities. An Ollama decision model (systemone) also reports a confidence for each answer, the way the hosted classifier does, so automatic steps such as matching a receipt to a bank line keep working: they still need 98% probability and 95% confidence.

A chat model (chat) gives its own estimate of the probabilities but no confidence. Every classifier still works, but steps that need confidence, such as automatic receipt matching, leave the decision to a person.

Which models to choose

RoleOllamaLM Studio
Chat, tools and extractionqwen3.5:9b (smaller: qwen3.5:4b, gemma4:e4b)qwen/qwen3.5-9b, google/gemma-4-e4b
Classifiersnimble or tev1, with systemoneqwen/qwen3.5-4b, with chat
Receipts and documents (vision)qwen3.5:9b, gemma4:12bqwen/qwen3.5-9b, google/gemma-4-12b
Embeddingsnomic-embed-textnomic-embed-text v1.5

Qwen3.5 and similar models think before they answer. On slow hardware, set OATMILK_LOCAL_REASONING=none.

Check your models

After you pick models, see if they're good enough for Oatmilk's own work:

Shell
oatmilk models eval

It gives your models the same tasks Oatmilk gives them, with the same instructions, on the books of a made-up company called Birch Labs. It never reads your real books and never calls the cloud. It takes a few minutes, and longer on a computer without a GPU. Press Ctrl+C to stop it; what finished is kept on screen.

TaskModelWhat it checksGood enough when
Sort chargesClassifiersPuts 12 bank and card charges in the right category, or asks you when it can't tell10/12 right, and at most 1 sure but wrong
Match receiptsClassifiersFinds the bank line that goes with each of 5 receipts, or says none does4/5 right, and none sure but wrong
Read receiptsReading documentsReads the store, date, total and currency off 4 receipt photos3/4 receipts all right
Ask AIChat and agentsAnswers 5 questions about the books by finding and using Oatmilk's tools4/5 right, and no made-up tools

"Sure but wrong" means the model was sure enough for Oatmilk to act without asking you, and it was wrong. Those mistakes go straight into your books, so the bar allows almost none. A made-up tool is one Oatmilk doesn't have.

Speed is a warning, never a failure. The check says "slow" when a charge takes more than about 2 seconds, a receipt more than about a minute, or Ask AI writes fewer than 5 tokens a second (a token is about three quarters of a word). The first answer of each model doesn't count, since it loads the model into memory.

Text
Checking Oatmilk's tasks on Ollama: qwen3.5:9b for chat and documents, tev1 for classifiers.

✓ Sort charges     11/12 right, none sure but wrong   0.3 s each
✓ Match receipts   5/5 right, none sure but wrong     0.6 s each
✓ Read receipts    4/4 right                          8.2 s each
✓ Ask AI           5/5 right                          21 tokens/s

Good enough for Oatmilk. Checked in 1 min 48 s.

It ends with code 0 when the models are good enough and 1 when they're not, so a script can use it. --json prints the whole report, --only receipts checks one task, and oatmilk models says when you last checked.

To try models before you switch to them, name them the way oatmilk models use does. Do the same when you set Oatmilk up with bun run self-host setup instead of the terminal app, since the check then doesn't know your models:

Shell
oatmilk models eval --only receipts --vision-model gemma4:12b
oatmilk models eval --models lmstudio --model qwen/qwen3.5-9b
oatmilk models eval --models ollama --model qwen3.5:9b --classifier-model tev1

When a task falls short

The check shows the worst mistake and the model to try instead, with the command that checks it:

Text
✗ Read receipts    2/4 right                          9.1 s each
  Worst: the Pine Street Hardware receipt: it read the total as 36.19, not 36.91.
  Try qwen3.5:9b: oatmilk models eval --only receipts --vision-model qwen3.5:9b

Not good enough to read receipts. Checked in 1 min 2 s.
  • Try the model it names. If it's already the one Oatmilk suggests, a larger model may do better.
  • On Ollama, start it with a long context, OLLAMA_CONTEXT_LENGTH=32768. Ask AI's instructions don't fit in Ollama's short default, and its answers suffer.
  • If a model stopped answering in time, give it more with --timeout 300, or try a smaller model.
  • Run it again after you change models, and before you trust them with real books.

Limits

  • Quality depends on the model. Run oatmilk models eval, then check a few real statements and receipts before you trust a model with your books.
  • Image generation isn't available locally, and voice input needs a transcription server.
  • Some agents look up their model's context window in a public catalog. If you run fully offline and an agent doesn't start, pin its model to a local one with OATMILK_LOCAL_MODEL_MAP and check bun run self-host logs app.

Without the Docker stack

The same settings work for bun run dev in .env.local. There, Oatmilk runs on your computer itself, so use http://localhost:11434/v1 (Ollama) or http://localhost:1234/v1 (LM Studio), which are also the defaults. See Develop Oatmilk locally.