afm

afm is a skill for Claude Code, Codex from scouzi1966/maclocal-api. It costs 114 tokens per session (1,270 once invoked), scanned A, original, MIT.

A maintenance guide for AFM, a Swift server and command-line tool that provides an OpenAI-compatible interface to Apple Foundation Models, MLX models, local model gateways, and vision OCR.

In plain words
What is it for?
It is used when changing AFM commands, chat-completion or model endpoints, server integrations, MLX behavior, gateway proxying, vision OCR, or related tests.
Why use it?
It gives development work on this server a defined place to handle command routing, API compatibility, streaming, tool calls, gateway behavior, and image-text extraction.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/scouzi1966/maclocal-api/afm
Any agent
npx skills add scouzi1966/maclocal-api --skill afm
Clone the repo
git clone --depth 1 https://github.com/scouzi1966/maclocal-api

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for afm

README.md
[![agentmods](https://agentmods.dev/badge/skills/scouzi1966/maclocal-api/afm.svg)](https://agentmods.dev/skills/scouzi1966/maclocal-api/afm)
Your own site
<a href="https://agentmods.dev/skills/scouzi1966/maclocal-api/afm"><img src="https://agentmods.dev/badge/skills/scouzi1966/maclocal-api/afm.svg" alt="Measured on agentmods" height="20"></a>
Per session 114 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,270 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00114 $0.01270
Opus 5 $0.00057 $0.00635
Sonnet 5 $0.00023 $0.00254
Haiku 4.5 $0.00011 $0.00127

Measured 4d ago against content hash 70898fea1355, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

afm scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- `curl http://127.0.0.1:9999/health`
skills/afm/SKILL.md · 120 lines

How it starts

The opening of the file, as written. The whole thing — 120 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AFM Skill

AFM (maclocal-api) is a local OpenAI-compatible API server and CLI for:

  • Apple Foundation Models (afm)
  • MLX models from Hugging Face (afm mlx)
  • Local backend gateway/proxy mode (afm -g)
  • Vision OCR/table extraction (afm vision)

1. Overview and Triggers

Use this skill when working on:

  • CLI flags, argument dispatch, or mode routing (afm, afm mlx, afm vision)
  • OpenAI-compatible routes (/v1/chat/completions, /v1/models)
  • Streaming SSE behavior and response compatibility
  • MLX tool calling, parser overrides, reasoning extraction, structured outputs
  • Gateway backend discovery/proxying (Ollama, LM Studio, Jan, local OpenAI endpoints)
  • Vision OCR and table extraction
  • AFMKit provider integration, build scripts, regression tests

2. Key File Reference

Purpose File Path
CLI modes, flags, single-prompt and stdin behavior Sources/MacLocalAPI/main.swift
Vision command Sources/MacLocalAPI/VisionCommand.swift
Vapor server + route registration Sources/MacLocalAPI/Server.swift
Foundation chat completions controller Sources/MacLocalAPI/Controllers/ChatCompletionsController.swift
MLX chat completions controller Sources/MacLocalAPI/Controllers/MLXChatCompletionsController.swift
Foundation model service Sources/MacLocalAPI/Models/FoundationModelService.swift
MLX model service Sources/MacLocalAPI/Models/MLXModelService.swift
OpenAI request schema Sources/MacLocalAPI/Models/OpenAIRequest.swift
OpenAI response schema Sources/MacLocalAPI/Models/OpenAIResponse.swift
Backend discovery Sources/MacLocalAPI/Services/BackendDiscoveryService.swift
Backend proxying Sources/MacLocalAPI/Services/BackendProxyService.swift
Backend definitions/capabilities Sources/MacLocalAPI/Models/BackendConfiguration.swift
Provider boundary check Scripts/check-afmkit-consumer-boundary.sh
Full bootstrap build Scripts/build-from-scratch.sh

Read the full file on GitHub · 120 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 120 lines · 114 tokens per session scan A 70898fea1355

Subscribe to this mod's changes

afm is a skill published in the GitHub repository scouzi1966/maclocal-api (334 stars, last pushed 4d ago), licensed MIT. It adds 114 tokens to every session and 1,270 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.