> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> RunAnywhere Swift SDK for iOS, macOS, tvOS, and watchOS

<div style={{ marginBottom: '24px' }}>
  <button
    id="copy-all-btn"
    onClick={() => {
  const btn = document.getElementById('copy-all-btn')
  btn.innerText = 'Copying...'
  fetch('/llms-full.txt')
    .then((res) => (res.ok ? res.text() : Promise.reject()))
    .then((text) => {
      const sections = text.split(/(?=^# )/m)
      const filtered = sections.filter((s) =>
        s.includes('Source: https://docs.runanywhere.ai/swift/')
      )
      if (filtered.length === 0) throw new Error('empty')
      return filtered.join('\n')
    })
    .catch(() => document.getElementById('full-guide-content').innerText)
    .then((text) => navigator.clipboard.writeText(text))
    .then(() => {
      btn.innerText = 'Copied!'
      setTimeout(() => {
        btn.innerText = 'Copy Full Swift SDK Docs for AI Agent'
      }, 2000)
    })
}}
    style={{
  background: 'linear-gradient(135deg, #ff6900 0%, #fb2c36 100%)',
  color: 'white',
  border: 'none',
  padding: '12px 24px',
  borderRadius: '8px',
  fontSize: '16px',
  fontWeight: '600',
  cursor: 'pointer',
  display: 'flex',
  alignItems: 'center',
  gap: '8px',
}}
  >
    Copy Full Swift SDK Docs for AI Agent
  </button>
</div>

<div id="full-guide-content">
  ## Overview

  The **RunAnywhere Swift SDK** is a production-grade, on-device AI SDK for Apple platforms. It enables developers to run AI models directly on Apple devices without requiring network connectivity for inference, ensuring minimal latency and maximum privacy for your users.

  The SDK provides a unified interface to multiple AI capabilities:

  <CardGroup cols={3}>
    <Card title="LLM" icon="brain" href="/swift/llm/chat">
      Text generation with streaming support and structured output
    </Card>

    <Card title="STT" icon="microphone" href="/swift/stt/transcribe">
      Speech-to-text transcription with multiple backends
    </Card>

    <Card title="TTS" icon="volume-high" href="/swift/tts/synthesize">
      Neural and system voice synthesis
    </Card>

    <Card title="VLM" icon="eye" href="/swift/vlm">
      Vision language models for image understanding
    </Card>

    <Card title="Tool Calling" icon="wrench" href="/swift/tool-calling">
      Function calling with typed tool definitions
    </Card>

    <Card title="Image Generation" icon="image" href="/swift/diffusion">
      On-device image generation with Stable Diffusion
    </Card>

    <Card title="VAD" icon="waveform" href="/swift/vad">
      Real-time voice activity detection
    </Card>
  </CardGroup>

  ## Key Capabilities

  * **Multi-backend architecture** – Choose from LlamaCPP (GGUF models), ONNX Runtime, or Apple Foundation Models
  * **Metal acceleration** – GPU-accelerated inference on Apple Silicon
  * **Event-driven design** – Subscribe to SDK events for reactive UI updates
  * **Production-ready** – Built-in analytics, logging, device registration, and model lifecycle management

  ## Core Philosophy

  <AccordionGroup>
    <Accordion title="On-Device First" icon="microchip">
      All AI inference runs locally, ensuring low latency and data privacy. Once models are
      downloaded, no network connection is required for inference.
    </Accordion>

    <Accordion title="Plugin Architecture" icon="puzzle-piece">
      Backend engines are optional modules—include only what you need. This keeps your app binary size
      minimal.
    </Accordion>

    <Accordion title="Privacy by Design" icon="shield-check">
      Audio and text data never leaves the device unless explicitly configured. Only anonymous
      analytics are collected by default.
    </Accordion>

    <Accordion title="Event-Driven" icon="bell">
      Subscribe to SDK events for reactive UI updates and observability. Track generation progress,
      model loading, and errors in real-time.
    </Accordion>
  </AccordionGroup>

  ## Features

  ### Language Models (LLM)

  * On-device text generation with streaming support
  * Structured output generation with `Generatable` protocol
  * System prompts and customizable generation parameters
  * Support for thinking/reasoning models with token extraction
  * Multiple framework backends (LlamaCPP, Apple Foundation Models)

  ### Speech-to-Text (STT)

  * Real-time streaming transcription
  * Batch audio transcription
  * Multi-language support
  * Whisper-based models via ONNX Runtime

  ### Text-to-Speech (TTS)

  * Neural voice synthesis with ONNX models
  * System voices via AVSpeechSynthesizer
  * Streaming audio generation for long text
  * Customizable voice, pitch, rate, and volume

  ### Voice Activity Detection (VAD)

  * Energy-based speech detection
  * Configurable sensitivity thresholds
  * Real-time audio stream processing

  ### Vision Language Models (VLM)

  * Multimodal image + text inference
  * Platform-conditional image constructors (iOS UIImage, macOS raw pixels)
  * Multi-file model registration with GGUF files
  * Streaming token output with cancellation support

  ### Tool Calling

  * Register typed tool definitions with parameter schemas
  * Automatic tool execution loop with configurable limits
  * Multi-tool chaining for complex agent workflows
  * ToolValue types with string and number support

  ### Image Generation (Diffusion)

  * On-device Stable Diffusion via Apple CoreML
  * Progress tracking with step-by-step callbacks
  * Cancellation support for long-running generation
  * Configurable guidance scale, steps, and dimensions

  ### Voice Agent Pipeline

  * Full VAD → STT → LLM → TTS orchestration
  * Complete voice conversation flow
  * Streaming and batch processing modes

  ### Model Management

  * Automatic model discovery and catalog sync
  * Download with progress tracking (download, extract, validate stages)
  * In-memory model storage with file system caching
  * Framework-specific model assignment

  ## System Requirements

  | Platform | Minimum Version |
  | -------- | --------------- |
  | iOS      | 17.0+           |
  | macOS    | 14.0+           |
  | tvOS     | 17.0+           |
  | watchOS  | 10.0+           |

  **Swift Version:** 5.9+

  **Xcode:** 15.2+

  <Note>
    Some optional modules have higher runtime requirements: - Apple Foundation Models
    (`RunAnywhereAppleAI`): iOS 26+ / macOS 26+ at runtime
  </Note>

  ## SDK Modules

  | Module                | Purpose                              |
  | --------------------- | ------------------------------------ |
  | `RunAnywhere`         | Core SDK (required)                  |
  | `RunAnywhereLlamaCPP` | LLM text generation with GGUF models |
  | `RunAnywhereONNX`     | STT/TTS/VAD via ONNX Runtime         |

  ## Next Steps

  <CardGroup cols={2}>
    <Card title="Installation" icon="download" href="/swift/installation">
      Install the SDK via Swift Package Manager
    </Card>

    <Card title="Quick Start" icon="rocket" href="/swift/quick-start">
      Build your first AI feature in minutes
    </Card>
  </CardGroup>
</div>
