npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ipa-prompt-api-fallback

v0.2.0

Published

Chrome Prompt API compatibility backend for ipa-tools createInference fallbacks

Downloads

358

Readme

ipa-prompt-api-fallback

Chrome Prompt API (LanguageModel) compatibility backend for ipa-tools createInference({ fallbacks }).

This is not IPA. There is no origin permission prompt, no user-chosen provider/model, and no permission_denied from the browser. Do not assign the adapter to window.inference. isInferenceAvailable() / getInference() / waitForInference() stay false/throwing on the fallback path.

Install

npm install ipa-tools ipa-prompt-api-fallback

npm

Peer dependency: ipa-tools >=0.6.0. Zero other runtime deps. Browser ESM only.

ipa-tools does not import this package. Your app imports both and passes the backend object into fallbacks.

Usage

import { createInference } from "ipa-tools";
import { createPromptApiBackend } from "ipa-prompt-api-fallback";

const inference = createInference({
  fallbacks: [createPromptApiBackend()],
  onDownloadProgress(loaded) {
    status.textContent = `Downloading on-device model… ${Math.round(loaded * 100)}%`;
  },
});

const status = await inference.probe();
// { ipa: "unavailable", promptApi: "downloadable" }

sendButton.addEventListener("click", async () => {
  if (status.ipa === "unavailable" && status.promptApi !== "unavailable") {
    const ok = await confirm(
      status.promptApi === "downloadable" || status.promptApi === "downloading"
        ? "No inference extension found. Chrome can use an on-device model (a few GB download). Continue?"
        : "No inference extension found. Use Chrome’s on-device model on this device?"
    );
    if (!ok) return;
  }

  const { message } = await inference.complete({
    method: "chat",
    messages: [{ role: "user", content: input.value }],
  });
  reply.textContent = message.content ?? "";
});

Resolve happens lazily on first complete / request / runTools (inside a user gesture). LanguageModel.create() is not called at module load. probe() / getPromptApiAvailability() never start the download.

Chrome requirements

  • Chrome with the Prompt API available (see Chrome AI docs).
  • Hardware / storage requirements for Gemini Nano (often several GB on first download).
  • User activation for LanguageModel.create().
  • Disclose download size when promptApi is "downloadable" — Chrome will not warn for you.

Raw availability (Chrome-specific) without going through createInference:

import { getPromptApiAvailability } from "ipa-prompt-api-fallback";

const promptApi = await getPromptApiAvailability();

Mapping caveats

| IPA | Prompt API adapter | | --- | --- | | accepted | Synthesized (not a permission prompt) | | delta / done | From promptStreaming() (lossy) | | usage | Omitted | | tools / toolCalling / webSearch | Unsupported (getFeatures().toolCalling === false; webSearch absent) | | imageInput / imageOutput / output.images | Unsupported (imageInput / imageOutput absent; image parts and output.images are invalid_request) | | Provider / model picker | None — done.model is "on-device" |

API

| Export | Role | | --- | --- | | createPromptApiBackend() | InferenceBackend with id: "promptApi" | | getPromptApiAvailability() | Chrome LanguageModel.availability() wrapper | | CreatePromptApiBackendOptions | Optional expected input/output languages | | PromptApiAvailability | "unavailable" \| "downloadable" \| "downloading" \| "available" |

Local development

From the repo root (npm workspaces):

npm install
npm run build -w ipa-prompt-api-fallback
npm test -w ipa-prompt-api-fallback

POC: examples/prompt-api-fallback (also on GitHub Pages).