Swift SDK
Conversational AI SDK: deploy customized, interactive voice agents in your Swift applications.
Installation
Add the ElevenLabs Swift SDK to your project using Swift Package Manager:
Ensure you add NSMicrophoneUsageDescription
to your Info.plist to explain microphone access to
users. The SDK requires iOS 14.0+ / macOS 11.0+ and Swift 5.9+.
Quick Start
Get started with a simple conversation in just a few lines:
Authentication
There are two ways to authenticate and start a conversation:
Public Agents
Private Agents
For public agents, use the agent ID directly:
Core Features
Reactive Conversation Management
The SDK provides a modern Conversation
class with @Published
properties for reactive UI updates:
Voice and Text Modes
Audio Controls
Client Tools
Client Tools allow you to register custom functions that can be called by your AI agent during conversations. The new SDK provides improved parameter handling and error management.
Handling Tool Calls
Handle tool calls from your agent with full parameter support:
Remember to setup your agent with the client-tools in the ElevenLabs UI. See the Client Tools documentation for setup instructions.
Connection State Management
Monitor the conversation state to handle different connection phases:
Agent State Monitoring
Track when the agent is listening or speaking:
Message Handling
Send text messages and monitor the conversation:
Session Management
SwiftUI Integration
Here’s a comprehensive SwiftUI example using the new SDK: