apfel exposes the on-device language model that ships with Apple Intelligence, through Apple's FoundationModels framework, as a UNIX command-line tool and a local OpenAI-compatible server. Inference happens entirely on the Mac, with no API key and no cloud call. It requires macOS 26 Tahoe or later on Apple Silicon with Apple Intelligence enabled.
As a command-line tool it takes a prompt as an argument or on standard input, attaches one or more files — including PDFs and images, with on-device text extraction and optical character recognition — streams output, emits JSON or schema-constrained JSON, returns bare code with no prose for piping, and sets exit codes for scripting. A chat flag opens an interactive read-eval-print loop, and a serve flag starts the HTTP server at http://localhost:11434/v1, optionally as a background service.
The server implements chat completions and the Responses API with streaming, tool calling, JSON-object and JSON-schema response formats, a models endpoint, and a health endpoint reporting model availability, context window, and languages. Unsupported OpenAI surfaces answer explicitly: legacy text completions and embeddings return 501, and rejected parameters such as logprobs, multiple completions, or image input return 400.
Model Context Protocol servers attach in command-line, chat, and server modes, as local scripts or remote Streamable HTTP endpoints with bearer-token authentication, and a calculator server is bundled. Sample shell scripts that wrap the tool — English to shell command, one-liners, narration, explanation, naming, port lookup, and git summaries — are written out with a demos subcommand.
Known limits: a single model of around 3B parameters with no configuration; a context window covering input and output together of 4,096 tokens on macOS 26 and 8,192 on macOS 27, read at runtime rather than hardcoded; no embeddings and no vision; responses that take seconds rather than milliseconds; Apple's guardrails, which can block benign prompts and are relaxed by a permissive flag; and no clock or network access, so the current date must be injected through a system prompt.
Features
- Pipe-friendly CLI: prompt as an argument or on standard input, with quiet mode and exit codes for scripts
- File attachments: text, source, PDF, and image files with on-device extraction and optical character recognition
- Structured output: a JSON output mode for scripting and a schema flag for guaranteed schema-conforming generation
- Code mode: returns code alone, with no prose or markdown fences
- OpenAI-compatible server: a drop-in local backend at http://localhost:11434/v1 for OpenAI SDKs
- Responses API: string and message input, instructions, streaming events, and function tools
- Tool calling: available from the command line, the chat loop, and the server
- MCP support: local script servers and remote Streamable HTTP servers, with token authentication
- Multi-turn input: a conversation passed in as JSON returns the next assistant turn
- Token preflight: a token-count flag checks a prompt against the live context budget
- Server security: bearer tokens from an environment variable, refusal of tokens over plaintext HTTP, and opt-in CORS
- Bundled demos: ready-made shell wrappers written out to a directory of your choice
