@tokenswim/pi

Use Tokenswim's OpenAI and xAI models in the pi coding agent with a single API key.

Packages

Package details

extension

Install @tokenswim/pi from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@tokenswim/pi
Package
@tokenswim/pi
Version
0.1.2
Published
Aug 13, 2026
Downloads
262/mo · 12/wk
Author
0x0501
License
MIT
Types
extension
Size
12.4 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@tokenswim/pi

Use Tokenswim's models in the pi coding agent. One API key, no per-vendor accounts.

Install

pi install npm:@tokenswim/pi

Then log in — pi prompts for the key and checks it against the gateway before storing it, so a mistyped key fails immediately rather than on your first message:

/login tokenswim

Get a key at https://tokenswim.app/dashboard/keys.

Prefer environment variables? Set TOKENSWIM_API_KEY instead and skip the login. A key stored by /login takes precedence over the variable.

Configuration

Variable Purpose
TOKENSWIM_API_KEY API key, used when none is stored by /login
TOKENSWIM_BASE_URL Gateway address, default https://tokenswim.app/v1

TOKENSWIM_BASE_URL is also read from the credential's own env block in pi's auth file, so one machine can hold keys for more than one gateway:

{
  "tokenswim": {
    "type": "api_key",
    "key": "sk-...",
    "env": { "TOKENSWIM_BASE_URL": "https://gateway.example.com/v1" }
  }
}

Development

bun install
bun run check          # typecheck + tests, no network, no credentials
bun run test:drift     # compare the catalog against tokenswim.app/pricing

./ext.sh registers a local checkout with pi and verifies it actually loaded — pi fails silently on a broken extension, so the install message alone proves nothing:

./ext.sh install       # register, then confirm the models appear
./ext.sh status        # is it installed, and what does it expose
./ext.sh try           # run pi once with it, touching no settings
./ext.sh uninstall

A local install is registered by path, never copied, so edits under src/ are live in the next pi session — /reload picks them up without restarting.

To send one real request (spends balance):

bun run smoke              # gpt-5.6-luna, the cheapest model
bun run smoke grok-4.5

License

MIT