LLM prompt — add the iOS native SDK
Use this prompt when you have an existing SwiftUI iOS app and want to add a 2wai avatar screen via TwaiAvatarKit.
The prompt
Section titled “The prompt”Copy, paste, fill {PLACEHOLDERS}:
I'm adding a 2wai talking avatar to an existing SwiftUI iOS app using the preview iOS native SDK (TwaiAvatarKit).
CONTEXT
2wai is a lip-synced talking-avatar platform. Transport 0 (LiveKit) is the only live transport. Integration pattern is MINT-PROXY: a backend holds `sk_...` and mints short-lived LiveKit participant tokens.
The iOS SDK ships under `ios-native/` in `2waiorg/2wai-toolkit-public` on `main`. Three library products:- `TwaiCore` — pure Swift REST client + Codable types + typed errors- `TwaiLiveKit` — Transport 0 engine (actor + LiveKit Room + mint-closure flow)- `TwaiPlayer` — SwiftUI `TwaiPlayerView` + `TwaiPlayerHandle`
Depends on `livekit/client-sdk-swift ~ 2.3`. iOS 15+, Swift 5.9+.
MY INPUTS
- avatar_id: {AVATAR_ID}- voice_id (optional): {VOICE_ID}- mint-proxy URL: {URL — e.g. https://my-app.com/api/mint}- Xcode version: {XCODE_15 / XCODE_16}- my app's existing SwiftUI entry file: {PATH, e.g. App/MyApp.swift}- where I want the avatar screen: {VIEW_NAME}
WHAT I NEED YOU TO DO
1. **Add the SDK via SPM**. In Xcode: File → Add Package Dependencies → paste `https://github.com/2waiorg/2wai-toolkit-public`, select branch `main` (or a release tag once there is one), add the `TwaiPlayer` product to my app target. (It transitively pulls `TwaiCore` + `TwaiLiveKit` + `livekit-client`.)
OR edit my `Package.swift` directly if I'm SPM-managed: ```swift dependencies: [ .package(url: "https://github.com/2waiorg/2wai-toolkit-public", branch: "main"), ] .target(name: "MyApp", dependencies: [ .product(name: "TwaiPlayer", package: "2wai-toolkit"), ]) ```
2. **Create the avatar screen** View file: ```swift import SwiftUI import TwaiCore import TwaiLiveKit import TwaiPlayer
struct {VIEW_NAME}: View { @State private var handle: TwaiPlayerHandle?
private let api = TwaiAPIClient( credentials: .mintProxy(url: URL(string: "{MINT_PROXY_URL}")!) )
var body: some View { TwaiPlayerView(mint: mint) .onReady { handle = $0 } .task { try? await handle?.send("Hi — tell me what you can do.") } }
private func mint() async -> TwaiMintResult { do { let s = try await api.createSession(.init( avatarId: "{AVATAR_ID}", voiceId: "{VOICE_ID}", mode: .video )) return .enabled(url: s.livekitUrl, token: s.participantToken, room: s.roomName) } catch TwaiError.rateLimited(let secs, _) { return .rateLimited(retryAfterSeconds: secs ?? 60) } catch { return .unavailable(message: "\(error)", cause: error) } } } ``` Mount `{VIEW_NAME}` in my app's existing navigation.
3. **Add Info.plist entries** for iOS mic (if I'll add mic later; harmless now): - `NSMicrophoneUsageDescription`: "To talk with the avatar" - `NSSpeechRecognitionUsageDescription`: "To understand what you say to the avatar"
4. **Build** (⌘B). Should compile clean against `livekit-client 2.3+`. If I hit anything unexpected (my app's existing Swift version mismatch, deployment-target too low, SPM resolution issue), surface it with the exact error.
5. **Run on physical iPhone** (⌘R, device target): - Avatar appears within ~5s of app launch. - Avatar talks (triggered by the `.task { try? await handle?.send("Hi...") }`). - Audio plays.
GOTCHAS TO HONOR
- `TwaiCredentials.mintProxy(url:)` is the ONLY production credential path. `._rawSecretKey` exists but is marked with a leading underscore — never use it in a shipped build.- `adaptiveStream: false` + `dynacast: false` are already in `TwaiEngine.swift`; do not change them.- SEND_GRACE_MS warm-up: `handle.send()` throws for ~2s after the `.ready` state. The sample above waits via `.task` which runs after `.onReady`, so this is handled correctly.- The SDK itself has been verified on Xcode + physical iPhone — your build should go clean. Flag any surprise.
DELIVERABLE
- Updated SPM manifest / Xcode SPM package reference.- One new SwiftUI View file.- Navigation wiring to mount it.- Info.plist entries.- One-line README note on which iOS version I verified against.
If you need anything (my minimum iOS version, whether I use UIKit or SwiftUI nav, whether I have a running mint proxy), ASK.
Reference docs: https://developers.2wai.ai/sdks/ios-native/Reference sample: https://github.com/2waiorg/2wai-toolkit-public/tree/main/ios-native/Samples/HelloAvatar