# How to Use Apple's fm CLI to Run On-Device LLMs From Python

DevFeed: [How to Use Apple's fm CLI to Run On-Device LLMs From Python](<https://devfeed.tech/articles/how-to-use-apple-s-fm-cli-to-run-on-device-llms-from-python-129387.md>)

Original publisher: [Read original article](<https://towardsdatascience.com/how-to-use-apples-fm-cli-to-run-on-device-llms-from-python/>)

Author: Irfan Alghani Khalid

Published: 2026-11-11T13:30:00Z

Content type: tutorial

Language: en

Sources: [Towards Data Science](<https://devfeed.tech/sources/towards-data-science.md>)

Topics: [On-device AI](<https://devfeed.tech/topics/on-device-ai.md>), [Local AI](<https://devfeed.tech/topics/local-ai.md>), [Python](<https://devfeed.tech/topics/python.md>), [Machine learning](<https://devfeed.tech/topics/machine-learning.md>)

Tags: [ai-engineer](<https://devfeed.tech/tags/ai-engineer.md>), [apple](<https://devfeed.tech/tags/apple.md>), [artificial-intelligence](<https://devfeed.tech/tags/artificial-intelligence.md>), [cli](<https://devfeed.tech/tags/cli.md>), [device](<https://devfeed.tech/tags/device.md>), [free](<https://devfeed.tech/tags/free.md>), [grounding](<https://devfeed.tech/tags/grounding.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [large-language-models](<https://devfeed.tech/tags/large-language-models.md>), [llms](<https://devfeed.tech/tags/llms.md>), [local-llm](<https://devfeed.tech/tags/local-llm.md>), [on-device](<https://devfeed.tech/tags/on-device.md>), [private](<https://devfeed.tech/tags/private.md>), [prototyping](<https://devfeed.tech/tags/prototyping.md>), [python](<https://devfeed.tech/tags/python.md>), [software-engineer](<https://devfeed.tech/tags/software-engineer.md>), [validation](<https://devfeed.tech/tags/validation.md>), [vision](<https://devfeed.tech/tags/vision.md>)

## AI overview

Apple's `fm` CLI runs compact Foundation Models locally on Apple Silicon, offering private, no-token-cost inference without network round-trips. The article tests text and image use: the model answered "Ipoh" to a Malaysia capital question and labeled grilled satay as fried, showing why outputs need grounding and validation, especially when they inform decisions. For local prototyping, `fm serve` exposes an OpenAI-compatible endpoint at `http://127.0.0.1:1976/v1`; applications can also invoke `fm respond` through Python's `subprocess`. The server path suits code already using the OpenAI SDK, while subprocess fits a single-machine prototype. Prompts need re-testing when switching to a hosted model, and the workflow assumes Apple Silicon. Native Apple apps intended for users should use the Swift Foundation Models framework. The article recommends hosted models for shared cross-platform backends, long documents, or strong factual accuracy.

## Source excerpt

A Sate Padang vision test and a Malaysia capital question show why the free, private model needs grounding and validation before it leaves prototyping. The post How to Use Apple's fm CLI to Run On-Device LLMs From Python appeared first on Towards Data Science.