You are probably here because someone asked you to put a local model into an Apple app. This file is the contract: what this package is, what it will and will not do, and the mistakes that make an agent’s Core AI code fail on a real device. Read it before writing Swift, whether you are working inside this repo or adding it to someone else’s app.
Core AI is Apple’s on-device inference runtime (iOS/macOS 27, .aimodel bundles).
CoreAIKit is a community Swift package on top of it — model download and cache, a pinned
catalog of converted models, and task-level APIs. It is not affiliated with Apple.
KitLanguageModel puts a catalog model behind Apple’s
own LanguageModelSession, so tool calling and @Generable guided generation work over a
third-party model.Task ops — the result in one line, model resolved and cached behind the call:
import CoreAIOps
let text = try await CoreAI.transcribe(voiceMemoURL) // Whisper v3 turbo
let tldr = try await CoreAI.summarize(text)
let pii = try await CoreAI.redact(text) // GLiNER2
Model level — pick the model, stream, attach tools:
import CoreAIKit
let chat = try await ChatSession(catalog: "qwen3.5-2b")
for try await event in chat.streamResponse(to: "Hello!") {
if case .response(let delta) = event { print(delta, terminator: "") }
}
Importing CoreAIOps re-exports the model layer, so one import covers both.
catalog.json holds 53 entries, each {id, kind, name, repo, revision, variants}. Ids look
like qwen3-0.6b, qwen3.5-2b, youtu-llm-2b, lfm2.5-1.2b — lowercase, hyphenated.
catalog.json, or call ModelCatalog at runtime. A
hallucinated id is a runtime failure the user sees, and model naming here does not follow
Hugging Face naming.main to pick up a newer model — the pin is what was gated. Bumping one is a deliberate,
reviewed change (scripts/pin-catalog.py --check is what CI enforces).Most Core AI code an agent writes compiles and then fails in one of these ways:
os_proc_available_memory(), request com.apple.developer.kernel.increased-memory-limit,
and treat a 4B-class model on a phone as tight rather than routine.kind in the catalog.
A chat model is not a VLM; an ASR model is not a diarizer.Do not describe these models as “verified” without saying what was verified:
cos ≥ 0.999
otherwise), then re-gated after compression, then run on hardware.models/<model>/recipe.toml), the export script, and the verification script
are all published — python3 conversion/zoo_verify.py <hf-repo> re-checks a published bundle’s
tokenizer, chat template, context length and declared precision against its source model
without a GPU or a device.If a user is deciding whether to ship on this, tell them that accurately rather than either overselling it or waving them off.
Ask the human:
apple/*.If you were handed this repository to build the designed-but-unbuilt work, start at
docs/HANDOFF.md — it indexes every design document, gives the build order,
and lists the preconditions that must be resolved on hardware before the code they gate is
written.
docs/COOKBOOK.md — every “I want to …” mapped to its snippet.Examples/ — one buildable app per capability; start from the closest one.AGENTS.md for porting a
new model rather than consuming one.