The main AFM server exposes Apple framework capabilities on port 9999 beside chat. Each route uses the same OpenAI-shaped error envelope and returns 503 when its OS capability is unavailable.
Surface
| Capability | Main-server routes | Backend |
|---|---|---|
| Vision | POST /v1/vision/ocr | Apple Vision |
| Speech | /v1/audio/transcriptions, /v1/audio/speech, /v1/audio/voices | Apple Speech and voices |
| Embeddings | POST /v1/embeddings | NLContextualEmbedding |
Vision OCR
The OCR endpoint accepts a local file reference, base64 bytes, a data URL, an OpenAI-style image_url, chat message parts, or a multipart upload. It can return recognized text, geometry, document pages, tables, barcodes, classification, saliency, and a combined text view.
# CLI: extract a table from a PDF
afm vision --file invoice.pdf --table
# HTTP: local file input
curl http://127.0.0.1:9999/v1/vision/ocr \
-H 'Content-Type: application/json' \
-d '{"file":"/absolute/path/invoice.pdf","table":true}'| Option | Behavior |
|---|---|
recognition_level | accurate or fast |
languages | Recognition-language hints |
uses_language_correction | Enable Vision language correction |
max_pages | Limit PDF work |
table | Request document table extraction |
debug | Include diagnostic hints |
Foundation-model chat can invoke OCR automatically only when the message contains image content, the built-in apple_vision_ocr tool is declared, and tool_choice permits it.
Speech
# Recognition
afm speech transcribe --file meeting.wav --format srt
# Synthesis
afm speech synthesize "Hello from AFM" --voice nova --output hello.aacThe transcription route supports plain text and structured formats such as JSON, SRT, and VTT. Synthesis uses installed Apple voices; query GET /v1/audio/voices for what the host provides.
Embeddings
The unified server lazy-loads Apple NaturalLanguage embeddings at /v1/embeddings. afm embed remains available as a dedicated embeddings-only server on port 9998.
curl http://127.0.0.1:9999/v1/embeddings \
-H 'Content-Type: application/json' \
-d '{
"model":"apple-nl-contextual-en",
"input":["local inference", "semantic search"],
"encoding_format":"float"
}'| Model ID | Scope |
|---|---|
apple-nl-contextual-en | English contextual embeddings |
apple-nl-contextual-multi | Latin-script multilingual contextual embeddings |
Input may be one string, an array of strings, or token-ID arrays. Output can be float or base64. If dimensions truncates the native vector, AFM L2-normalizes the result and sets the X-Embedding-Truncated response header.