RoadieKit is a small Swift SDK for chat, embeddings, and AI image generation and editing. It authenticates each device anonymously — no login screen and no provider key in the app — calling Roadie’s native /v1 surface for chat and embeddings and the OpenAI-compatible surface at /openai/v1 for images. Roadie holds your provider keys (BYOK), meters usage per device, and enforces free-vs-pro limits.

Prerequisites

In the dashboard:
  1. Create a project (its development and production environments are created for you).
  2. Connect an OpenAI provider credential (BYOK). Image generation uses gpt-image-1, so an OpenAI key is required. See Providers & BYOK.
  3. Create a publishable key (rd_pk_…). It ships in the app and can only mint device tokens — it cannot call model endpoints.
  4. For local development, create a secret key (rd_sk_…) or pre-mint a client token to use as a static bearer while you build (see step 2).
  5. For production device auth, enable device attestation on the project (Apple App Attest). See Mobile device auth.

1. Install RoadieKit

Add RoadieKit with Swift Package Manager. In Xcode, choose File → Add Package Dependencies… and enter https://github.com/paroaria/roadiekit.git, or add it to Package.swift:
RoadieKit requires iOS 18+.

2. Configure the client

A Roadie client needs a RoadieConfig (where the gateway lives) and a token provider (how each request is authenticated). Swap the provider between local development and production without changing any call site:
  • StaticTokenProvider — a fixed bearer read from the run scheme’s ROADIE_STATIC_TOKEN environment variable (an rd_sk_… key or a pre-minted client token). The working simulator / dev path.
  • AppAttestTokenProvider — silently mints a per-device client token via Apple App Attest, using the publishable key. The production path; it needs a real device (App Attest is unavailable in the simulator).
Keep configuration out of source: read the base URL and publishable key from Info.plist (RoadieBaseURL / RoadiePublishableKey) and inject ROADIE_STATIC_TOKEN from the run scheme so it is never committed or shipped in a Release build.

3. Chat and embeddings

Chat and embeddings are the simplest calls and live on Roadie’s native /v1 surface. Send a message and read the reply:
Stream the reply token-by-token with roadie.chat.stream(_:) (an AsyncThrowingStream of typed events), and embed text with roadie.embeddings.create(_:). See the RoadieKit reference for the full chat, streaming, and embeddings API, and the Send a message tutorial for an end-to-end walkthrough.

4. Generate an image

images.generate creates an image from a prompt alone and returns the generated image’s raw PNG bytes:
The image model defaults to gpt-image-1 (set RoadieConfig.imageModel to change it), and n defaults to 1. size is one of .auto, .square, .landscape, .portrait; background is .transparent, .opaque, or .auto (when omitted, generate defaults to .opaque and edit to .transparent); quality is .low, .medium, .high, or .auto.

5. Edit an image

images.edit takes the source PNG bytes and a prompt and returns the generated image’s raw PNG bytes. mask is optional; when present, only the masked region is regenerated.

6. Handle errors

Every HTTP or decoding failure is thrown as a RoadieError; task cancellation is Swift’s own CancellationError. Branch on error.kind:
RoadieKit handles two cases for you: it re-mints once on a 401 (an expired client token) and retries transient network and 5xx failures. An insufficientQuota error is your cue to show the paywall — see Free → Pro with StoreKit.

Next steps

Anonymous device auth

How App Attest mints per-device client tokens with no account.

Free → Pro with StoreKit

Convert the free tier to a paid subscription and flip the device’s plan.

Send a message

Set up the SDK, send a chat message through Roadie, and get a reply.

RoadieKit reference

The full chat, embeddings, and image API, plus the token providers.

Android quickstart

The same for Android, with the Kotlin SDK and Play Integrity device auth.