Build AI-powered iOS and macOS apps with ChatGPT sign-in.
Let users power their in-app AI experience through their own ChatGPT accounts. No API keys to manage and no developer-funded OpenAI API usage for the built-in account-backed integration.
CodexKit is a native Swift AI agent SDK with streaming, app-defined tools, SQLite or Realm conversation persistence, optional local memory, and SwiftUI integration.
iOS 17+ · macOS 14+ · Swift 6.1+ · Xcode 16.3+
Build your first SwiftUI app →
CodexKit is an independent project, not an official OpenAI SDK. Account eligibility, models, and usage limits depend on provider support and the user's account. See ChatGPT sign-in and access.
- Installation
- Quickstart
- Capabilities
- Why an embedded Swift agent runtime?
- Demo apps
- Cloud execution with npm
- Documentation
- Project
- License
Screens from the full iOS demo. The getting-started guide builds a smaller chat interface in your own app.
In Xcode, choose File → Add Package Dependencies, enter the URL below, and select version 2.3.0:
https://github.com/timazed/CodexKit
Add the products your app needs:
| Product | Purpose |
|---|---|
CodexKit |
Agent runtime, authentication, tools, and memory APIs |
CodexKitUI |
Optional SwiftUI helpers for observable state and prompts |
CodexKitSQLite |
Conversation and memory storage using SQLite through GRDB |
CodexKitRealm |
Conversation and memory storage using RealmSwift |
Choose one persistence adapter to keep conversations across app launches. Credentials are stored separately in Keychain. See persistence configuration for storage locations and migration.
Build a SwiftUI AI app with ChatGPT sign-in walks through:
- Creating a view model and signing in with ChatGPT.
- Sending messages and displaying streaming responses.
- Restoring saved conversations with SQLite or Realm.
- Registering an app-defined tool and presenting approvals.
Each stage adds a small piece of code and includes a check to run. Complete view-model and view files are available at the end.
Already integrating a runtime? Go directly to app-defined tools, model configuration, or SDK integration.
| Capability | What you can build |
|---|---|
| ChatGPT sign-in | Account-backed AI features without API-key entry; device-code and browser flows, plus optional local Codex session reuse on macOS |
| Streaming and structured output | Live text responses and validated typed results |
| App-defined tools | Agents that read app data or perform authorized actions, with approval controls |
| SQLite or Realm persistence | Saved conversations, resumable threads, and context compaction |
| Optional local memory | Capture selected information and retrieve it for later requests, separately from conversation history |
| Personas and skills | App-specific instructions and tool policies |
| Images | Image input, generation, and editing |
| Runtime controls | Model discovery, usage-limit reporting, progress, interruption, and bounded parallel tools |
See the full feature matrix for supported behavior.
CodexKit runs agent orchestration inside your app: conversation state, tool execution, approvals, and persistence. Your app owns the interface and implements the tools. The built-in backend sends model requests to the ChatGPT Codex service, so inference requires network access.
The core Swift integration does not require a separate Codex app-server, running desktop app, CLI process, or Node backend.
See how the embedded runtime works for the data flow and integration comparison.
The repository includes native iOS and macOS demos with sign-in, streaming chat, tools, approvals, structured output, memory, and persistence options.
open DemoApp/CodexKitDemo.xcodeprojSelect CodexKitIOSDemo or CodexKitMacDemo. Follow the demo setup and walkthrough for configuration and verification commands.
The optional @timazed/codexkit package lets a Node.js backend execute CodexKit-prepared text, structured JSON, and image generation/edit requests. Swift apps do not need Node or npm.
The bridge executes selected requests; your backend supplies authentication custody, job storage, retries, and result delivery. Text/JSON execution is tool-free.
See the package guide and limitations and remote execution guide. Cloud releases use separate cloud-v* tags.
Use the documentation index for the complete guide list. Common integration topics:
| Topic | Guides |
|---|---|
| Authentication | iOS sign-in · macOS session reuse · Account access |
| Messages and results | Messaging and images · Structured output · Structured recovery |
| App integration | SDK lifecycle · Apple integrations · Session transfer |
| Diagnostics | Logging and troubleshooting · Usage telemetry |
Latest Swift release: v2.3.0. See the changelog and migration guide for changes and upgrades.
To build and test a checkout on macOS with Xcode installed:
swift build --force-resolved-versions
swift test --force-resolved-versionsContributing · Verification · Security policy
MIT — free to use, modify, and redistribute, including in commercial apps, while retaining the copyright and license notice. Provider services and third-party dependencies remain subject to their own terms and licenses.
