whatisgithub

What is apple-foundation-models-ruby-sdk?

afomera/apple-foundation-models-ruby-sdk — explained in plain English

Analysis updated 2026-05-18

22RubyAudience · developerComplexity · 3/5LicenseSetup · moderate

In one sentence

A Ruby library that lets your programs use Apple's on-device AI model from Apple Intelligence, running fully locally with no API key or server needed.

Mindmap

mindmap
  root((repo))
    What it does
      Ruby port of Apple SDK
      On-device AI sessions
      No data leaves device
    Tech stack
      Ruby
      Swift
      FFI
    Use cases
      Chat sessions
      Structured output
      Tool calling
    Audience
      Developers
      Mac users
    Setup
      macOS 26 plus
      Xcode required

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add a private, offline AI chat session to a Ruby application.

USE CASE 2

Get structured data back from the model by defining a typed Ruby class.

USE CASE 3

Let the model call your own Ruby tools during a conversation.

What is it built with?

RubySwiftFFI

How does it compare?

afomera/apple-foundation-models-ruby-sdkdawarich-app/atlasjacksonpires/rails-realtime-erd
Stars222121
LanguageRubyRubyRuby
Setup difficultymoderatehardeasy
Complexity3/54/52/5
Audiencedeveloperops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires macOS 26+ with Apple Intelligence enabled and a full Xcode install, not just Command Line Tools.

Apache-2.0 license: use freely for any purpose, including commercial use, as long as you keep the copyright and license notices.

So what is it?

This library lets Ruby programs use Apple's on-device AI model, which Apple ships as part of Apple Intelligence on recent Macs. Because the model runs on the device, no data is sent to any server and no API key is needed. The library is a port of Apple's own Python SDK and connects to the same underlying Swift code through Ruby's FFI interface. To use it, you need a Mac running macOS 26.0 or later with Apple Intelligence enabled, a full Xcode installation (the lighter Command Line Tools are not enough), and Ruby 3.1 or newer. You add the gem to your Gemfile, run bundle install, and a small Swift package compiles during setup. The main interaction is a session: you create one, optionally give it system instructions, and then call respond with a text prompt. The model returns either the full response at once or a streaming sequence of partial results you can print as they arrive. You can attach images to prompts for the model to describe or analyze, and you can set options like temperature and response length. For structured output, you define a Ruby class with typed properties and optional constraints, such as allowed values, numeric ranges, or required array lengths. Passing the class to respond tells the model to fill in those fields and return an instance. Tools work in a similar way: you write a class with a name, a description, and a typed arguments structure, and the model calls it during generation when it decides the tool is relevant. Other features include exporting conversation history as JSON and resuming a session from a saved transcript, cancelling requests with a timeout, and an optional Fiber-based async layer that lets multiple sessions run concurrently. Errors are organized into named subclasses for common failure modes like guardrail violations and rate limits. The project is Apache-2.0 licensed.

Copy-paste prompts

Prompt 1
Help me set up this gem on a Mac with Apple Intelligence enabled, including the Swift package build.
Prompt 2
Show me how to define a typed Ruby class to get structured output from a session.
Prompt 3
Explain how to attach an image to a prompt and stream the model's response.
Prompt 4
Walk me through writing a tool class the model can call during generation.

Frequently asked questions

What is apple-foundation-models-ruby-sdk?

A Ruby library that lets your programs use Apple's on-device AI model from Apple Intelligence, running fully locally with no API key or server needed.

What language is apple-foundation-models-ruby-sdk written in?

Mainly Ruby. The stack also includes Ruby, Swift, FFI.

What license does apple-foundation-models-ruby-sdk use?

Apache-2.0 license: use freely for any purpose, including commercial use, as long as you keep the copyright and license notices.

How hard is apple-foundation-models-ruby-sdk to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is apple-foundation-models-ruby-sdk for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.