ChappieConfiguration with a distinct keychainAccount value. The SDK stores and retrieves credentials independently for each account string, so sessions never bleed across users.
One configuration per user
Create aChappieConfiguration keyed to your app’s current user identifier, then pass it to both Chappie.authSession(configuration:) and Chappie.client(configuration:):
authSession.signOut() to remove their ChatGPT credential from Keychain. The credential is stored under their keychainAccount key and does not affect any other user’s session.
Sharing credentials across app extensions
If your app and a widget, share extension, or app clip need access to the same ChatGPT credential, add a Keychain Access Groups entitlement to your targets and setkeychainAccessGroup in the configuration:
TEAMID with your Apple Developer team identifier and com.example.shared with the access group name declared in your entitlements file. All targets that share this access group can read and write the same Keychain item.
ChappieConfiguration parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
keychainService | String | "com.chappie.sdk" | The Keychain service name; acts as a namespace for all Chappie items |
keychainAccount | String | "default" | The Keychain account name; set this to your app’s user identifier to isolate credentials per user |
keychainAccessGroup | String? | nil | An optional access group for sharing credentials between your app and its extensions |
keychainAccessibility | ChappieKeychainAccessibility | .whenUnlockedThisDeviceOnly | Controls when the Keychain item is readable; see below |
model | String | SDK default | The ChatGPT model the client uses for requests |
harness | ChappieHarness | .default | The assistant harness injected at the start of every conversation |
Putting it all together
Keychain accessibility
ThekeychainAccessibility setting determines when the operating system allows your app to read the stored credential:
| Value | When the item is readable |
|---|---|
.whenUnlockedThisDeviceOnly | Only while the device is unlocked; item does not migrate to other devices via iCloud backup |
.afterFirstUnlockThisDeviceOnly | After the device has been unlocked at least once since boot; allows background access |
Switching between accounts at runtime
Because each configuration is independent, you can hold multiple auth sessions in memory and switch between them as your app’s current user changes:Chappie.authSession(configuration:) creates a new, independent session object. It reads from Keychain at init time, so a returning user is signed in automatically without any additional sign-in steps.
Raw access and refresh tokens are never exposed through Chappie’s public API.
ChappieAccountInfo provides only identity metadata — email, user ID, account ID, and plan — derived from the stored credential. Chappie is an in-process SDK, not a server-side token vault; treat it accordingly when designing your app’s trust model.Example: multi-user app
The following example wires aUserSession observable to a ChappieAuthSession so that signing in or out of your app automatically creates or destroys the corresponding ChatGPT session:
Auth Overview
Understand the full auth lifecycle, state machine, and error types.
Sign-In Button
Add a ready-made sign-in button to your SwiftUI views.