기본 콘텐츠로 건너뛰기

Apple Foundation Models: Use Claude, Gemini or MLX in Swift

Summary: In the OS 27 betas, Apple's Foundation Models framework stopped being "the on-device model API" and became a general LLM API: anything that conforms to the LanguageModel protocol can be passed to LanguageModelSession. That means one Swift code path can talk to the on-device Apple model, Apple's Private Cloud Compute model, Claude, Gemini, a local MLX model, or any chat-completions server. This walkthrough shows the exact packages and one-line swaps for each, and what actually changes when you leave the on-device model.

What changed, in one paragraph

When the framework shipped with OS 26, a session meant Apple's on-device model, full stop. Apple's developer page now describes it as "a native Swift API for integrating any large language model into your app." The mechanism is the LanguageModel protocol (iOS, iPadOS, macOS, tvOS, visionOS and watchOS 27.0+). A provider writes a light type that declares capabilities plus an executor that translates framework types for its backend, and distributes it as a Swift package. Your app code stays the same: create a session with a model, call respond(to:) or streamResponse(to:), and keep your tools, instructions and @Generable types. Apple's own two models, SystemLanguageModel and PrivateCloudComputeLanguageModel, are simply the first two conforming types.

Before you start

  • Xcode 27 beta and the OS 27 SDK. Every third-party bridge below requires them; the Claude package also lists watchOS 27 and visionOS 27, while Firebase's initial release supports iOS and macOS only.
  • A device that supports Apple Intelligence if you want Apple's models. Third-party server models do not depend on Apple Intelligence, which is one practical reason to add one as a fallback.
  • Beta expectations. The Claude package is labeled beta (0.1.x), the Firebase integration is a Preview with no SLA, and Apple's utilities package is at 1.0.0-beta6. Pin versions.

Step 1: Start from the on-device baseline

Write your feature against the plain on-device session first. It costs nothing per call, works offline and has no usage cap, so it is the right place to get prompts, tools and guided generation working:

import FoundationModels

let session = LanguageModelSession()
let response = try await session.respond(to: "Summarize this note in two lines: ...")
print(response.content)

Apple's own guidance on its Private Cloud Compute page is the same order: start on-device, measure with the Evaluations framework, and only move up when the feature needs more reasoning or context. If you already test prompts outside Xcode, the idea carries over from our Promptfoo tutorial: decide what "good enough" means before switching models.

Step 2: Swap in Private Cloud Compute (one line)

The documented swap is literally the initializer argument:

let session = LanguageModelSession(model: PrivateCloudComputeLanguageModel())

What you get, per Apple's comparison table: 32K context instead of 4K, and reasoning levels (.light, .moderate, .deep via ContextOptions) where the on-device model has none. What you give up: offline use, and unlimited calls, because each person gets a daily request limit. Three things to wire in:

  1. Availability. Switch on model.availability; handle .deviceNotEligible and .systemNotReady with an alternative UI.
  2. Network failure. Apple suggests retrying on the on-device model when the request fails for lack of a connection.
  3. Quota UI. Use model.quotaUsage to show "nearing limit" states, and catch quotaLimitReached. Xcode's scheme options can simulate both the approaching and reached states, so you can test this without burning real requests.

Developing with PCC needs a managed entitlement (com.apple.developer.private-cloud-compute) that you request from Apple. Apple's developer page says developers in the App Store Small Business Program with fewer than two million first-time App Store downloads can use the PCC model with no cloud API cost, and notes that expanded access will carry a fee in the future.

A small router that keeps the on-device model as the default looks like this (our sketch, built only from the documented calls above):

func makeSession(needsLongContext: Bool) -> LanguageModelSession {
    if needsLongContext, #available(iOS 27.0, macOS 27.0, *) {
        let pcc = PrivateCloudComputeLanguageModel()
        if case .available = pcc.availability {
            return LanguageModelSession(model: pcc)
        }
    }
    return LanguageModelSession()   // on-device default
}

Step 3: Add Claude with Anthropic's package

Anthropic publishes ClaudeForFoundationModels on GitHub. Add it with Swift Package Manager (https://github.com/anthropics/ClaudeForFoundationModels.git, from 0.1.0), import it next to FoundationModels, and pass a ClaudeLanguageModel to the session. Its quick start creates the model with a name such as .sonnet5 and an auth: value, then calls session.respond(to:) exactly as before.

Two details worth knowing before you ship:

  • Reasoning maps to effort. The framework's .light, .moderate and .deep become Claude effort low, medium and high; a level a model does not accept is dropped, not rejected. You can pin one with fixedEffort:.
  • Fallbacks. fallbacks: accepts up to three models that the API retries in order if the requested model declines a request in a policy area. A response can even switch models midway; the transcript entry records the handover.

The package documents several auth: modes. Usage bills to your Anthropic workspace.

Step 4: Add Gemini through Firebase AI Logic

Google's route is the Firebase Apple SDK (at least version 12.19.0), adding the FirebaseAILogic and FirebaseAppCheck libraries. After the usual Firebase project setup, the model line is:

let ai = FirebaseAI.firebaseAI(backend: .googleAI())
let model = ai.geminiLanguageModel(name: "gemini-3.8-flash")
let session = LanguageModelSession(model: model)

The supported list covers general models (gemini-4-hydrogen, gemini-4-argon, gemini-4-carbon, gemini-3.8-flash, gemini-3.5-flash-lite) and Nano Banana image models; Live API models are not supported. Firebase's guide enforces App Check from the start, including during development. If you are weighing Carbon for the heavy lifting, our Gemini 4 Carbon pricing breakdown covers what it costs per call.

Step 5: Run an open model locally with MLX

The mlx-swift-lm package now ships MLXFoundationModels, a bridge that builds an MLXLanguageModel you pass to LanguageModelSession. The README example loads a Gemma 3 1B 4-bit configuration with #huggingFaceLanguageModel(configuration:capabilities:) and requests a @Generable struct; output is grammar-constrained to the schema through MLXGuidedGeneration. The key difference from server models: you declare capabilities (.guidedGeneration, .vision, .toolCalling, .reasoning), so the framework only uses what you claim the model supports. For the trade-offs of local weights versus an API in general, see Inkling 2 Small: run it locally or via API.

Step 6: Point at any chat-completions server

Apple's open-source foundation-models-utilities package adds ChatCompletionsLanguageModel, which takes a model name and a base URL (its example uses http://localhost:8000/v1). Set supportsGuidedGeneration: false when your server cannot do structured output. This is also how you reach a gateway: put a proxy like the one in our LiteLLM tutorial in front, and a single Swift model type can reach every backend the proxy knows about. The same package adds history-trimming profile modifiers (drop completed tool calls, rolling window, summarize) and a just-in-time Skills type.

Comparison: which model type to pass

Model type Runs where Offline Context / reasoning Cost basis Status (Nov 14)
SystemLanguageModel On device Yes 4K, no reasoning No per-call cost, unlimited Shipping
PrivateCloudComputeLanguageModel Apple PCC No 32K, light/moderate/deep Daily per-person limit; no cloud API cost for eligible Small Business Program devs OS 27, entitlement required
ClaudeLanguageModel Anthropic API No Per model; effort levels Billed to your Anthropic workspace Beta 0.1.x
geminiLanguageModel (Firebase) Gemini API No Per model; thinking level Your Firebase project (Developer API can start at no cost) Preview
MLXLanguageModel On device, open weights Yes, after download Capabilities you declare Device compute only 27.0 SDK
ChatCompletionsLanguageModel Any compatible server If server is local Depends on server Whoever runs the server 1.0.0-beta6

What really changes when you leave the on-device model

The API stays the same, but behavior does not, and that is where bugs hide:

  • Prompt size. A prompt tuned to fit 4K will not break on bigger models, but a prompt written for a 32K or larger model will fail on-device. If you fall back, keep a shorter prompt variant.
  • Feature parity is declared, not guaranteed. Each bridge decides what it supports. Guided generation may be off for a local server, and a Claude schema or image needs every model in a fallback chain to support it.
  • Reasoning is a hint. The on-device model ignores reasoning levels; Claude maps them to effort and drops unsupported ones.
  • Switching mid-conversation. Dynamic Profiles let one session swap model, temperature, reasoning level and tools while sharing the transcript, so you do not need two sessions to escalate a hard question.
  • Testing on the Simulator. Some auth paths need real hardware (see the note below), so plan device testing earlier than you would for the on-device model.

Editor's note

Good fit: iOS/macOS developers who already use LanguageModelSession and want a bigger model for a few hard tasks without a second SDK in their feature code. Not a fit yet: anything that must ship on OS 26 or earlier, or needs a stable API this month; every third-party bridge here is beta or preview.

Common errors and fixes we found in the docs:

  • ClaudeError.attestationUnsupported on the Simulator: the Claude package's App Attest mode needs a physical device with a Secure Enclave; its README describes a separate mode for Simulator iteration.
  • Gemini requests rejected during development: Firebase's guide enforces App Check from setup, so configure the App Check debug provider as the guide describes before you test.
  • .unavailable(.deviceNotEligible) from PCC: the device or region does not support Apple Intelligence; show an alternative UI or route to a third-party model.
  • quotaLimitReached: the person used their daily PCC allowance; it is not a rate limit, so retrying in a few seconds will not help.
  • Structured output errors from a local server: set supportsGuidedGeneration: false on ChatCompletionsLanguageModel.

Gotcha: the MLX README example carries @available(iOS 26.0, ...) on the @Generable struct but wraps the session in #available(iOS 27.0, ...). Your types can stay OS 26-compatible; only the model swap needs 27.

FAQ

Do I need to rewrite my existing Foundation Models code?

No. Sessions, tools, instructions and @Generable types carry over. You change the model passed to LanguageModelSession(model:) and add availability, network and quota handling for server models.

Is the Private Cloud Compute model free?

For people using your app, it comes with a daily limit, and they can upgrade iCloud+ for more. For developers, Apple says Small Business Program members under two million first-time downloads pay no cloud API cost, and that expanded access will carry a fee in the future.

Can I use an OpenAI-compatible or self-hosted model?

Yes, through ChatCompletionsLanguageModel in Apple's utilities package, which works with any server that speaks the chat-completions API, including a local one.

Build on-device first, escalate one feature at a time, and let the protocol keep your code path single.

See the official screenshots and our comparison table at the end of this post. Image credits: screenshots of Apple Developer, Firebase documentation and the ClaudeForFoundationModels GitHub README; comparison table by lightmind24.

lightmind24 is an independent review site, not affiliated with Apple, Anthropic or Google.

Last verified: 2026-11-14

Sources:
Apple: Foundation Models framework
Apple docs: LanguageModel protocol
Apple docs: Adding server-side intelligence with Private Cloud Compute
WWDC26: Bring an LLM provider to the Foundation Models framework
GitHub: anthropics/ClaudeForFoundationModels
Firebase: Access the Gemini API through Apple's Foundation Models framework
GitHub: ml-explore/mlx-swift-lm
GitHub: apple/foundation-models-utilities

Uploaded Image Uploaded Image Uploaded Image Uploaded Image Uploaded Image

댓글

이 블로그의 인기 게시물

브루(Vrew) 요금제 정리: 무료 200크레딧으로 어디까지 쓸 수 있나

요약: 영상 자막 편집기 브루(Vrew)는 2026년 4월 22일부터 기능별 사용량 대신 '통합 크레딧' 하나로 요금을 매겨요. 무료 플랜은 매달 200크레딧이 들어오는데, 음성 분석(자동 자막)만 쓰면 최대 200분 분량이라 짧은 영상 몇 편은 충분하지만, 영상 초반의 Vrew 마크를 지우려면 유료 플랜이 필요해요. 이 글은 브루 공식 가격 페이지와 고객센터 공지를 2026년 10월 23일에 다시 확인해, 크레딧 계산법과 플랜 고르는 기준을 정리했어요. 목차 브루 요금 구조: 통합 크레딧이란 1크레딧으로 할 수 있는 일 무료 플랜으로 되는 것과 안 되는 것 유료 플랜 4종 비교표 월 구독·연 구독·기간 이용권, 무엇이 이득일까 상황별 추천: 학생·직장인·유튜버 크레딧이 모자랄 때: 사용 기록 지우개 업그레이드·환불 전에 알아둘 규칙 운영자 메모, 자주 묻는 질문 1. 브루 요금 구조: 통합 크레딧이란 예전 브루는 플랜마다 음성 분석 몇 분, AI 목소리 몇 자, 번역 몇 자처럼 기능별 한도를 따로 줬어요. 그런데 보이저엑스(브루 운영사)가 실제 이용 데이터를 보니 한두 가지 기능만 집중해서 쓰는 사람이 훨씬 많았다고 해요. 그래서 2026년 4월 22일 업데이트부터는 플랜마다 정해진 크레딧을 받고, 어떤 기능에 쓸지는 내가 정하는 방식으로 바뀌었어요. 플랜별 매달 지급량은 Free 200 · Light 2,000 · Standard 10,000 · Business 12,000크레딧 이에요. 공식 공지에 따르면 무료 사용자는 매달 1일에, 유료 사용자는 매월 결제일에 충전되고, 남은 크레딧은 다음 달로 넘어가지 않아요. 바뀐 뒤 무엇이 좋아졌나 공지에 나온 예시가 이해하기 쉬워요. Standard 플랜에서 AI 목소리만 쓰면 예전에는 최대 50만 자였지만, 지금은 1만 크레딧을 모두 AI 목소리에 몰아 쓸 수 있어 최대 100만 자가 돼요. 반대로 여러 기능을 골고루 쓰는 사람은 크레딧이 기능끼리 ...

에이닷 전화 vs 익시오: 통화 녹음·AI 요약, 내 통신사·폰에 맞는 앱 고르기

요약: 통화 녹음과 AI 요약을 쓰고 싶다면 먼저 내 통신사와 휴대폰 종류부터 확인해야 해요. LG유플러스 고객은 무료 앱 익시오, SKT 고객은 에이닷 전화가 가장 기능이 많고, 다른 통신사의 아이폰 사용자는 iOS에 들어 있는 기본 통화 녹음·전사 기능이 현실적인 선택이에요. 이 글은 2026-10-30에 SKT·LG유플러스·Apple 공식 페이지와 도움말을 직접 확인해 세 가지를 비교했어요. 왜 '앱 기능'보다 '내 조건'을 먼저 봐야 할까요 통화 요약 앱 비교 글을 보면 기능 목록부터 나열하는 경우가 많아요. 그런데 실제로 써 보려는 사람에게 가장 먼저 걸리는 건 기능이 아니라 이용 조건 이에요. 익시오는 LG유플러스 고객 전용이고, 에이닷 전화는 누구나 설치할 수 있지만 통역콜·baro 같은 기능은 SKT 고객에게만 열려 있어요. 아이폰은 운영체제 구조상 앱이 통화를 마음대로 녹음하기 어려워서, 통신사 앱이 안 되면 iOS 기본 기능에 기대야 해요. 그래서 이 글은 "어떤 앱이 제일 좋은가"보다 "내 통신사·내 폰에서 무엇을 쓸 수 있나" 순서로 정리했어요. 기능 차이는 그다음이에요. 한눈에 비교: 에이닷 전화 vs 익시오 vs 아이폰 기본 통화 녹음 구분 에이닷 전화 (SKT) 익시오 ixi-O (LG유플러스) 아이폰 기본 통화 녹음 (Apple) 누가 쓸 수 있나 통신사 구분 없이 앱 설치 가능. 단, 통역콜·baro·그룹통화 발신 등은 SKT 고객 전용 U+ 모바일 고객. 타 통신사, 만 14세 미만, 선불요금제 고객은 제한 (공식 사이트 FAQ상 알뜰폰 중 KB리브엠은 예외) 지원 국가·언어의 iPhone 사용자. 1명과 통화할 때만 녹음 가능 지원 OS·기기 Android 10 이상, iOS 16 이상 iOS 17 이상 iPhone 12 이상 / Android...

타입캐스트 vs 클로바더빙: 수익 나는 채널에 쓸 때 무료·유료 조건 비교

요약 타입캐스트와 클로바더빙은 둘 다 글만 입력하면 한국어 AI 목소리를 만들어 주는 서비스지만, 무료로 쓸 수 있는 범위가 꽤 다릅니다. 클로바더빙 무료는 매달 15,000자까지 쓸 수 있는 대신 수익이 생기는 채널에는 쓸 수 없고, 타입캐스트 무료는 처음에 주는 약 5분 분량의 다운로드로 끝나는 체험판에 가깝습니다. 광고 수익이 붙은 유튜브나 쇼핑몰 영상에 넣을 목소리라면 처음부터 유료 플랜 조건을 보고 고르는 편이 안전합니다. 왜 이 두 서비스를 같이 비교하나 쇼츠 내레이션, 수업 자료 더빙, 상품 소개 영상처럼 "내 목소리 대신 AI 목소리"가 필요할 때 한국 사용자들이 가장 많이 찾는 곳이 네오사피엔스의 타입캐스트 와 네이버의 클로바더빙 입니다. 기능 소개만 보면 비슷해 보이지만, 실제로 문제가 되는 건 음질보다 "이 목소리를 내 채널에 써도 되나" 입니다. 그래서 이 글은 기능 나열보다 무료 사용 범위, 출처 표기 의무, 유료 플랜 가격과 다운로드 한도를 중심으로 정리했습니다. 모든 수치는 2026년 10월 25일에 두 서비스의 공식 요금 페이지와 고객센터 도움말에서 직접 다시 확인한 내용입니다. 한눈에 보는 비교표 항목 타입캐스트 무료 타입캐스트 베이직 클로바더빙 Free 클로바더빙 Standard 월 요금 0원 9,900원 (연간 결제 시 10% 할인) 0원 19,900원 (네이버 클라우드 플랫폼에서 결제) 무료·포함 사용량 음성 생성·재생 무제한, 다운로드는 최초 3,000크레딧(약 5분) 1회 지급 월 30,000크레딧(약 60분) 월 15,000자, 다운로드 월 20회, 프로젝트 누적 5개 (매월 1일 갱신) 월 30,000자, 다운로드 월 40회, 프로젝트 누적 20개 쓸 수 있...