Chabi

Guide

Monetize a Mac AI app

Native Mac apps whose AI runs on your users' plans, in Swift or Electron.

Updated November 2026

Why it suits Mac apps

A Mac app that calls AI either ships your API key (anyone can pull it out of the app) or needs a server to hide it, and then you pay for every user's AI. With Chabi, each user signs in with their own plan and the app calls AI with their token: no key in the app, no server, no AI bill. Users subscribe to Chabi on its website, not in your app.

Electron

Use the SDK's Node entry. It opens the system browser to sign in and listens on 127.0.0.1 for the return. Register http://127.0.0.1/callback as a redirect URI in the portal.

import { app, shell, safeStorage } from "electron";import { Chabi } from "@chabi/js/node";import OpenAI from "openai"; const chabi = new Chabi({  clientId: CHABI_CLIENT_ID,  storage, // { load, save, clear }: encrypt the tokens with safeStorage  openBrowser: (url) => shell.openExternal(url),});await chabi.load();if (!chabi.signedIn) await chabi.signIn(); const ai = new OpenAI(chabi.openai());

Swift

There's no Swift SDK yet, so sign in with OAuth 2.0 and PKCE by hand. There is no client secret. Register your app's URL scheme (for example myapp://callback) as the redirect URI.

  1. Make a random code_verifier and state, and the challenge: base64url of the verifier's SHA-256 (CryptoKit).
  2. Open https://chabi.dev/oauth/authorize with response_type=code, client_id, redirect_uri, code_challenge, code_challenge_method=S256 and state, in an ASWebAuthenticationSession.
  3. When it returns, check state, then POST form-encoded to https://chabi.dev/oauth/token with grant_type=authorization_code, code, redirect_uri, client_id and code_verifier.
  4. Keep the access and refresh tokens in the Keychain. Refresh before the access token expires; each refresh token works once, so always save the new one.

Then call AI as you would OpenAI's API, with Chabi's base URL and the user's token:

var req = URLRequest(url: URL(string: "https://chabi.dev/v1/chat/completions")!)req.httpMethod = "POST"req.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")req.setValue("application/json", forHTTPHeaderField: "Content-Type")req.httpBody = try JSONEncoder().encode(body) // { model, messages }let (data, response) = try await URLSession.shared.data(for: req)

The full flow, refresh rules and errors are in the sign-in docs.

What your users see

A Sign in with Chabi button, Chabi's sign-in in their browser, and one screen asking them to allow your app. After that, the app just works, and its AI comes out of their plan (Lite $5 a month (250 credits), Basic $10 a month (500 credits), Pro $20 a month (1,100 credits), Max $100 a month (6,000 credits)). Chabi Voice, a Mac dictation app, works this way.

Next