Preview. The Swift SDK is in preview. APIs may change before the 1.0 release.
Installation (SPM)
// Package.swift
dependencies: [
.package(
url: "https://github.com/hubrix-ai/sdk-swift",
from: "2026.5.4"
)
],
targets: [
.target(
name: "YourApp",
dependencies: [.product(name: "Hubrix", package: "sdk-swift")]
)
]Or download the zip and add Sources/Hubrix to your project directly.
Quickstart
import Hubrix
let client = HubrixClient(apiKey: "YOUR_API_KEY")
// Verify connection
let profile = try await client.me()
print("Connected: \(profile.email)")
// Start a research report
let job = try await client.research.create(
query: "Latest advances in AI reasoning",
depth: "standard"
)
// Poll until complete
let report = try await client.research.poll(reportId: job.id)
print("Report: \(report.content?.count ?? 0) chars")
// Save to file
if let md = try? await client.research.exportMarkdown(reportId: job.id) {
try md.write(toFile: "report.md", atomically: true, encoding: .utf8)
}Recipes
Run a workflow
let run = try await client.workflows.createRun(
workflowId: "your-workflow-uuid",
inputs: ["query": "Summarise Q1 sales", "format": "markdown"]
)
let result = try await client.workflows.pollRun(
workflowId: "your-workflow-uuid",
runId: run.id,
interval: 3.0,
timeout: 120.0
)
print("Status: \(result.status)")Error handling
do {
let report = try await client.research.create(query: "AI trends")
} catch HubrixError.insufficientCredits(let detail, _) {
print("Credits needed: \(detail)")
} catch HubrixError.rateLimited(let retryAfter, _) {
print("Rate limited, retry after: \(retryAfter ?? 60)s")
} catch HubrixError.authentication(let detail, _) {
print("Auth error: \(detail)")
} catch {
print("Unexpected: \(error)")
}Concurrency model
HubrixClient, WorkflowsResource, and ResearchResource are all Swift actor types. They are safe to use across concurrent tasks with no additional synchronisation required.
Reference
Full API reference at api.hubrix.ai/reference.
Source: github.com/hubrix-ai/sdk-swift (planned)