# Claude for Foundation Models

> Swift package that lets Apple apps use Claude as a server-side language model through the Foundation Models framework.

Claude for Foundation Models is a Swift package from Anthropic that conforms Claude to Apple's Foundation Models `LanguageModel` protocol. Developers drive Claude with the same `LanguageModelSession` API they use for Apple's on-device model, including `respond(to:)`, streaming, guided generation, and tool calling. The README labels it a beta that targets the server-side language model API introduced in the OS 27 betas, so APIs may change before general availability.

## What It Is

The package is a provider integration for Apple's Foundation Models framework, not a general-purpose Anthropic Messages API client. Its public surface is `ClaudeLanguageModel`, `ClaudeModel`, `AuthMode`, and `ClaudeServerTool`. An app creates a `ClaudeLanguageModel` with a model name and credential, passes it to a `LanguageModelSession`, and uses the session as it would with any other Foundation Models provider.

## Model Selection and Behavior

Models are chosen with compiled-in `ClaudeModel` constants that mirror API model IDs, or with a custom ID plus explicitly declared capabilities. Each model declares the sampling parameters, effort levels, thinking, structured output, and image input it accepts, and the bridge uses this to decide which request fields to send. A fixed effort level can be pinned per model, and the framework's reasoning levels map to Claude effort levels. Up to three fallback models can be named, so a request that a model declines in certain policy areas is retried on the next model within the same request.

## Authentication Options

There are three modes. App Attest registers the app in the Anthropic console, so each install proves it is a genuine copy and the app ships no key. API keys are intended for simulator development. A proxied mode routes requests through the developer's own backend, which adds the credential server-side. An optional user profile ID can attribute requests to individual end users.

## Streaming, Structured Output and Server Tools

Streaming returns cumulative snapshots. Types annotated with `@Generable` can be requested through `generating:` for structured output. Server-side tools (web search, web fetch, and code execution) run on Anthropic's infrastructure within a single round trip and are configured per model, with domain filters and usage limits for search and fetch. Tool activity appears in transcript entries so apps can render it inline. Provider errors that do not map to Foundation Models errors surface as `ClaudeError`.

## Setup Path

It is added through Swift Package Manager or Xcode and requires iOS, macOS, visionOS, or watchOS 27 (beta) and Xcode 27 (beta). A runnable command-line example streams a chat turn to the terminal and can enable web search. The package is licensed under Apache 2.0, and the README says it is maintained on a best-effort basis and does not accept external contributions.

## Features
- Conforms Claude to Apple's Foundation Models LanguageModel protocol
- Works with LanguageModelSession respond(to:)
- Streaming responses as cumulative snapshots
- Structured output with @Generable types
- Client-side tool calling via the framework
- Server-side tools: web search, web fetch, code execution
- Fixed effort levels and reasoning-level mapping
- Fallback models for declined requests
- App Attest, API key, and proxied authentication
- User profile attribution for requests
- Custom model IDs with declared capabilities
- ClaudeError error handling

## Integrations
Apple Foundation Models, Swift Package Manager, Xcode, Anthropic console, App Attest

## Platforms
MACOS, IOS, API, DEVELOPER_SDK, CLI

## Pricing
Open Source

## Version
0.2.3

## Links
- Website: https://github.com/anthropics/ClaudeForFoundationModels
- Documentation: https://github.com/anthropics/ClaudeForFoundationModels
- Repository: https://github.com/anthropics/ClaudeForFoundationModels
- EveryDev.ai: https://www.everydev.ai/tools/claude-for-foundation-models
