The serve mode and the OpenAI protocol

A Local Coding Agent with apfel

A series on building a coding agent in Swift whose language model runs entirely on your own Mac — from the apfel CLI to Xcode integration via MCP.

Every Apple Silicon Mac running macOS 26 (Tahoe) ships with a Foundation Model that is currently used only by Siri and a few system functions. apfel exposes this model as a CLI and as an OpenAI-compatible server. This series builds a Swift coding agent on top of it: a Plan/Act/Observe loop, tool calling, MCP integration, a Hummingbird server, and integration with Xcode 26.3 via the Model Context Protocol. No API key, no cloud endpoint, no token bill — but no cloud pace either: two critical interludes (Article 6 and Article 11) take a close look at what the small on-device model can handle and what platform dependency the local route entails. Code lives openly on Codeberg, with a tag per article to follow along. Twelve articles plus a prologue.

  1. 0

    The Model Is Already There — A Prologue to the Local Coding Agent

    A series takes a close look at the Foundation Model every Apple Silicon Mac running macOS 26 ships with — and builds on it a coding agent in Swift that runs locally.
    2. Jun 2026
  2. 1

    apfel from the command line

    We install apfel, walk through the three modes (prompt, serve, chat), and see where the on-device model holds up and where it gives way — Article 1 of the series "A Local Coding Agent with apfel".
    3. Jun 2026
  3. 2

    The serve mode and the OpenAI protocol

    We start apfel as a local OpenAI-compatible server, walk through every endpoint and see where the protocol diverges from OpenAI — Article 2 of the series "A Local Coding Agent with apfel".
    3. Jun 2026