iOS SDK
QwryClient
The initializer, properties and methods of QwryClient, the main entry point of the QwryAI iOS SDK
public actor QwryClient
QwryClient talks to one QwryAI agent. Create it once and keep it. Because it's an actor, you can call it from any task, and its methods and mutable properties are reached with await.
init
public init(
agentId: String,
baseURL: URL = QwryClient.defaultBaseURL,
configuration: URLSessionConfiguration = .default,
maxToolLoopSteps: Int = 10
)| Parameter | Type | Default | Description |
|---|---|---|---|
agentId | String | Required | Your agent's ID, from the Setup tab of the iOS SDK channel. |
baseURL | URL | https://www.qwryai.com/api/sdk | The SDK API to call. Leave it at its default. |
configuration | URLSessionConfiguration | .default | The session configuration used for every request. Set timeouts and caching here. |
maxToolLoopSteps | Int | 10 | How many rounds of tool calls one send or retry may make before it throws QwryError.toolLoopLimitExceeded. See Client-Side Tools. |
// Custom timeouts
let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = 30
config.timeoutIntervalForResource = 300
let client = QwryClient(
agentId: "YOUR_AGENT_ID",
configuration: config,
maxToolLoopSteps: 20
)Properties
| Property | Type | Description |
|---|---|---|
agentId | String | The agent this client talks to. |
deviceId | String | The device ID. Always available, without await. |
authState | AuthState | .anonymous, or .identified(userId:) after a successful identify. |
currentConversationId | String? | The conversation send continues. nil until the first answer, and after newConversation(), identify or logout. |
currentUserId | String? | The signed-in user's ID, or nil while anonymous. |
The type also has two static values: QwryClient.version ("0.1.0") and QwryClient.defaultBaseURL.
Methods
| Method | Description |
|---|---|
send(_:conversationId:configure:) | Send a message, stream the answer and run tools. See Streaming. |
retry(conversationId:messageId:configure:) | Ask the agent to answer again. See Streaming. |
sendNonStreaming(_:conversationId:) | Get the whole answer at once, with no handlers. Tools still run. See Streaming. |
tool(_:handler:) | Register a tool the agent can run on the device. See Client-Side Tools. |
removeTool(_:) | Stop handling a tool. See Client-Side Tools. |
identify(token:) | Sign a user in with a JWT; returns their user ID. See User Identity. |
logout() | Go back to anonymous. See User Identity. |
newConversation() | Clear currentConversationId. See Conversations & History. |
listConversations(cursor:limit:) | List past conversations. See Conversations & History. |
listMessages(conversationId:cursor:limit:) | Load a page of a conversation's messages. See Conversations & History. |