iOS SDK
Conversational AI SDK: deploy customized, interactive voice agents in your Swift applications.
Also see the Conversational AI overview
Installation
Add the ElevenLabs Swift SDK to your project using Swift Package Manager:
Add the Package Dependency
- Open your project in Xcode
- Go to
File
>Add Packages...
- Enter the repository URL:
https://github.com/elevenlabs/ElevenLabsSwift
- Select your desired version
Import the SDK
Ensure you add NSMicrophoneUsageDescription
to your Info.plist to explain
microphone access to users.
Usage
This library is primarily designed for Conversational AI integration in Swift applications. Please use an alternative dependency for other features, such as speech synthesis.
Initialize Conversation
First, create a session configuration and set up the necessary callbacks:
Session Configuration
There are two ways to initialize a session:
You can obtain an Agent ID through the ElevenLabs UI:
Client Tools
Client Tools allow you to register custom functions that can be called by your AI agent during conversations. This enables your agent to perform actions in your application.
Registering Tools
Register custom tools before starting a conversation:
Remember to setup your agent with the client-tools in the ElevenLabs UI. See the Client Tools documentation for setup instructions.
Starting the Conversation
Initialize the conversation session asynchronously:
The client tools parameter is optional. If you don’t need custom tools, you can omit it when starting the session.
Audio Sample Rates
The ElevenLabs SDK currently uses a default input sample rate of 16,000 Hz
. However, the output sample rate is configurable based on the agent’s settings. Ensure that the output sample rate aligns with your specific application’s audio requirements for smooth interaction.
The SDK does not currently support ulaw format for audio encoding. For compatibility, consider using alternative formats.
Managing the Session
Example Implementation
For a full, working example, check out the example application on GitHub.
Here’s an example SwiftUI view implementing the conversation interface:
This SDK is currently experimental and under active development. While it’s stable enough for testing and development, it’s not recommended for production use yet.
Was this page helpful?