Android SDK overview
Add an Askocto agent to a native Android app with the Kotlin SDK: chat, streaming, client tools and user identity.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
The Android 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 written in Kotlin, uses suspend functions for single requests and Flow for streaming, and mirrors the iOS SDK concept for concept.
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 token by token as a
FlowofStreamEventvalues. - 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 Android project with Kotlin coroutines and
minSdk24 or higher. - The id of a published agent, for example
agt_123. Find it under Settings > General inside the agent. - Network access. The app needs the
INTERNETpermission.
The SDK is published as co.askocto:sdk. It never needs a workspace API key, and you should not put one in an app, because keys act on the whole workspace.
Pages in this section
- Quickstart: add the dependency 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: collect 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.