---
slug: "alexeiled-pi-provider-compat"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/alexei-led/pi-provider-compat@main/README.md"
repo: "https://github.com/alexei-led/pi-provider-compat"
source_file: "README.md"
branch: "main"
---
# @alexeiled/pi-provider-compat

[![npm version](https://img.shields.io/npm/v/%40alexeiled%2Fpi-provider-compat?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@alexeiled/pi-provider-compat)
[![CI](https://img.shields.io/github/actions/workflow/status/alexei-led/pi-provider-compat/ci.yml?branch=main&style=flat-square&label=ci)](https://github.com/alexei-led/pi-provider-compat/actions/workflows/ci.yml?query=branch%3Amain)
[![license](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](./LICENSE)

A compatibility bridge for Pi custom providers that use `streamSimple`.

## Problem

Pi 0.80 moved the old global `pi-ai` dispatcher to `@earendil-works/pi-ai/compat`.
Custom providers registered with `pi.registerProvider()` are provider-scoped, but some
extensions still call the global compat dispatcher directly.

That mismatch produces errors such as:

```text
No API provider registered for api: router-local-api
No API provider registered for api: openai-codex-personal-responses
```

It can affect model routers, provider aliases, watchdogs, background commands, and any
extension that calls `stream()` or `streamSimple()` from `@earendil-works/pi-ai/compat`.

## What it does

This extension discovers every registered provider with both:

- `api`
- `streamSimple`

It registers a provider-aware dispatcher for that API in the compat registry when no
compat provider is already registered. Calls route by `model.provider`. Existing compat
providers are left untouched, preserving their ownership and reload cleanup. The bridge
refreshes on session/model lifecycle events and removes only its own registrations.

There are no provider-specific names or allowlists.

## Install

```bash
pi install npm:@alexeiled/pi-provider-compat
```

Reload Pi:

```text
/reload
```

Then retry the command that failed.

## Requirements

- Pi `>=0.80.8`
- A custom provider registered with `pi.registerProvider(..., { api, streamSimple })`

Pi packages its core libraries. This package declares them as peers and does not bundle Pi.

## Scope

This is a compatibility workaround for extensions that use the legacy global dispatcher.
It does not replace a provider implementation, register credentials, or change model routing.
It does not override an API that already has a compat provider, and it does not help an API
that has no registered provider-scoped `streamSimple` implementation.

The durable upstream fix is for Pi to bridge `registerProvider()` registrations into the
compat registry itself, or for callers to use Pi's provider-scoped runtime.

## Development

```bash
npm install
npm run test:all
```

The tests cover custom routing, preservation and cleanup of an existing compat provider,
refresh after provider changes, type checking, and the npm package manifest.

## License

MIT
