This guide covers only the simplest steps to run an LLM on your device. For a detailed, step-by-step explanation of how everything works, see the full integration guide.
1
Create a new SwiftUI project

2
Add the SDK
Add this package through SPM:
Copy
https://github.com/trymirai/uzu-swift.git
4
Paste the snippet
Go to
ContentView.swift and add this snippet:Don’t forget to add your API key.
Copy
import Uzu
public func runSummarization() async throws {
let engine = try await UzuEngine.create(apiKey: "API_KEY")
let model = try await engine.chatModel(repoId: "Qwen/Qwen3-0.6B")
try await engine.downloadChatModel(model) { update in
print("Progress: \(update.progress)")
}
let textToSummarize =
"A Large Language Model (LLM) is a type of artificial intelligence that processes and generates human-like text. It is trained on vast datasets containing books, articles, and web content, allowing it to understand and predict language patterns. LLMs use deep learning, particularly transformer-based architectures, to analyze text, recognize context, and generate coherent responses. These models have a wide range of applications, including chatbots, content creation, translation, and code generation. One of the key strengths of LLMs is their ability to generate contextually relevant text based on prompts. They utilize self-attention mechanisms to weigh the importance of words within a sentence, improving accuracy and fluency. Examples of popular LLMs include OpenAI's GPT series, Google's BERT, and Meta's LLaMA. As these models grow in size and sophistication, they continue to enhance human-computer interactions, making AI-powered communication more natural and effective."
let input: Input = .text(
text: "Text is: \"\(textToSummarize)\". Write only summary itself.")
let session = try engine.chatSession(model, config: Config(preset: .summarization))
let runConfig = RunConfig()
.tokensLimit(256)
.enableThinking(false)
.samplingPolicy(.custom(value: .greedy))
let output = try session.run(
input: input,
config: runConfig
) { _ in
return true
}
print("Summary: \(output.text.original)")
print(
"Model runs: \(output.stats.prefillStats.modelRun.count + (output.stats.generateStats?.modelRun.count ?? 0))"
)
print("Tokens count: \(output.stats.totalStats.tokensCountOutput)")
}
5
Add the snippet call
Copy
var body: some View {
VStack {
Text("On-device AI")
}
.onAppear() {
Task {
try await runSummarization()
}
}
}
Now that we’ve tried the simplest snippet, let’s take a look at the step-by-step integration guide.