cd /news/ai-tools/hybrid-llm-routing-on-iphone-local-m… · home › topics › ai-tools › article
[ARTICLE · art-170479] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Hybrid LLM routing on iPhone: local models plus cloud APIs with Shortcuts

A developer built a hybrid LLM router inside Apple Shortcuts that keeps short or sensitive prompts on a local OpenAI-compatible model and sends longer requests to a cloud API, using a simple 200-character length check to branch between the two. The shortcut requires no Xcode or custom iOS app, relying on two HTTP request actions and a conditional, with the developer noting the API key stored in a shortcut should be treated as a low-limit throwaway credential and rotated if the phone is shared.

by read3 min views2 publishedNov 16, 2026

Most of the prompts I type on my phone are trivial — a quick rewrite, a two-line summary, a "what does this mean" question. Sending all of those to a paid cloud endpoint felt wasteful, and some of them contained things I would rather not upload at all. So I built a small router in Apple Shortcuts that keeps the light and sensitive requests on a local model and only sends the heavy lifting to a cloud API.

No Xcode, no full iOS app. Just Shortcuts, an HTTP request, and one length check.

The idea is simple: one shortcut, two branches.

Everything happens inside Shortcuts, Apple's built-in automation app, which chains actions into a single runnable script. You can trigger it from the app, from Siri, or from the Share Sheet.

Before touching Shortcuts, make sure the pieces talk to each other:

http://127.0.0.1:8080/v1/chat/completions. The port depends on your app. sk-) that identifies your account. My checklist before I started:

That last item matters more than it sounds. Two "OpenAI-compatible" endpoints can still disagree on field names, and you will only find out at runtime.

Write the rule down before you build anything. Mine looked like this:

The 200-character threshold is a heuristic, not science. Short prompts are usually cheap and fast enough for a small on-device model. If yours handles more, raise the number.

Hybrid AI Router. You get an empty canvas. Summarize this note in three bullets: The meeting moved to Friday. Later you can swap this for Shortcut Input when you run it from Siri or the Share Sheet.Length → is less than → 200. You now have two branches. A prompt like What is 2+2? is 8 characters, so it falls into the local branch. A request for a 500-word essay lands in the cloud branch. That is the whole routing logic — everything else is plumbing.

Inside the If branch:

POST. Content-Type: application/json. Then add a Request Body in JSON. This template works for most local runtimes, since they tend to speak the OpenAI-compatible chat format:

{
  "model": "your-local-model",
  "messages": [
    {"role": "user", "content": "What is 2+2?"}
  ],
  "temperature": 0.7
}

Replace your-local-model with the model name your app reports. If your app ignores the model field, delete that line entirely. A correct run ends with your local app returning a JSON response that the shortcut can read.

In the Otherwise branch, add a second Get Contents of URL:

https://api.example.com/v1/chat/completions. model field and the actual prompt in content. One practical note: keeping the API key inside a shortcut is convenient but not a vault. Anyone with access to your unlocked phone can open the shortcut and read it. Treat a shortcut key as a low-limit throwaway credential, and rotate it if the phone is shared.

Do not trust a single happy-path run. I tested by editing the Text action:

If the local branch fails, open the local URL in Safari first — if Safari cannot reach it, Shortcuts will not either. If the cloud branch fails, re-test the key from a desktop curl call to separate an auth problem from a shortcut problem.

Two things I would change next time: switching the Text action to Shortcut Input so the router works from Siri and the Share Sheet, and adding a fallback so a failed cloud call retries locally instead of just erroring out.

You do not need a custom app to get hybrid AI on an iPhone. A length check and two HTTP actions in Shortcuts are enough to keep cheap, private prompts on-device and spend cloud tokens only where they buy you something. Start with a crude rule like 200 characters, run both branches deliberately, and tune the threshold based on what your local model actually handles well. If you are still choosing which local model to run, AI Release also has beginner guides for running models locally on a PC and on Android — worth a read before you hardcode a gateway.

This article was originally published on AI Release — https://ai-release.org

More practical AI guides and breakdowns: https://t.me/ai_release1

── more in #ai-tools 4 stories · sorted by recency
── more on @apple 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/hybrid-llm-routing-o…] indexed:0 read:3min 2026-11-16 · —