omp packages

@underactive/pi-subq-provider0.1.0

SubQ provider for Pi: Savant for chat and Snap as a decision model

underactive Published 1 day ago MIT ~0 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

SubQ for Pi

Adds SubQ's two models to Pi:

  • Savant (subq-savant-1.4), a reasoning model for chat with a 4M-token context window.
  • Snap (subq-snap-1.2), a decision model. It answers yes/no, choice and score questions with probabilities instead of generating text.

Requires Pi 1.7.0 or newer and Node 22.19+.

Setup

1. Get an API key

Create an account at console.subq.ai and generate a key on the API keys page. One key works for both models.

2. Install the package

pi install npm:@underactive/pi-subq-provider

This adds the package to ~/.pi/agent/settings.json. Add --local to install it only for the current project (.pi/settings.json). To try it for one session without installing:

pi -e npm:@underactive/pi-subq-provider

3. Add your key

In Pi, run:

/login subq

Or run /login, choose Sign in with an API key, and select Subquadratic. The list is long; type subq to filter it.

Either way, Pi prompts for the key and stores it in ~/.pi/agent/auth.json, scoped to the subq provider. It is kept separate from your other provider credentials.

Or set it in your environment before starting Pi:

export SUBQ_API_KEY="your-key"

If an interactive session starts with Savant selected and no key, the extension shows a warning pointing to /login subq.

4. Select the model

Pick SubQ Savant 1.4 with /model, or start with it directly:

pi --model subq/subq-savant-1.4

Snap is not a chat model, so it is not listed in /model. See Snap.

Models

Model ID Use Context Input Price per 1M tokens
SubQ Savant 1.4 subq-savant-1.4 Chat 4M Text, images $0.10 input, $0.01 cached input, $0.50 output
SubQ Snap 1.2 subq-snap-1.2 Decisions 384K Text, images $0.04 input, output free

These are SubQ's published rates when this version was released, and Pi uses them to estimate cost. They can change.

The extension registers the versioned IDs, not the -latest aliases. SubQ applies a model's own rate limits only to its exact ID; an alias counts against the organization's shared pool unless SubQ has given the alias limits of its own.

Savant (chat)

Savant uses Pi's OpenAI Chat Completions transport, so streaming, tool calls, image input, retries, cancellation and context compaction work as they do for Pi's built-in providers.

  • Thinking levels. Savant has three reasoning efforts, and Pi offers exactly those: low, high and max. Savant cannot stop reasoning, so there is no off. A session set to another level moves up to the next one offered: off and minimal run as low, medium as high, and xhigh as max. A request that sets no level uses SubQ's default, high.
  • Reasoning cost. Reasoning appears as thinking and is billed as output tokens. A short answer can cost many more output tokens than its visible text.
  • Output limit. Requests cap output at 128,000 tokens (max_tokens), which reasoning and the answer share. This is the limit SubQ's coding-agent guide uses.
  • Temperature. Savant accepts only a temperature of 1, so the extension always sends 1. A temperature set by another extension or an SDK caller is replaced.

Snap (decisions)

Pi lists Snap as a decision model (model type classifier). It takes a JSON state and named questions, and answers each one:

Question Asks Answer
bool Yes or no probability of yes, from 0 to 1
choice Which one of the named options choice, probabilities for every option, and confidence
score A rating on 2 to 10 ordered levels score, which can fall between two levels, and confidence

One request can ask up to 128 questions about the same state, and can include up to four PNG, JPEG or WebP images.

From codemode

The model reaches Snap through Pi's codemode tool. Enable the tool with "defaultTools": ["+codemode"] in Pi's settings. A script then calls Snap like this:

const snap = await models.getModelOfType("classifier", "subq", "subq-snap-1.2");
const result = await models.classify(snap, {
  state: { message: "The change works, thanks." },
  questions: {
    approved: {
      type: "bool",
      instructions: "Does the user approve of the result?",
      criteria: { true: "Approval", false: "No approval" },
    },
  },
});
return result.stopReason === "stop" ? result.answers : result.errorMessage;

The script returns the answers by question name, for example { approved: { type: "bool", probability: 0.97 } }. Pi adds the cost of each call to the codemode tool result, so it counts toward the session cost.

From an extension

Extensions call Snap through the model registry, for example to route a request inside a virtual model:

const snap = ctx.modelRegistry.findOfType("classifier", "subq", "subq-snap-1.2");
const result = await ctx.modelRegistry.classify(snap, { state, questions }, { signal });

Behavior

  • Calls do not throw. Check result.stopReason: on "error" or "aborted", result.errorMessage holds SubQ's reason, such as SubQ Decisions API error (422): validation_error: questions/queue: must have required property 'criteria'.
  • Rate-limited (429) and failed (5xx) requests are retried twice with backoff. Every other failure is reported at once.
  • SubQ bills decisions by input tokens only. result.usage holds the count and its cost.
  • SubQ calls the yes/no question type noul. Pi calls it bool, and the extension converts between the two.
  • SubQ also returns a probability for each level of a score question. Pi's score answer has no field for them, so they are not passed on.

Configuration

Variable Default Effect
SUBQ_API_KEY none API key, if not set with /login subq

Update and remove

pi update --extensions
pi remove npm:@underactive/pi-subq-provider

Development

To run a local checkout instead of the published package:

pi -e /absolute/path/to/pi-subq-provider/index.js

Inside Pi the extension needs no installed dependencies: it imports only module specifiers Pi resolves for extensions. For local tests, install the development dependencies and run:

npm install
npm test
nvm use                # Node 22.19, the minimum supported version
npm run check          # tsc --noEmit on the JSDoc types, ESLint, Prettier check
npm run format         # apply Prettier
npm run test:coverage  # tests with Node's built-in coverage report

npm run check type-checks the provider registration against Pi's own ExtensionAPI types in strict mode, so a misspelled model or compatibility setting fails the check instead of being ignored at runtime.

Tests use mocked HTTP and need no API credentials. The Savant tests run Pi's own Chat Completions transport with this extension's model settings and check the request it builds (token limit field, temperature, reasoning effort, omitted fields) and how it reads a SubQ stream (reasoning, usage, cost, tool calls, context overflow, rate limits, truncated streams). The Snap tests cover the request and response shapes in SubQ's API reference, images, every malformed answer, error formats, retries, timeouts, cancellation, request hooks and headers.

Sources

License

MIT