# apfel

> A free, open-source CLI tool that unlocks Apple's on-device LLM on macOS 26+ as a terminal command, OpenAI-compatible HTTP server, and interactive chat.

apfel is a free, open-source Swift CLI tool that exposes Apple's built-in on-device language model (shipped with macOS 26 Tahoe via the FoundationModels framework) as a UNIX command-line tool, an OpenAI-compatible HTTP server, and an interactive multi-turn chat. It runs 100% on-device using Apple Silicon's Neural Engine and GPU — no API keys, no subscriptions, no data leaving your machine. Built with Swift 6.3 and licensed under MIT, apfel bridges Apple's raw `LanguageModelSession` API with practical developer tooling.

- **CLI / UNIX Tool** — *Pipe-friendly with stdin/stdout, JSON output (`-o json`), file attachments, and proper exit codes; composable with `jq`, `xargs`, and shell scripts.*
- **OpenAI-Compatible Server** — *Starts a local HTTP server at `localhost:11434`; supports `POST /v1/chat/completions`, streaming (SSE), tool/function calling, `response_format: json_object`, CORS, and standard parameters like `temperature` and `max_tokens`.*
- **Interactive Chat** — *Multi-turn conversations with automatic context management and five trimming strategies to handle the 4,096-token context window.*
- **Zero Cost** — *No per-token billing, no API keys required; the model is already installed on your Mac as part of Apple Intelligence.*
- **100% On-Device Privacy** — *All inference runs locally on the Neural Engine and GPU; nothing is sent to external servers.*
- **Power Shell Scripts** — *Bundled demo scripts include `cmd` (natural language to shell command), `oneliner` (pipe chains from English), `explain`, `wtd`, `gitsum`, and `mac-narrator`.*
- **Drop-in OpenAI Replacement** — *Any OpenAI SDK or framework can point to `http://localhost:11434/v1` and work without code changes.*
- **Install via Homebrew** — *Run `brew install Arthur-Ficial/tap/apfel` then `apfel "Hello, Mac!"` to get started in seconds; or build from source with `git clone` and `make install`.*

## Features
- CLI UNIX tool with stdin/stdout and JSON output
- OpenAI-compatible HTTP server at localhost:11434
- Interactive multi-turn chat with context management
- Five context trimming strategies for 4,096-token window
- Streaming (SSE) support
- Tool/function calling
- File attachments
- CORS support for browser clients
- 100% on-device inference via Apple Neural Engine
- Zero cost — no API keys or subscriptions
- Bundled demo shell scripts (cmd, oneliner, explain, wtd, gitsum, mac-narrator)
- MIT open-source license
- Homebrew installation

## Integrations
OpenAI Python SDK, OpenAI-compatible clients, Homebrew, jq, curl, Shell scripts

## Platforms
MACOS, CLI, API

## Pricing
Open Source

## Version
0.6.13

## Links
- Website: https://apfel.franzai.com
- Documentation: https://github.com/Arthur-Ficial/apfel/blob/main/docs/EXAMPLES.md
- Repository: https://github.com/Arthur-Ficial/apfel
- EveryDev.ai: https://www.everydev.ai/tools/apfel
