Free AI inside your iPhone app: Apple's on-device Foundation Models, the way Settl does it
The short version
Apple ships a language model on newer iPhones that your own app can call from code. It runs on the phone, works offline, and Apple's own words are that the inference "is free of cost". So a feature like "say an expense, get a filled form" needs no API key, no per-call bill and no server of yours.
This guide is how my app Settl uses it for voice expenses: the Swift bridge from Flutter, the one cap that keeps it fast (80 tokens), the guided-generation schema that makes the model fill your fields directly, the early stop at 4 fields, and the cloud fallback for the sentences it cannot parse.
| What | The short answer | Where it comes from |
|---|---|---|
| Cost per call | $0. Apple: "AI inference that is free of cost" | Apple Newsroom, 29 Sep 2025 |
| Where it runs | On the phone: "generated entirely on device" | Apple Newsroom |
| Offline | Yes: "available offline" | Apple Newsroom |
| Which phones | Devices that support Apple Intelligence (iPhone 15 Pro and Pro Max, iPhone 16 models or later, iPhone Air) | Apple Support 121115 |
| How you call it | Swift, the FoundationModels framework |
developer.apple.com/documentation/foundationmodels |
| Output you control | Guided generation: the model fills your own Swift struct | Apple docs |
| Settl's cap | maximumResponseTokens: 80, greedy, temperature 0 |
OnDeviceLLM.swift |
| Early stop | Break out of the stream once intent, amount, title and payer are decoded | OnDeviceLLM.swift |
| Fallback | cascade: on-device first, cloud only for unclear or incomplete parses (the client default) |
config_service.dart |
Checklist
- Target iOS 26+ and gate the call:
#if canImport(FoundationModels)plus@available(iOS 26.0, *). - Check availability before you call it. People without an Apple Intelligence device must still get a working path.
- Describe your output as a
@Generablestruct, with a@Guideon every field. - Set
GenerationOptionsexplicitly: greedy sampling, temperature 0, a smallmaximumResponseTokens. - Stream the response and stop as soon as the required fields are filled.
- Keep a cloud fallback for low-confidence or incomplete results, and keep it off the happy path.
- Never log the user's words. They stay on the phone; keep it that way.
Copy these prompts
Paste them into Claude Code (or any AI that can see your project).
1. Could this feature run on the phone?
Look at the features in my iOS app that call a cloud LLM today. For each one, tell me whether it could run on Apple's on-device Foundation Models instead: is the task short (parse, classify, extract, summarise a few lines), does it need world knowledge or long context, and what would break if the model were small. Rank them by how much cloud cost and latency I would remove. Do not change any code yet.
2. Design the guided-generation schema
I want the on-device model to turn this input into a structured result: <describe the input and the fields you need>. Write the Swift: a @Generable struct with a @Guide on every field (description plus .range or .anyOf constraints where the values are a fixed set), and the GenerationOptions with greedy sampling, temperature 0 and the smallest maximumResponseTokens that still fits a full result. Explain each constraint in one line.
3. Add the early stop
In my streaming call to the on-device model, find the point where the fields my app actually needs are all decoded (name them). Add an early commit: as soon as those fields are present in the partial result, take the value and break out of the stream instead of waiting for the full response. Keep the optional fields optional.
4. Wire the cloud fallback
Add a parser strategy with three modes: on-device only, cloud only, and cascade (on-device first, cloud only when the on-device result is missing required fields or has low confidence). Make cascade the default. Show me the Flutter side (a MethodChannel to the Swift bridge) and what the app does when the device does not support Apple Intelligence.
If you are building…
…in Flutter. Keep the model in Swift and talk to it over a MethodChannel. Settl's channel is settl/on_device_llm. Dart sends the transcript, Swift returns the parsed fields as JSON, and the rest of the app does not know where the answer came from.
The schema is the contract. Settl's struct names the fields the app reads (title, amount, currency, category, split mode, payer, members). Constraints do the validation for you: .anyOf for fixed lists such as currency codes and categories, .range for the amount, .maximumCount on the members list.
Why 80 tokens. A typical parsed result is a short JSON object. A hard cap keeps the model quick and stops a rambling answer from ever happening. Pick yours by measuring a full-fill result for your own schema, then add a little headroom.
Why greedy and temperature 0. The same sentence gives the same parse every time. That makes results testable, and it makes caching safe.
The early stop. Stream the response. The partial result fills in field by field. When the required fields are all there, commit and leave the stream. The tail of the output is never generated, which is free speed.
The fallback. On-device first. Only when the parse is unclear or incomplete does the request go to a cloud model. Most sentences never leave the phone.
Run this on your codebase
Audit my app for on-device AI. Tell me (1) which of my cloud LLM calls are short structured-output tasks that Apple's Foundation Models could take over, (2) which iOS versions and devices my users are on, so I know how many could use it, (3) where my app would need a cloud fallback, and (4) the smallest first feature I could move on-device with a @Generable struct. Give me a plan, not code.
Sources: Apple Newsroom "Apple's Foundation Models framework unlocks new intelligent app experiences" (29 Sep 2025), developer.apple.com/documentation/foundationmodels, Apple Support 121115, and Settl's own code. Settl is the example here, not the pitch.