https://github.com/nathanborror/swift-mlx-kit
An easy way to use the Apple MLX framework in Swift.
https://github.com/nathanborror/swift-mlx-kit
Last synced: about 2 months ago
JSON representation
An easy way to use the Apple MLX framework in Swift.
- Host: GitHub
- URL: https://github.com/nathanborror/swift-mlx-kit
- Owner: nathanborror
- License: mit
- Created: 2025-02-20T06:47:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-17T22:36:39.000Z (about 1 year ago)
- Last Synced: 2025-04-18T12:24:20.996Z (about 1 year ago)
- Language: Swift
- Size: 2.52 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Swift MLXKit
An unofficial Swift client library for interacting with [Apple's MLX framework](https://opensource.apple.com/projects/mlx).
## Requirements
- Swift 6+
- iOS 17+
- macOS 15+
## Installation
Add the following to your `Package.swift` file:
```swift
Package(
dependencies: [
.package(url: "https://github.com/nathanborror/swift-mlx-kit", branch: "main"),
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "MLXKit", package: "swift-mlx-kit"),
]
),
]
)
```
## Usage
### Chat Completion
```swift
import OpenAI
let client = Client()
let req = ChatRequest(
messages: [.init(role: .user, content: "Hello, OpenAI!")],
model: "mlx-community/Llama-3.2-1B-Instruct-4bit"
)
do {
let response = try await client.chatCompletions(request)
print(response)
} catch {
print(error)
}
```