Apple-native APIs

Vision, Speech, and NaturalLanguage through HTTP.

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

CapabilityMain-server routesBackend
VisionPOST /v1/vision/ocrApple Vision
Speech/v1/audio/transcriptions, /v1/audio/speech, /v1/audio/voicesApple Speech and voices
EmbeddingsPOST /v1/embeddingsNLContextualEmbedding

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}'
OptionBehavior
recognition_levelaccurate or fast
languagesRecognition-language hints
uses_language_correctionEnable Vision language correction
max_pagesLimit PDF work
tableRequest document table extraction
debugInclude 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.aac

The 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 IDScope
apple-nl-contextual-enEnglish contextual embeddings
apple-nl-contextual-multiLatin-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.