Skip to content

EmbeddedLLM/tokenvisor-pi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

tokenvisor-pi

TokenVisor custom provider for pi and oh-my-pi (omp).

Dynamically discovers models from your TokenVisor account and registers them as a provider. The extension API is identical across both hosts; the only difference is how each stores credentials, which this extension bridges automatically (see How it works).

Install

Under pi:

pi install git:github.com/EmbeddedLLM/tokenvisor-pi

Or add to .pi/settings.json:

{ "packages": ["git:github.com/EmbeddedLLM/tokenvisor-pi"] }

Under omp:

omp plugins add https://github.com/EmbeddedLLM/tokenvisor-pi

Or add to ~/.omp/plugins/package.json:

{ "dependencies": { "tokenvisor-pi": "https://github.com/EmbeddedLLM/tokenvisor-pi" } }

The package.json pi manifest is read by both hosts (omp falls back to the pi field).

Setup

Under pi

  1. Start pi
  2. Run /login → "Use an API key" → TokenVisor → paste your API key (saved to ~/.pi/agent/auth.json)
    • or run /tokenvisor-login (same result)
  3. Run /reload to load models
  4. Run /model to select a TokenVisor model

Under omp

omp's /login is OAuth-only — it has no "enter an API key" UI, so TokenVisor will never appear there. Use the extension's own interactive command instead:

/tokenvisor-login

It prompts for your API key, saves it to ~/.pi/agent/auth.json (shared with pi's /login), and reloads. Then run /model to select a TokenVisor model.

Alternatively, provide the key via the environment:

export TOKENVISOR_API_KEY=tv-pat-...

If you also have pi installed and already ran pi /login (or /tokenvisor-login under either host), you don't need to do anything else — the extension reads the key from ~/.pi/agent/auth.json and mirrors it into the environment for omp automatically.

Configuration

API Key (resolution order)

  1. TOKENVISOR_API_KEY environment variable (always honored; the omp-idiomatic source)
  2. ~/.pi/agent/auth.json (set via pi /login — lets omp reuse a pi-stored key on a shared machine)

The resolved key is mirrored into TOKENVISOR_API_KEY at load time so the provider's env-var-name apiKey resolves correctly under both hosts.

Base URL

Defaults to https://devstudio.tokenvisor.ai/api/v1. Override with:

export TOKENVISOR_BASE_URL=https://your-custom-endpoint/api/v1

How it works

Both pi and omp accept pi.registerProvider("TokenVisor", { apiKey: "TOKENVISOR_API_KEY", ... }), where apiKey is an env-var name that the host resolves at request time (resolveConfigValue: env-var lookup → literal fallback).

The catch: if the env var is unset, the host falls back to the literal string "TOKENVISOR_API_KEY" and sends a bogus Authorization: Bearer TOKENVISOR_API_KEY header → 401 unauthorized. omp cannot store the key via /login (its /login only lists built-in OAuth providers), so the only omp-native source is the env var.

This extension resolves the key from the env var or pi's auth.json, then publishes it into process.env.TOKENVISOR_API_KEY before registering the provider. That makes the env-var-name form resolve to the real key under both hosts, regardless of credential-store differences. An explicit user-provided env var always takes precedence.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors