iOS SDK overview
Add an Askocto agent to a native iOS app with the Swift SDK: chat, streaming, client tools and user identity, built on async/await.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
The iOS SDK lets a native app talk to one of your agents. Use it when you want the conversation to live inside your own screens instead of a web view. The SDK is a Swift package named Askocto. It uses async/await for single requests and AsyncThrowingStream for streaming, and it mirrors the Android SDK concept for concept, with the same type and method names.
What the SDK covers
- Chat. Send a message with
OctoClientand get aChatResponsewith the answer, the sources used and the credit usage. - Streaming. Receive the answer piece by piece as an
AsyncThrowingStreamofStreamEventvalues. - Conversations. List past conversations, load their messages and continue one by passing its id.
- Client tools. Register a
ClientToolso the agent can ask your app to do something on the device, such as opening an order screen. - User identity. Pass a
UserIdentityso conversations belong to a signed-in customer. - Errors. Every failure arrives as a typed
OctoError.
What you need
- An app that targets iOS 16 or later.
- The id of a published agent, for example
agt_123. Find it under Settings > General inside the agent. - Network access for the app.
The SDK never needs a workspace API key. Do not put one in an app, because keys act on the whole workspace.
Pages in this section
- Quickstart: add the package and send a first message.
- Client: create and configure
OctoClient. - Chat response: read the answer, sources and usage.
- Conversations: list, load and continue conversations.
- Conversation models: the
ConversationandMessagetypes. - Streaming: show an answer as it is written.
- Streaming events: every
StreamEventcase. - Client side tools: let the agent call code in your app.
- User identity: sign customers in with a verified identity.
- Error handling: handle
OctoErrorand retry safely. - JSON value: the
JSONValuetype for tool arguments and results. - SwiftUI: build a chat screen with a view model.