ClaudeForFoundationModels  by anthropics

Claude LLM integration for Apple's Foundation Models

Created 3 months ago
259 stars

Top 97.8% on SourcePulse

GitHubView on GitHub
Project Summary

This package integrates Anthropic's Claude models into Apple's Foundation Models framework, enabling developers on Apple platforms to leverage powerful LLM capabilities. It allows seamless use of Claude via the familiar LanguageModelSession API, supporting advanced features like streaming, guided generation, and server-side tool execution, thereby simplifying LLM integration in native applications.

How It Works

The core mechanism involves conforming Claude to Apple's LanguageModel protocol. Developers instantiate ClaudeLanguageModel with authentication and model details, then pass it to LanguageModelSession. This abstraction layer ensures that Claude's responses, streaming, structured output, and tool-calling functionalities are accessible through the unified Foundation Models interface, mirroring the experience of using Apple's on-device models.

Quick Start & Requirements

  • Installation: Swift Package Manager (Package.swift or Xcode).
  • Prerequisites: iOS 27, macOS 27, visionOS 27 (beta OS releases); Xcode 27 (beta). Requires an Anthropic API key for development.
  • Setup: Minimal setup; run example commands provided.
  • Links: https://github.com/anthropics/ClaudeForFoundationModels.git

Highlighted Details

  • Model Abstraction: Uses ClaudeModel constants (e.g., .sonnet5, .opus4_8) that encapsulate model capabilities, ensuring API compatibility. Dateless IDs represent pinned model snapshots.
  • Feature Parity: Supports streaming responses, structured output generation via @Generable structs, and configurable server-side tools (web search, code execution).
  • Effort Control: Allows fine-grained control over Claude's reasoning effort (low to max) via the fixedEffort parameter, mapping to Foundation Models' reasoning levels.
  • Authentication Flexibility: Offers .apiKey for development and .proxied for production, requiring a backend relay to manage credentials server-side.

Maintenance & Community

  • Status: Maintained on a best-effort basis, provided "as is".
  • Contributions: External contributions are not accepted.
  • Feedback: Bug reports and feedback are welcomed via GitHub issues.

Licensing & Compatibility

  • License: Apache 2.0.
  • Compatibility: Permissive license suitable for commercial use and integration into closed-source applications.

Limitations & Caveats

  • Beta Software: Targets beta OS releases (27+); APIs are subject to change before general availability.
  • Platform Dependency: Requires specific beta versions of Apple operating systems and Xcode.
  • Production Authentication: Current production authentication requires a self-hosted backend relay; a simpler, native solution is planned.
Health Check
Last Commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
1 stars in the last 30 days

Explore Similar Projects

Starred by John Resig John Resig(Author of jQuery; Chief Software Architect at Khan Academy), Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm), and
2 more.

mcp-server-cloudflare by cloudflare

0%
4k
MCP servers for LLM integration with Cloudflare services
Created 1 year ago
Updated 2 weeks ago
Feedback? Help us improve.