Apple's Core AI Models: Export Recipes, Python Primitives, and Swift Runtime for On-Device AI
Explore Apple's open-source toolkit for exporting, authoring, and running on-device AI models with Core AI, including Python primitives, Swift utilities, and agent skills.
Apple has open-sourced Core AI Models, a comprehensive toolkit designed to streamline the entire lifecycle of on-device AI development. This repository provides model export recipes, reusable Python primitives, a Swift runtime package, and even agent skills for coding assistants. If you're building AI features for macOS or iOS and want to leverage Apple Silicon efficiently, this is the toolkit you've been waiting for.
What's Inside the Repository?
The repo is organized into four main directories, each serving a distinct purpose in the on-device AI workflow:
models/: A curated catalog of popular open-source models (from Hugging Face and elsewhere) with export recipes to convert them into Core AI's.aimodelformat.python/: Python primitives and utilities for authoring custom Core AI models in PyTorch, plus export scripts.swift/: A Swift package (coreai-models) that provides runtime utilities for integrating Core AI models into your macOS and iOS apps.skills/: Pluggable skills for coding agents (Claude Code, Codex CLI, Gemini CLI) that help them use Core AI effectively.
Why This Matters for On-Device AI
Running AI models on-device offers significant advantages: lower latency, offline capability, and enhanced privacy since data never leaves the device. However, the path from a PyTorch model to a deployable on-device model has been fragmented. Apple's Core AI framework provides the runtime, but developers needed tooling to bridge the gap. This repository fills that gap with:
- Standardized export recipes that handle model conversion, including tokenizer bundling for LLMs and multi-model pipelines for diffusion models.
- Python building blocks that abstract away common patterns like KV cache management, precision rules, and MoE layer handling.
- Swift runtime utilities that simplify loading, configuring, and running models in your app.
Getting Started: Exporting a Model
First, install uv if you haven't already:
brew install uv
# or
curl -LsSf https://astral.sh/uv/install.sh | sh
Clone the repository and list available models:
git clone https://github.com/apple/coreai-models.git
cd coreai-models
uv run coreai.model.registry --list-models
Each model in the models/ folder has its own README.md with specific export instructions. For example, exporting an LLM typically produces a resource folder containing one or more .aimodel files plus a tokenizer. The Swift package then knows how to load these resources at runtime.
Authoring Custom Models with Python Primitives
If you need to create a custom model architecture, the python/ directory provides reusable primitives built on PyTorch. These primitives enforce best practices for on-device execution on Apple platforms, including:
- BC1S layout (batch, channel, 1, spatial) for optimal memory access patterns.
- Op compatibility with Core AI's supported operations.
- KV cache patterns for efficient autoregressive generation.
- Precision rules (e.g., FP16, INT8 quantization) to balance performance and accuracy.
- MoE (Mixture of Experts) support with sparse computation patterns.
The coreai-torch library handles the actual export, while coreai-opt provides compression exploration tools (quantization, palettization) to shrink model size without catastrophic quality loss.
Integrating Models into Your App with Swift
The Swift package (coreai-models) is the runtime counterpart. It provides:
- Model loading utilities that handle the
.aimodelformat and resource bundles. - Inference runners for different model types (LLMs, diffusion models, etc.).
- Performance instrumentation to monitor latency and logits output (as seen in recent commits adding VLM support).
Requirements: macOS and iOS 27.0+, Xcode 27.0+. The package is available via Swift Package Manager.
Agent Skills: Supercharge Your Coding Workflow
One of the most innovative aspects of this repo is the inclusion of agent skills. These are plugins that teach coding assistants (like Claude Code, Codex CLI, or Gemini CLI) how to work with Core AI. Three skills are available:
- working-with-coreai: End-to-end workflow for deploying PyTorch models on Apple Silicon, covering export with
coreai-torchand runtime integration. - model-authoring: Empirical rules for authoring PyTorch models for on-device execution, covering layout, op compatibility, KV cache, precision, MoE, and common pitfalls.
- model-compression-exploration: Systematically explore weight compression configurations (quantization and palettization) using
coreai-opt.
To install for Claude Code:
/plugin marketplace add [email protected]:apple/coreai-models.git
/plugin install coreai-skills@coreai-models
For Codex CLI:
codex plugin marketplace add https://github.com/apple/coreai-models
codex
# Then use /plugins in the interactive browser to install coreai-skills
For Gemini CLI:
gemini extensions install /path/to/coreai-models/skills
Once installed, the skills activate automatically based on your task context, or you can invoke them explicitly.
Current Limitations and Community Engagement
Apple is not accepting code contributions at this time. The project is focused on maintaining a curated, well-tested gallery. However, GitHub Issues are open for:
- Bug reports for Python scripts or Swift utilities.
- Model requests for new models or workflow improvements.
This is a deliberate scope decision to ensure quality and stability.
Conclusion
Apple's Core AI Models repository is a significant step toward making on-device AI development accessible and efficient. By providing export recipes, Python primitives, a Swift runtime, and even agent skills, Apple has created a cohesive ecosystem that reduces friction from model selection to app integration. Whether you're a mobile developer looking to add on-device LLM capabilities or a researcher exploring compression techniques, this toolkit deserves your attention.
Check out the repository on GitHub and start experimenting with on-device AI today.