Skip to content

About

Official Swift SDK for the Wiro AI API (WiroKit): run image, video, audio and LLM models from iOS apps with typed requests and live task tracking.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Wiro AI

WiroKit for iOS: Swift SDK for the Wiro AI API

Run image, video, audio and LLM models from iOS apps in Swift with the Wiro AI API: typed requests, live task tracking and file uploads.

SwiftPM Swift 6.0+ iOS 17+ CI License: MIT

Website · Models · Docs · Dashboard

WiroKit is the official Swift package for calling the Wiro AI model API from iOS 17+ apps. It runs any model in the Wiro AI catalog, through typed request factories for popular image, video and music models or through Wiro.model with a parameter map, and follows each task by polling or over a WebSocket until the outputs are ready. It is written in Swift 6 with async/await and has no third-party dependencies.

Features

  • Typed request factories for popular image, video, and audio models
  • Dynamic model requests with Wiro.model("owner/project", parameters:)
  • Model search, explore, and schema validation
  • subscribe / run / subscribeStream task lifecycle APIs
  • Automatic file uploads for device-local inputs
  • Polling and WebSocket task tracking
  • Task cancel / kill
  • Retry with exponential backoff, timeouts, and structured logging
  • API key, HMAC signature, and proxy authentication
  • Zero third-party dependencies (Foundation, URLSession, CryptoKit)

Requirements

Installation

Swift Package Manager

Add WiroKit to your Package.swift:

dependencies: [
    .package(
        url: "https://github.com/wiroai/Swift-QuickStart.git",
        from: "0.1.0"
    ),
],

Or in Xcode choose File > Add Package Dependencies... and enter the repository URL, then link the WiroKit product.

Quick start

import WiroKit

let client = try WiroClient(apiKey: "your-api-key")

let result = try await client.subscribe(
    Wiro.flux2Pro(
        prompt: "A cinematic mountain lake",
        width: 1024,
        height: 1024
    )
)

switch result {
case .success(let task):
    print(task.outputs.first?.url as Any)
case .failure(_, let reason):
    print("Failed:", reason)
}

Mobile tip: Prefer WiroClient(proxyURL:headers:) in shipped apps so long-lived API secrets never ship inside the binary.

Authentication

API key

let client = try WiroClient(apiKey: "your-api-key")

API key + HMAC signature

let client = try WiroClient(
    apiKey: "your-api-key",
    apiSecret: "your-api-secret"
)

Signature mode sends x-api-key, x-nonce, and an HMAC-SHA256 x-signature header. The configured credentials must match the authentication type selected for the Wiro AI project.

Proxy (recommended for production)

let client = try WiroClient(
    proxyURL: URL(string: "https://api.myapp.com/wiro/v1")!,
    headers: ["Authorization": "Bearer \(sessionToken)"]
)

Your backend attaches Wiro AI credentials server-side. The SDK never stores an API key in proxy mode. Task WebSocket streams still connect directly to Wiro AI because they authenticate with per-task tokens.

Which call do I need?

I want to... Call
Generate with a supported model client.subscribe(Wiro.flux2Pro(...))
Run any other model client.subscribe(Wiro.model("owner/project", parameters: [...]))
Fire-and-forget then wait run / runModel, then waitForTask
Stream live status updates subscribeStream(...)
Find a model searchModels(search:) / explore()
Inspect parameters getModelSchema(...), then schema.validate(...)
Send device bytes WiroFileInput.data(bytes, fileName: "photo.png")
Send a hosted file WiroFileInput.url(url)
Stop work Cancel the Swift Task, or cancelTask / killTask

Typed and dynamic requests

Typed factories check required parameters and select options at compile time, and throw WiroError.validation when a value is out of range. Type Wiro. in Xcode to list them.

Category Models
Image FLUX.2 Pro, GPT Image 2, Nano Banana Pro, Seedream v4, Grok Imagine Image
Video Runway Gen-4.5, Seedance 2.0, Kling V3, Veo 3.1, Sora 2 Pro, Hailuo 2.3 Fast, Grok Imagine Video
Music Lyria 3
// Typed
let request = try Wiro.flux2Pro(
    prompt: "Sunset over the bay",
    width: 1024,
    height: 1024
)

// Dynamic
let dynamic = try Wiro.model(
    "black-forest-labs/flux-2-pro",
    parameters: [
        "prompt": "Sunset over the bay",
        "width": 1024,
        "height": 1024,
    ]
)

Read the accepted parameters before running a model:

let schema = try await client.getModelSchema(
    WiroModelID(parsing: "openai/sora-2")!
)
let problems = schema.validate(["prompt": "A cinematic mountain lake"])

validate returns human-readable problems and an empty array when the parameters satisfy the schema.

Polling and WebSocket tracking

Polling is the default tracking mode:

let result = try await client.subscribe(
    Wiro.flux2Pro(prompt: "A cinematic mountain lake"),
    onUpdate: { update in
        print(update.status as Any)
    }
)

Use WebSocket tracking for realtime events:

let result = try await client.subscribe(
    Wiro.flux2Pro(prompt: "A cinematic mountain lake"),
    trackingMode: .webSocket
)

Use subscribeStream when a for try await loop is more convenient than a callback:

for try await update in try await client.subscribeStream(
    Wiro.flux2Pro(prompt: "A cinematic mountain lake")
) {
    print(update.status as Any)
}

WebSocket tracking falls back to polling when the socket closes before a terminal event. To manage submission and tracking separately:

let run = try await client.run(
    Wiro.flux2Pro(prompt: "A cinematic mountain lake")
)
guard let token = run.taskToken else { return }
let task = try await client.waitForTask(token)

Uploads

File parameters take WiroFileInput values. Unresolved file inputs are uploaded automatically before /Run.

// Device-local bytes
let input = WiroFileInput.data(imageData, fileName: "photo.png")

// Already-hosted file
let hosted = WiroFileInput.url(
    URL(string: "https://example.com/photo.png")!
)

let result = try await client.subscribe(
    Wiro.model("owner/project", parameters: ["image": .fileInput(input)])
)

To manage uploads yourself, call uploadFile(_:fileName:) for in-memory bytes, or uploadFile(at:fileName:) to stream a local file from disk without loading it fully into memory:

let upload = try await client.uploadFile(imageData, fileName: "photo.png")
let url = upload.files.first?.url

Task cancellation and lifecycle

  • Cancel the Swift Task that awaits a call to stop local work immediately; the SDK surfaces WiroError.cancelled.
  • Call cancelTask(taskID) when a queued task id is known.
  • Call killTask(token) or killTask(taskID) to stop a remote worker.
  • Tie tracking to the owning view or model lifetime so navigation does not leak work. Do not auto-restart a billable run after a relaunch unless the user explicitly taps Generate again.

Model runs and file uploads are never retried automatically because they can create duplicate billable work. Retries apply to read-like operations such as model and task lookup, and rate-limit retries respect Retry-After.

Errors

do {
    _ = try await client.explore()
} catch let error as WiroError {
    switch error {
    case .apiResult(let message, let code, _, _):
        print(code as Any, message)
    case .authentication:
        break
    case .validation, .schemaValidation:
        break
    case .rateLimited(_, _, let retryAfter, _):
        print(retryAfter as Any)
    case .network, .webSocket, .timedOut:
        break
    case .cancelled:
        break
    case .unknownAPI(let message, let statusCode, _):
        print(statusCode, message)
    }
}

The Wiro AI API can report application-level failures with HTTP 2xx and "result": false. Those responses surface as WiroError.apiResult.

Security guidance

  • Ship App Store builds in proxy mode.
  • Never log API keys, secrets, proxy tokens, or raw response bodies.
  • Error descriptions exclude credentials, headers, and request bodies; use responseBody only for local diagnostics.
  • Do not commit credentials to the repository.

Example app

open Example/WiroExample.xcodeproj

Configure an API key or proxy URL in Settings, enter a prompt, and tap Generate. See Example/README.md.

Agent skill

This repository includes an agent skill, wiro-swift, in skills/wiro-swift/SKILL.md. It shows coding agents such as Claude Code, Codex and Cursor how to use WiroKit in iOS apps. Add it to your agent with:

npx skills add wiroai/Swift-QuickStart --skill wiro-swift

Documentation

Development

xcodebuild test -scheme WiroKit \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  -enableCodeCoverage YES

xcodebuild docbuild -scheme WiroKit \
  -destination 'generic/platform=iOS'

xcodebuild build -project Example/WiroExample.xcodeproj \
  -scheme WiroExample \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  CODE_SIGNING_ALLOWED=NO

More from Wiro AI

Repository What it is
Wiro-MCP Official MCP server for Wiro AI, @wiro-ai/wiro-mcp on npm
Wiro-LLM Vercel AI SDK provider for chat, images, speech, transcription and video, @wiro-ai/wiro-llm on npm
Wiro-Chromium-Extension Wiro AI extension for Chrome, Edge, Opera and Brave
Wiro-Firefox-Extension Wiro AI add-on for Firefox
Wiro-Safari-Extension Wiro AI extension for Safari on the Mac
Wiro-Plugin Wiro AI plugin for Cursor, Claude Code, Gemini CLI, Devin, Antigravity and Kiro
Wiro-Skills Agent skills for images, image edits, video, music, speech, transcripts, 3D and model search
Kotlin-QuickStart WiroKit, the Wiro AI SDK for Android
Dart-QuickStart Wiro AI SDK for Dart and Flutter, wiro on pub.dev
ReactNative-QuickStart Wiro AI SDK for React Native and Expo, @wiro-ai/wiro-react-native on npm
Swift-Realtime Realtime voice AI example for iOS
Kotlin-Realtime Realtime voice AI example for Android
Dart-Realtime Realtime voice AI example for Flutter
ReactNative-Realtime Realtime voice AI example for React Native
n8n-nodes-wiro One Wiro AI node for n8n with a searchable model picker, @wiro-ai/n8n-nodes-wiro on npm
Wiro-Dify-Plugin Wiro AI plugins for Dify: the LLM gateway as a model provider, plus image, video, speech and music tools
Wiro-ComfyUI Wiro AI nodes for ComfyUI
Wiro-Hermes Wiro AI plugins for Hermes Agent: image, video, audio and 3D tools, plus the LLM gateway as a model provider
Wiro-Zed Wiro AI MCP server extension for Zed
Wiro-Action GitHub Action for Wiro AI models and the LLM gateway, on the GitHub Marketplace
Wiro-Raycast Wiro AI extension for Raycast: image and video generation, LLM chat and model search
Wiro-WordPress Wiro AI plugin for WordPress: featured images, image edits, alt text, narration and SEO suggestions
Wiro-Obsidian Wiro AI plugin for Obsidian: images, video, speech, music, transcription and text tools
Wiro-Blender Wiro AI add-on for Blender: text to 3D, image to 3D and textures
Wiro-Figma Wiro AI plugin for Figma: images, vectors, image edits and text
Wiro-Next-Starter Next.js starter for Wiro AI: Playground, image, video and audio tools, and LLM chat, ready for Vercel and Railway
Wiro-Docs Source of the Wiro AI API docs
wiroai.github.io Every open-source project from Wiro AI on one page, with a page for each repository

Website · Models · Docs · X

License

MIT. See LICENSE.

Wiro AI koala mascot

About

Official Swift SDK for the Wiro AI API (WiroKit): run image, video, audio and LLM models from iOS apps with typed requests and live task tracking.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages