AdaptiveModelRouting
Swift package · iOS and macOSv0.3.0 · 20 November 2026

AdaptiveModelRouting

Route each request using measured response times and the providers your app allows.

By Cory Parry · Updated

Diagram showing a request routed to either an on-device or a cloud model
Routing policy sets which providers are eligible. When both are allowed, the router uses measured response times to choose between them.

About the project

AdaptiveModelRouting chooses between on-device and cloud language models. It learns from comparable requests and uses those timings to pick a provider when both are allowed. Use Apple Foundation Models and Private Cloud Compute, or supply your own providers.

Choose where requests go

Keep a request on-device with localOnly, require a cloud model with cloudRequired, or use automatic routing when both providers are permitted.

Use your preferred providers

Use the Apple adapter or supply your own local and cloud providers. The package supports text, structured output, and streaming.

Inspect routing decisions

Detailed results show which provider was selected, which one answered, and how long foreground attempts took.

Who is AdaptiveModelRouting for?

Swift developers adding language model features to iOS or macOS apps who want control over where requests run.

Install AdaptiveModelRouting

  1. In Xcode, choose File → Add Package Dependencies and enter https://github.com/coryparrry/AdaptiveModelRouting.git.
  2. Select version 0.3.0 and add the AdaptiveModelRouting library to your target.
  3. For Swift Package Manager, use .upToNextMinor(from: "0.3.0") with the repository URL and add the AdaptiveModelRouting product to your target.
View the v0.3.0 release ↗

Route your first request

  1. Set up the Apple adapter or supply your own providers.
  2. Choose a request policy based on where the prompt is allowed to go.
  3. Try a local-only request first, then inspect detailed results to see which provider answered.

Requirements and limitations

  • Build with an iOS or macOS 27 SDK.
  • The core router runs on iOS 26+ and macOS 26+. The Apple adapter requires iOS 27+ or macOS 27+.
  • Apple Private Cloud Compute requires the appropriate managed entitlement and app signing.

Automatic calibration can send the same prompt to both providers. Choose localOnly for prompts that must stay on-device. The v0.3.0 release adds opt-in aggregate usage reporting.

Read the package documentation ↗

AdaptiveModelRouting: common questions

How does AdaptiveModelRouting choose a provider?

When both providers are allowed, AdaptiveModelRouting uses measured response times from comparable requests to choose the provider it expects to answer faster. Your app can also require that a request stays on-device or uses the cloud.

Where can I get AdaptiveModelRouting v0.3.0?

The MIT-licensed Swift package and the v0.3.0 release notes are available on GitHub. Add the package repository in Xcode or as a Swift Package Manager dependency.

Sources and further reading

Plain-text project guides