Getting Started with Outspeed Swift SDK

A Swift SDK for the Outspeed API that enables real-time voice conversations using WebRTC technology.

The Outspeed Swift SDK is fully compatible with the ElevenLabs Swift SDK. Migrating your code is easy—see our ElevenLabs Compatibility guide for details.

Features

  • Real-time voice conversations with AI
  • Support for both Outspeed and OpenAI providers
  • WebRTC-based audio streaming
  • Customizable voice and model selection
  • Device-specific optimizations
  • Comprehensive audio session management

Installation

Swift Package Manager

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/outspeed-ai/OutspeedSwift", from: "0.0.2")

And add OutspeedSDK to your target dependencies:

.target(
    name: "YourTarget",
    dependencies: ["OutspeedSDK"]),

Xcode

  1. Open Your Project in Xcode
    • Navigate to your project directory and open it in Xcode.
  2. Add Package Dependency
    • Go to File > Add Packages...
  3. Enter Repository URL in the Search Bar
    • Input the following URL: https://github.com/outspeed-ai/OutspeedSwift
  4. Select Version
  5. Import the SDK
    import OutspeedSDK
  6. Ensure NSMicrophoneUsageDescription is added to your Info.plist to explain microphone access.

Requirements

  • iOS >=18.0
  • Swift 6.1+

Usage

Basic Setup

import OutspeedSDK

// Create a session configuration
let config = OutspeedSDK.SessionConfig( agentId : "testagent")

// Create callbacks to handle events
let callbacks = OutspeedSDK.Callbacks()
callbacks.onMessage = { message, role in
    print("Received message from \(role.rawValue): \(message)")
}

callbacks.onError = { message, error in
    print("Error: \(message)")
}

callbacks.onStatusChange = { status in
    print("Status changed to: \(status.rawValue)")
}

// Start the conversation
Task {
    do {
        let conversation = try await OutspeedSDK.Conversation.startSession(
            config: config,
            callbacks: callbacks
            apiKey: "<YOUR_OUTSPEED_API_KEY>"
        )

        // When done with the conversation
        conversation.endSession()
    } catch {
        print("Failed to start conversation: \(error)")
    }
}

Examples

You can find examples of the SDK here: Outspeed Swift Examples