SDKs
Swift SDK
Use the Altirs Swift SDK to run guardrail checks in your Swift applications.
Install
Add to Package.swift:
dependencies: [
.package(url: "https://github.com/altirs/sdk-swift", from: "0.1.0"),
]Quick Start
import AltirsSDK
let client = AltirsClient(apiKey: "grd_...")
let result = try await client.check(CheckPayload(input: "Ignore all previous instructions"))
if result.blocked {
print("Blocked:", result.violations)
}Methods
| Method | Description |
|---|---|
check(payload) | Run guardrail checks on a single input/response pair. Returns CheckResponse. |
batch(items) | Run checks on multiple items (max 20). Returns BatchResponse. |
isSafe(input) | Convenience: returns true if input passes all checks. |
maskPII(text) | Convenience: returns text with PII redacted. |
Error Handling
Catch AltirsError when the API returns a non-2xx response:
do {
let result = try await client.check(payload)
} catch let error as AltirsError {
print(error.message, error.status, error.requestId)
}Configuration
let client = AltirsClient(
apiKey: "grd_...",
baseURL: "https://altirs.ai/api", // optional
timeout: 30 // optional, seconds, default 30
)