Beta Release. The Chatbase iOS SDK is currently in beta (v0.1.0-beta.1). APIs may change in future releases.
What is the Chatbase iOS SDK?
The Chatbase iOS SDK is a Swift library that lets you add Chatbase agents to your iOS or macOS app. It gives you:- Real-time streaming with
async/awaitand per-chunk callbacks - Client-side tools that let the agent run functions on the device
- User identity with JWT sign-in and an automatic device ID
- Conversation management with paginated history
- Ready-made SwiftUI state through
ConversationStateandConversationListState - Typed errors for everything that can go wrong
Everything in the SDK lives in one module,
ChatbaseSDK. A single import ChatbaseSDK gives you every type in these docs.Installation
The SDK ships as a Swift Package.- Xcode
- Package.swift
- File → Add Package Dependencies…
-
Paste the repository URL:
-
Choose version
0.1.0-beta.1(or Up to Next Minor) and add the ChatbaseSDK library to your app target.
No
Info.plist changes are needed. The SDK talks to https://www.chatbase.co over HTTPS, which iOS allows by default.Quick Start
1
Get your Agent ID
- Go to the Chatbase Dashboard
- Select your agent
- Go to Settings → General
- Copy the Agent ID
2
Enable the iOS SDK channel
In the dashboard, go to Deploy → iOS SDK and enable the channel for your agent.
3
Create a client
@State property. A new client starts anonymous, tied to a device ID that stays the same across launches.4
Send your first message
5
Continue the conversation
ConversationState instead. It keeps the conversation ID for you, along with the message list.ChatbaseClient
final class ChatbaseClient
The main entry point. You can call it from any task or actor.
init
String
required
The Chatbase agent ID to connect to.
String
default:"https://www.chatbase.co/api/sdk"
The Chatbase API address. Leave this at its default.
URLSessionConfiguration
default:".default"
The
URLSessionConfiguration used for every request. Set timeouts and caching here.Int
default:"10"
How many times a single
send or retry may run tools before giving up. Going over throws ChatError.toolLoopLimitExceeded(limit:). See Client-Side Tools.Properties
Methods
Logging
The SDK writes to Apple’s logging system under the subsystemcom.chatbase.sdk, in three categories:
View them in Console.app, or run
log stream --predicate 'subsystem == "com.chatbase.sdk"'. Message text is never logged.
Rate Limits
Chatbase allows 1,000 requests every 10 seconds per device. Going over throws anAPIError.httpError with status 429. See Error Handling.
Next Steps
Streaming
Stream replies with async/await and callbacks
SwiftUI
Ready-made state for chat screens
Client-Side Tools
Let the agent run functions on the device
Conversations
Conversations, history, and pagination
User Identity
Sign users in with JWT tokens
Error Handling
Error types and how to handle them
