RoadieKit is a small Swift SDK for AI image generation and editing. It authenticates each device anonymously — no login screen and no provider key in the app — and calls the OpenAI-compatible image surface at /openai/v1. Roadie holds your OpenAI key (BYOK), meters usage per device, and enforces free-vs-pro limits.
RoadieKit is images-only today (generation and editing). For chat and embeddings on iOS, point a third-party OpenAI-compatible Swift client at the same surface — see chat on iOS below and the OpenAI drop-in page.

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. 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.
To create an image from a prompt alone, use images.generate:
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.

4. 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.

Chat and embeddings on iOS

RoadieKit does not cover chat. Point any OpenAI-compatible Swift client at the same surface — the base URL and bearer token are the only changes:
See OpenAI drop-in and Using OpenAI SDKs.

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.

Image enhance tutorial

A complete image-editing feature end to end.

RoadieKit reference

The full image API and token providers.