omp packages

@flop-labs/pi0.3.1

FLOP verified inference for Pi and Pi Durable, with model routing and replay-safe paid jobs

svidyuk Published 7 days ago MIT OR Apache-2.0 ~320 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

@flop-labs/pi

A Pi package that adds FLOP verified inference to Pi:

  • the flop provider, with one model for each offer the FLOP gateway currently lists;
  • the flop/auto virtual model, which picks a FLOP model for each request.

The gateway lists an offer only while an attested, identity-verified, priced, and healthy compute session serves it. Each response is settled through a FLOP compute channel. Pi records the physical model behind every answer, and /session breaks cost down per model.

Requires Pi 1.4 or later; the extension refuses to load on an older Pi. Virtual models are still experimental in Pi.

For applications built on Pi Durable, see DURABLE.md: the durable subpath exposes a physical-model provider and a native flop_infer tool with persistent request IDs and receipt metadata, plus a SQLite-backed example and the memory/settlement integration map.

MEMORY.md describes the experimental memory subpath: native remember/recall tools over a host-supplied verified-memory client, with isolated namespaces, durable operation records and an encrypted local conformance example. The paid-memory SDK and provider binding remain prerequisites for real FLOP storage.

For Cloudflare Workers, see CLOUDFLARE.md: Cloudflare's installation command and a private RPC example using agents/harness/pi, Lifecycle SQLite and the native FLOP provider/tool.

Install

The package is published to GitHub Packages for now, not npm. Its npm registry needs a GitHub token with read:packages even for public packages, so route the @flop-labs scope in your user npm config first; pi install reads it:

npm config set @flop-labs:registry https://npm.pkg.github.com
npm config set //npm.pkg.github.com/:_authToken "$(gh auth token)"  # or a classic token with read:packages
pi install npm:@flop-labs/pi   # add the package to your Pi settings

Applications that import the subpaths (@flop-labs/pi/durable, /memory, /memory/paid-storage) install it with npm install @flop-labs/pi instead.

From a checkout of this repository, build the package first; Pi loads dist/index.js:

pnpm --filter "@flop-labs/pi..." run build
pi install ./sdk/pi            # add the package to your Pi settings
pi -e ./sdk/pi/src/index.ts    # or load the source for one run

Configure

Variable Required Meaning
FLOP_GATEWAY_URL yes FLOP inference gateway, for example http://127.0.0.1:3200 for a local stack. Without it the extension fails to load, and Pi reports the error.
FLOP_API_KEY yes Gateway credential. Without it the FLOP models are unavailable. Use a bounded child credential (flop_ek_… from POST /v1/keys/ephemeral or POST /v1/connect/grants) with a spend cap, rather than an owner key.
FLOP_PI_FALLBACK_MODEL no provider/model that answers after every FLOP model has failed in the current turn, for example anthropic/claude-sonnet-4-5. Answers from this model are not FLOP-verified. In interactive mode Pi shows a warning when it switches to the fallback. Leave it unset to keep flop/auto FLOP-only.

Example ~/.pi/agent/settings.json that starts Pi on flop/auto:

{
  "packages": ["npm:@flop-labs/pi"],
  "defaultProvider": "flop",
  "defaultModel": "auto",
  "defaultThinkingLevel": "low"
}

The package reads the catalog once, when it loads. Run /reload to pick up offers added later. Discovery uses @flop-labs/client and the shared public API contracts, with a ten-second deadline and redirects disabled. Catalog validation checks the response's structure; Pi retains its price, limit and capability checks. Inference continues through Pi's Anthropic Messages transport.

How flop/auto routes

Request Routed to
New user message A FLOP model chosen by the thinking level you selected. low picks the cheapest model whose context window fits the conversation, high the most expensive, and medium the one in between. FLOP prices each token by the compute it meters for it, so price order follows model size.
Tool follow-up in the same turn The model already answering that turn, so its prompt cache stays valid.
Retry after a context overflow The FLOP model with the largest context window.
Retry after any other failure The next FLOP model. Failed models are kept as router state on the session branch, so they survive compaction and follow /tree. The failure list resets at the next user message.
Every FLOP model failed this turn FLOP_PI_FALLBACK_MODEL if it is set. Otherwise the request fails.

The thinking level is also forwarded to the model that was picked, and Pi clamps it to what that model supports. A model without reasoning runs with thinking off. A reasoning model accepts low, medium, or high effort, and a request for off runs at low, because the gateway cannot disable thinking.

A stream that fails before any output is retried. The gateway released that request's reservation, so Pi records no cost for the failed attempt. A stream that fails after output has been committed is not retried, because the gateway already charged for it.

Task correlation

Each agent run, meaning a prompt together with its tool turns and retries, sends one random X-Correlation-ID on its FLOP requests. The next prompt gets a new id. The gateway uses the id to group a task's turns in its usage labels. The id carries no prompt text, and requests routed to the fallback model do not send it.

Limits

  • Text only. The gateway's Messages bridge accepts text and tool blocks, so Pi sends placeholders in place of images.
  • Every model is FLOP-verified. All listed models carry the same attestation, so the router has no verification tier to choose between.
  • Subagents. pi-subagents children can start on flop/auto from pi-subagents 0.75.0 (nicobailon/pi-subagents#2635). With an older release, give them a physical model such as flop/<model-id>.
  • Unknown model at prompt time. before_agent_start handlers see ctx.model.api === "pi-virtual" and cannot know which physical model will answer (earendil-works/pi#10318).

Develop

pnpm --filter @flop-labs/pi typecheck
pnpm --filter @flop-labs/pi test

tests/gateway-contract.test.ts sends Pi's real Anthropic request through the gateway's own request validator (services/rest-gateway/src/agent-protocol.ts). A gateway change that rejects what Pi sends fails this package's tests.