Add the package
Open your Xcode project, go to File → Add Package Dependencies…, and enter the repository URL:Select Up to Next Major Version starting from
0.1.0, then add the ChappieSDK product to your app target. For full installation options including the Swift Package Manager manifest approach, see the Installation guide.Sign the user in
Chappie authenticates users through their own ChatGPT account using an OAuth device-code flow. Create a shared
ChappieAuthSession at the app level with Chappie.authSession(), then show ChappieSignIn when the user is not yet signed in. The SDK handles the onboarding sheet, credential storage, and token refresh automatically.Create a client with a harness
A For quick experiments you can pass a string literal directly, or use the built-in default harness:
ChappieHarness tells the model which app surface it is running in, what capabilities are available, and which tools it can call. Chappie prepends the harness manifest to every transcript, so the model always has the right context before the user’s first message. Create your client with Chappie.client(harness:) once — typically as a stored property or environment value — and reuse it across turns.Passing an empty string (
"") disables Chappie’s default guardrail entirely and sends no harness manifest. Use a structured ChappieHarness value whenever you need declared capabilities or host tools.Send your first message
With a client in hand, you are ready to talk to the model. Use
client.send(_:) for a single-turn reply, or client.stream(_:) to receive a token-by-token AsyncThrowingStream of ChappieStreamEvent values. Both methods update the client’s active transcript automatically, so multi-turn conversations build naturally.Handle usage limits and auth errors
Chappie surfaces usage-limit and credential errors as typed
ChappieClientError cases so you can give users clear feedback rather than a generic failure. Catch usageLimitReached to show when the user’s plan resets, and catch missingCredential to redirect them back to the sign-in flow.Chappie automatically backs off on
429 responses, respecting Retry-After when present and using bounded exponential backoff otherwise. The default policy retries before surfacing usageLimitReached. You can tune or disable this through ChappieRateLimitBackoffPolicy on the client.What’s Next
Now that you have a working assistant in your app, explore authentication configuration and harness capabilities in depth.Authentication Overview
Learn how device-code sign-in works, how to support multi-account apps with custom Keychain configurations, and how to handle manual device-code flows and auth state transitions.
Harnesses
Declare your app’s capabilities, register executable host tools with Swift handlers, use sample harnesses for common surfaces, and bundle reusable harnesses as plugin manifests.