Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.synheart.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

syni-swift is the iOS / macOS consumer SDK for Syni. Same agent surface as the Flutter sibling and the Kotlin sibling, idiomatic for Swift (async/await, AsyncThrowingStream<SyniChatEvent, Error> for streaming, Combine AnyPublisher<SyniInstallState, Never> for the install lifecycle).

Platform support

  • iOS 16.0+ · macOS 13.0+
  • Swift 5.9+ · Xcode 15+
  • Native runtime ships as SyniRuntime.xcframework (built locally via Scripts/build-xcframework.sh for path-dep consumers; binary target on releases)

Installation

// Package.swift
dependencies: [
    .package(url: "https://github.com/synheart-ai/syni-swift.git", from: "0.0.2"),
],
targets: [
    .target(
        name: "YourApp",
        dependencies: [
            .product(name: "SyniSwift", package: "syni-swift"),
        ]
    ),
]
For local development against a sibling checkout, run ./Scripts/build-xcframework.sh once to produce the native runtime (~5 min; see the script for toolchain prerequisites).

Basic usage

import SyniSwift

let agent = SyniAgent()

// Load a persona by id from bundled spec assets.
let persona = try await SyniSpecPersona.load("focus.coach.v1")

// First-run install: download + verify the model, load the engine,
// bind the persona. Emits lifecycle events on agent.installState.
try await agent.install(
    persona: persona,
    model: SyniModels.qwen25_15bInstructQ4
)

// Single-turn chat.
let response = try await agent.chat("How can I focus right now?")
print(response.displayText)

Streaming

chatStream returns an AsyncThrowingStream<SyniChatEvent, Error> — token-level .delta events followed by exactly one .final carrying the structured response.
for try await event in agent.chatStream("hello") {
    switch event {
    case let .delta(text):
        print(text, terminator: "")
    case let .final(response):
        print("\n[\(response.displayText.count) chars]")
    }
}

Hybrid local / cloud

let agent = SyniAgent(
    cloudConfig: SyniCloudConfig(
        baseUrl: "https://api.synheart.ai",
        authToken: { "<bearer-token>" },
        tenantId: "<tenant>",
        userId: "<user>"
    )
)

let response = try await agent.chat(
    "how was my recent session?",
    mode: .cloudFirst // try cloud, fall back to local
)
SyniExecutionMode cases: .localFirst (default), .cloudFirst, .localOnly, .cloudOnly.

Install lifecycle

Wire installState into SwiftUI to surface progress:
@Observable
final class InstallVM {
    var state: SyniInstallState = .notInstalled
    private var cancellable: AnyCancellable?

    func observe(_ agent: SyniAgent) {
        cancellable = agent.installState.sink { [weak self] in self?.state = $0 }
    }
}

// In your view
switch vm.state {
case .notInstalled:               Button("Install model") { /* trigger install */ }
case let .installing(stage, p):   ProgressView("\(stage)", value: p)
case .installed:                  ChatView()
case let .failed(reason, _):      Text("Install failed: \(reason)")
}
Stages: .downloadingModel.verifyingModel.loadingEngine.bindingPersona.

Where this fits

syni-swift is the agent layer — inference, install lifecycle, persona binding, chat orchestration. It does NOT own:
  • HSI signal collection (the synheart-core SDK does), or
  • the four-authority gate (consent + capability + activation + session; also a host concern).
Synheart-ecosystem apps typically depend on SynheartCore and use SyniModule, which wraps this SDK with those layers. Standalone use of SyniSwift is fully supported when you don’t need the wider Synheart contract.

Models

Out-of-the-box GGUF models exposed under SyniModels:
  • qwen25_15bInstructQ4 (default, ~1.5 GB)
  • qwen2_05bInstructQ4 (~500 MB)
  • gemma3_1bInstructQ4
Pinned SHA-256 per model; verified at install time. Bring your own GGUF via a custom SyniModelSpec. Swift also supports Apple Foundation Models as an execution target where available (.appleFoundationModels in RoutingPolicy.preferredEngines).

API reference

SurfaceNotes
SyniAgentConstructed with optional installer / cloudConfig. Exposes installState / currentState / isInstalled / hasCloud.
SyniAgent.install / restoreInstallIfReady / uninstall / disposeasync / throws; emit install-state transitions.
SyniAgent.chat / chatStreamasync throws / AsyncThrowingStream<SyniChatEvent, Error>.
SyniInstallStateEnum: .notInstalled, .installing(stage:progress:), .installed(...), .failed(reason:cause:).
SyniChatResponsedisplayText, message, suggestions, kind (.chat / .coach / .suggestions / .unknown).
SyniSpecPersonaload(id) — bundled persona JSON.
SyniModelCatalogList local + cloud model options; bundled defaults under SyniModelCatalog.bundled.
SyniCloudConfigbaseUrl, authToken: () -> String?, tenantId, userId.
SyniExecutionMode.localFirst, .cloudFirst, .localOnly, .cloudOnly.