# Fitting a chat model and an image model on one iPhone

I wanted an AI assistant I could use without my conversations living on someone else's server, and one that kept working on a plane. So I built one for the iPhone. Here's what it took to get a chat model and an image model living in the same app.

## The chat model

Anvil runs Gemma 4 E2B through LiteRT LM. The same model handles questions about photos and documents. That turned out to be one of the most useful features: point the camera at a sign or a menu in another language and ask what it says, with no signal at all.

## The image model

Anvil Dream uses an SDXL Lightning model converted to Core ML with Apple's ml stable diffusion tools, running on the Neural Engine. Lightning only needs a few steps, so it makes 1024x1024 images right on the phone, as many as you want, even in airplane mode.

## Making them share memory

An iPhone doesn't have room for both models at once, so they are never loaded at the same time. The app unloads one before loading the other. It's a simple rule, and it's the reason everything fits. It's also why Anvil requires an iPhone 15 Pro or newer.

## Keeping the app small

The models aren't bundled. They download inside the app over WiFi after install, so the app itself stays small and people choose when to spend the storage.

## What stays on the phone

Chat, voice, notes, tasks, photo questions and image generation all run locally. There's no account. Web search and iCloud backup are optional and are the only parts that go online.

## The honest tradeoffs

The models are a download of several GB, and a model small enough for a phone has real limits next to the giant cloud models. For a lot of everyday things, though, having it private and always available wins.

## Try it

Version 4.1 is on public TestFlight, and beta testers get Anvil Pro free: https://testflight.apple.com/join/s8UAwXBm

If you've shipped other models on iOS, I'd love to hear what worked for you in the comments.
