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

# Swift SDK: Getting Started

> Add real-time voice conversations to your iOS app with the Outspeed Swift SDK

## Features

* Real-time voice conversations with AI
* Support for both Outspeed and OpenAI providers
* WebRTC-based audio streaming
* Customizable voice and model selection
* ElevenLabs Conversational AI compatibility

<Note>
  The Outspeed Swift SDK is fully compatible with the ElevenLabs Swift SDK. See our{" "}
  <a href="./outspeed-swift-elevenlabs">ElevenLabs Compatibility guide</a> for migration details.
</Note>

## Installation

1. Open Your Project in Xcode
2. Go to `File` > `Add Packages...`
3. Enter Repository URL: `https://github.com/outspeed-ai/OutspeedSwift`
4. Import the SDK

   ```swift theme={null}
   import OutspeedSDK
   ```

<Warning>Ensure `NSMicrophoneUsageDescription` is added to your Info.plist to explain microphone access.</Warning>

## Requirements

* iOS 15.2 or later
* Swift 6.1+

## Basic Usage

Here's the minimal code to get a voice conversation working:

```swift theme={null}
import OutspeedSDK

// Create a session configuration
let config = OutspeedSDK.SessionConfig()

// 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)")
    }
}
```

## Customization

### System Prompt and First Message

```swift theme={null}
let agentConfig = OutspeedSDK.AgentConfig(
    prompt: "You are a helpful assistant with a witty personality.",
    firstMessage: "Hey there, how can I help you with Outspeed today?"
)

let config = OutspeedSDK.SessionConfig(
    overrides: OutspeedSDK.ConversationConfigOverride(agent: agentConfig)
)
```

### Voice Selection

```swift theme={null}
let ttsConfig = OutspeedSDK.TTSConfig(voiceId: OutspeedSDK.Voice.david.rawValue)

let config = OutspeedSDK.SessionConfig(
    overrides: OutspeedSDK.ConversationConfigOverride(tts: ttsConfig)
)
```

## Complete Example

See a full iOS voice bot application example at our [Examples Repository](https://github.com/outspeed-ai/outspeed-examples/tree/main/swift-ios-basic).
