Skip to content

About

pi coding-agent provider for SingularityAPI — 13 chat models (DeepSeek V3.2/V4, Kimi K2/K3, GLM 5.3, GPT-5.6/6-Astra) with live catalog sync, verified thinking levels, cached-input pricing, and per-request receipts

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

π pi-singularity-provider

DeepSeek, Kimi, GLM, GPT, and Claude models via SingularityAPI

Live catalog metadata — context windows, output limits, exact pricing — plus per-request receipts for pi.

pi extension license


Features

  • Curated catalog — 21 chat models across the DeepSeek, Kimi, GLM, GPT, and Claude families through one OpenAI-compatible endpoint
  • Live metadata sync — models, context windows, max output tokens, and exact per-token pricing refreshed from GET /v1/models on session start (stale-while-revalidate; zero-latency startup from embedded snapshot + disk cache)
  • Reasoning models — thinking levels for every reasoning-capable model, all gateway-verified: GPT-5.6 family (explicit reasoning_effort, tool-safe), DeepSeek/Kimi/GLM at low/medium/high, Kimi K3 / GPT-6 family / Claude Sonnet·Opus·Fable at all five levels — see Thinking Mode
  • Receipts — every response carries an x-singularity-receipt-id header; /singularity-receipt shows the exact tokens, cost, and latency for any request

Installation

pi install <source> downloads the package into pi's agent directory, reads the "pi": {"extensions": ["./index.ts"]} manifest in its package.json, and adds the source to your pi settings — so the extension loads automatically on every start, no -e flag needed. Manage it later with pi update pi-singularity-provider, pi remove pi-singularity-provider, and pi list. Add -l to any install to record it project-locally (.pi/settings.json) instead of user-wide.

Option 1: npm (recommended)

pi install npm:pi-singularity-provider

Option 2: GitHub

pi install https://github.com/wyrdwerk/pi-singularity-provider

(git:github.com/wyrdwerk/pi-singularity-provider and SSH forms work too.)

Option 3: Local clone

git clone https://github.com/wyrdwerk/pi-singularity-provider.git
pi install ./pi-singularity-provider     # persistent, same as above

or load it one-off without touching settings:

pi -e /path/to/pi-singularity-provider

Option 4: Any other agent or tool (not pi)

SingularityAPI works with any coding agent that accepts a custom OpenAI-compatible endpoint — no extension needed. Copy this block and give it to your agent:

Set up SingularityAPI as an OpenAI-compatible model provider for this agent.

- Base URL: https://api.singularityapi.dev/v1
- Auth: Bearer token, read from the SINGULARITY_API_KEY environment variable
- Models: fetch the live catalog from GET /v1/models and treat it as the source of
  truth for model IDs, context windows, output limits, and pricing. Register only
  entries with a /v1/chat/completions capability as chat models.
- Follow the full integration guide exactly (catalog format, reasoning levels,
  receipts, cost accounting):
  https://github.com/WyrdWerk/pi-singularity-provider/blob/main/INTEGRATING.md

INTEGRATING.md is agent-agnostic and carries everything that block references; see Using SingularityAPI with Other Agents and Tools.

Then set your API key

# Recommended: add to auth.json (see Authentication below)
# Or set as environment variable (Windows syntax differs — see Authentication)
export SINGULARITY_API_KEY=sapi_...

pi

Get your API key at app.singularityapi.dev (API keys → Create; the sapi_... key is shown once).

Available Models

Model Context Reasoning Input Max Output Input $/M Cached $/M Output $/M
Claude Fable 5.1 1M ✅ Text 128K $10.00 $0.15 $50.00
Claude Haiku 5.5 1M ❌ Text 128K $0.10 $0.006 $0.50
Claude Opus 5.5 1M ✅ Text 128K $3.00 $0.12 $16.00
Claude Sonnet 5.5 1M ✅ Text 128K $2.00 $0.12 $10.00
DeepSeek V3.2 128K ✅ Text 128K $0.186 — $0.28
DeepSeek V4 Flash 1M ✅ Text 384K $0.081 $0.007 $0.162
DeepSeek V4 Flash 0731 1M ✅ Text 384K $0.20 $0.007 $0.50
DeepSeek V4 Pro 1M ✅ Text 384K $0.392 $0.128 $0.783
DeepSeek V4.1 Flash 1M ❌ Text 384K $0.13 $0.003 $0.50
Deepseek V4.1 Flash 1017 1M ❌ Text 393K $0.09 $0.002 $0.36
GLM 5.3 1M ✅ Text 131K $1.17 $0.245 $3.96
GPT-5.6 Luna 1M ✅ Text 128K $0.18 $0.02 $1.10
GPT-5.6 Sol 1M ✅ Text 128K $2.40 $0.20 $14.00
GPT-5.6 Terra 1M ✅ Text 128K $1.80 $0.20 $10.00
GPT-6 Astra 1M ✅ Text 128K $8.00 $1.00 $30.00
GPT-6 Luna 1M ✅ Text 128K $0.10 $0.01 $0.40
GPT-6 Sol 1M ✅ Text 128K $1.80 $0.20 $8.00
GPT-6.1 Sol 1M ✅ Text 128K $2.00 $0.10 $10.00
Kimi K2.6 262K ✅ Text 262K $0.581 $0.128 $2.448
Kimi K2.7 Code 262K ✅ Text 262K $0.639 $0.152 $3.15
Kimi K3 1M ✅ Text 262K $2.50 $0.30 $14.00

Pricing and limits refresh live from GET /v1/models on session start (the endpoint is served cache-control: no-store, so what you see is always current). Table above mirrors the catalog as of 2026-10-21.

Usage

After loading the extension, use the /model command in pi to select your preferred model:

/model singularity deepseek-v4-flash

Or start pi directly with a SingularityAPI model:

pi --provider singularity --model deepseek-v4-flash

Thinking Mode

The GPT-5.6 models (gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna) are reasoning models using the openai thinking format (reasoning_effort). The extension always sends an explicit reasoning_effort for these models — including "none" when thinking is off — because SingularityAPI's upstream rejects tool calls that omit it ("Function tools with reasoning_effort are not supported…"). Level mapping: off→none, minimal/low→low, medium→medium, high→high.

All DeepSeek, Kimi, and GLM chat models — plus the GPT-6 family and Claude Sonnet/Opus/Fable — have reasoning enabled via patch.json, verified against the gateway (2026-09-13 and 2026-10-21 probes): DeepSeek/Kimi/GLM accept reasoning_effort at low/medium/high and return a reasoning_content thinking channel; kimi-k3, gpt-6-astra/luna/sol, gpt-6.1-sol, and claude-sonnet-5-5 / claude-opus-5-5 / claude-fable-5.1 additionally expose xhigh/max (400 on DeepSeek/Kimi/GLM; accepted on these). Minimal stays hidden. Thinking off sends no reasoning_effort at all — for GPT-6 Astra and GPT-6.1 Sol this is mandatory, since they 400 on reasoning_effort: "none" (the exact opposite of the GPT-5.6 rule above). Quirks: deepseek-v3.2 at low and GPT-6 models below max may not produce a visible thinking channel on short prompts (reasoning_items at max for Luna/Sol/6.1-Sol; reasoning_content for Claude). claude-opus-5-5 may still emit reasoning_content when no effort is sent. deepseek-v4.1-flash and claude-haiku-5-5 accept every level but never return a thinking channel, so they are registered non-reasoning. To revert everywhere, restore patch.json to {}; to disable for one model, delete just its entry.

Reasoning is populated dynamically. The extension reads reasoning capability straight from GET /v1/models whenever the API exposes it — no extension update needed. On the chat-completions capability entry (or the model itself), any of these shapes is recognized:

// canonical
"reasoning": { "supported": true, "efforts": ["none", "low", "medium", "high"] }
// also accepted
"reasoning": true
"reasoning_effort_values": ["none", "low", "medium", "high"]
"supported_parameters": ["max_tokens", "reasoning_effort", "stream"]

When the API speaks, it wins over the embedded curation — including an explicit "not supported". Levels map onto pi's thinking levels (off→none, minimal→low, others same-named; unsupported levels are hidden). While the API stays silent for a model, the curated entry stands, and patch.json remains the final override either way (see Patch Overrides).

Receipts

Every SingularityAPI response — including errors after admission and streams — carries x-singularity-request-id and x-singularity-receipt-id headers. The extension captures the latest receipt id automatically; to inspect exact tokens, cost, and latency:

/singularity-receipt            # last request's receipt
/singularity-receipt rcpt_...   # a specific receipt

usage and total_cost_usd are null until the receipt reaches a terminal state (settled); if they're pending, wait a moment and run the command again. Receipts only resolve for your own account.

Authentication

The SingularityAPI key can be configured in multiple ways (resolved in this order):

  1. auth.json (recommended, OS-independent) — Add to ~/.pi/agent/auth.json (%USERPROFILE%\.pi\agent\auth.json on Windows):

    { "singularity": { "type": "api_key", "key": "sapi_..." } }

    The key field supports literal values, env var names, and shell commands (prefix with !). See pi's auth file docs for details.

  2. Runtime override — Use the --api-key CLI flag

  3. Environment variable — Set SINGULARITY_API_KEY (syntax differs by shell):

    # Linux / macOS (bash, zsh) — current session; add to ~/.bashrc or ~/.zshrc to persist
    export SINGULARITY_API_KEY=sapi_...
    # Windows PowerShell — current session
    $env:SINGULARITY_API_KEY = "sapi_..."
    # persist for your user (takes effect in new sessions)
    [Environment]::SetEnvironmentVariable("SINGULARITY_API_KEY", "sapi_...", "User")
    :: Windows CMD — current session
    set SINGULARITY_API_KEY=sapi_...
    :: persist for your user (takes effect in new sessions)
    setx SINGULARITY_API_KEY "sapi_..."

Environment Variables

Variable Required Description
SINGULARITY_API_KEY No Your SingularityAPI key (sapi_...; fallback if not in auth.json)

Configuration

Add to your pi configuration for automatic loading:

{
  "extensions": [
    "/path/to/pi-singularity-provider"
  ]
}

Compat Settings

SingularityAPI speaks the OpenAI chat completions wire format, with one behavioral difference that shapes the compat config: unsupported or reserved parameters are rejected with a 400, never silently dropped.

  • maxTokensField: "max_completion_tokens" — max_tokens and max_completion_tokens are interchangeable on every chat model (sending both is a 400)
  • supportsDeveloperRole: false — all models use the system role, not developer
  • supportsStore: false — the store parameter is not supported

Patch Overrides

The patch.json file contains overrides that are applied on top of models.json data at runtime. This is useful for:

  • Marking a model as reasoning-capable when the API doesn't advertise it
  • Adding compat settings the API doesn't provide
  • Overriding pricing/context windows before the next sync

Updating Models

Run the update script to fetch the latest catalog from SingularityAPI:

export SINGULARITY_API_KEY=sapi_...
node scripts/update-models.js

This will:

  1. Fetch models from https://api.singularityapi.dev/v1/models
  2. Refresh pricing, context windows, and max output tokens from the live capabilities data
  3. Preserve curated metadata (reasoning, names, compat) for known models
  4. Move delisted models to deprecated-models.json (14-day grace period)
  5. Update models.json and the README model table

Note: the runtime already revalidates live on every session start, so this script is for refreshing the committed snapshot — not required for day-to-day freshness.

Using SingularityAPI with Other Agents and Tools

This extension is pi-specific, but SingularityAPI is not: any coding agent that can point at a custom OpenAI-compatible endpoint can use it with just the base URL and an API key. INTEGRATING.md is the complete, agent-agnostic integration guide — the /v1/models metadata format, request-parameter policy, reasoning levels, receipts, and cost accounting — so other agents (or their humans) can replicate everything this extension does for pi.

License

MIT

About

pi coding-agent provider for SingularityAPI — 13 chat models (DeepSeek V3.2/V4, Kimi K2/K3, GLM 5.3, GPT-5.6/6-Astra) with live catalog sync, verified thinking levels, cached-input pricing, and per-request receipts

Resources

Stars

3 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages