macOS 27 ships a new `fm` command-line tool pre-installed on every Mac, and a pip-installable Python SDK, both giving scripting and data-science workflows direct access to the same on-device Apple Foundation Model used by the Swift Foundation Models Framework.
⢠Enables rapid prompt iteration from the terminal or a Jupyter Notebook without rebuilding an Xcode project, dramatically shortening the feedback loop.
⢠Python SDK integrates natively with the ML/data-science ecosystem (Pandas, scikit-learn, etc.), making it easy to build evaluation pipelines and quantify prompt quality before writing a line of Swift.
⢠The `fm` CLI can be dropped into shell scripts and CI automation to add LLM reasoning to file management, text extraction, and other workflows at zero API cost.
A shell script that uses `fm respond` with a structured JSON schema to classify files in a directory as draft or final, then moves them accordingly ā demonstrating how to call the on-device model from a Bash script on macOS 27.
#!/usr/bin/env bash
# Requires macOS 27+ with the fm CLI pre-installed.
# Usage: ./sort_assets.sh /path/to/assets /path/to/backup /path/to/archive
set -euo pipefail
WORKING_DIR="${1:?Usage: $0 <working_dir> <backup_dir> <archive_dir>}"
BACKUP_DIR="${2:?}"
ARCHIVE_DIR="${3:?}"
mkdir -p "$BACKUP_DIR" "$ARCHIVE_DIR"
# Build a newline-separated file list
FILE_LIST=$(ls "$WORKING_DIR")
# Define the structured output schema once
SCHEMA=$(fm schema object \
--property finalFiles array string \
--property draftFiles array string)
# Ask the on-device model to classify the files
RESULT=$(fm respond \
--schema "$SCHEMA" \
--prompt "You are a file organiser. Given this list of asset filenames, \
classify each as either a final deliverable or a draft/work-in-progress. \
Return two arrays: finalFiles and draftFiles.\n\nFiles:\n$FILE_LIST")
# Parse the JSON arrays produced by the model
FINAL_FILES=$(echo "$RESULT" | python3 -c \
"import sys,json; d=json.load(sys.stdin); print('\\n'.join(d['finalFiles']))")
DRAFT_FILES=$(echo "$RESULT" | python3 -c \
"import sys,json; d=json.load(sys.stdin); print('\\n'.join(d['draftFiles']))")
# Copy final files to backup
while IFS= read -r file; do
[[ -z "$file" ]] && continue
cp "$WORKING_DIR/$file" "$BACKUP_DIR/$file"
echo "Backed up final file: $file"
done <<< "$FINAL_FILES"
# Move draft files to archive
while IFS= read -r file; do
[[ -z "$file" ]] && continue
mv "$WORKING_DIR/$file" "$ARCHIVE_DIR/$file"
echo "Archived draft file: $file"
done <<< "$DRAFT_FILES"
echo "Done. Backup: $BACKUP_DIR | Archive: $ARCHIVE_DIR"The fm CLI and Python SDK are macOS-only ā they do not run on iOS devices. Python 3.10+ is required for the SDK. The Python SDK is installed via pip (`pip install foundation-models`) and requires Xcode to be present. Structured output schemas generated with `fm schema object` produce JSON that must be passed explicitly to `fm respond --schema`. Private Cloud Compute prompts via `--model large` count against usage limits.
Apple Silicon Mac required for both the CLI and Python SDK; on-device model always available, Private Cloud Compute model subject to usage limits
More iOS 27 APIs land every week.
Get notified when new capabilities are published ā no noise, just signal.