SwiftAI  by mi12labs

Swift library for building LLM apps on iOS and macOS

Created 3 months ago
274 stars

Top 94.4% on SourcePulse

GitHubView on GitHub
Project Summary

A modern, type-safe Swift library for building AI-powered applications on iOS and macOS. SwiftAI provides a unified API that abstracts away complexities of integrating with various AI models, from Apple's on-device capabilities to cloud-based services like OpenAI, enabling developers to build robust LLM features efficiently.

How It Works

SwiftAI employs a model-agnostic design, offering a single interface to interact with diverse AI backends including Apple's on-device models, OpenAI, MLX, and custom solutions. Its core innovation lies in strongly-typed, structured output generation with compile-time validation, ensuring data integrity. The library leverages modern Swift concurrency (async/await) for asynchronous operations, supports real-time streaming responses, and provides first-class features for agent tool use and stateful chat conversations.

Quick Start & Requirements

  • Installation: Swift Package Manager. Add https://github.com/mi12labs/SwiftAI to your project.
  • Prerequisites: Standard Swift development environment. For the MLX backend, additional dependencies (SwiftAIMLX, MLXLLM) are required.
  • Links: SwiftAI GitHub

Highlighted Details

  • Model Agnostic API: Seamlessly switch between on-device (SystemLLM, MLX) and cloud (OpenAI) models without code changes.
  • Type-Safe Structured Output: Define Swift structs that the AI can generate directly, with compile-time validation.
  • Streaming API: Supports real-time, progressive generation of text and structured data.
  • Agent Tool Loop: First-class integration for AI to call external tools and functions.
  • Conversations: Stateful chat sessions with automatic context management.
  • MLX Backend (Experimental): Integrates local LLMs via Apple's MLX framework.

Maintenance & Community

The project is developed for the Swift community with a link to contributing guidelines. Specific details on active maintainers, community channels (like Discord/Slack), or a public roadmap are not detailed in the README.

Licensing & Compatibility

Released under the MIT License, permitting broad use, modification, and distribution, including for commercial purposes.

Limitations & Caveats

SwiftAI is currently in Alpha status, indicating potential for rough edges and breaking changes. Structured output generation is not yet supported when using the experimental MLX backend.

Health Check
Last Commit

1 month ago

Responsiveness

Inactive

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

Explore Similar Projects

Feedback? Help us improve.