pi-extension-wandb
v0.1.0
Published
pi coding agent extension that adds Weights & Biases Inference as a model provider.
Maintainers
Readme
pi-extension-wandb
A pi coding agent extension that adds
Weights & Biases Inference as a model
provider. Model list is discovered dynamically from W&B's OpenAI-compatible
/v1/models endpoint, so new models show up without code changes.
Install
Get an API key from https://wandb.ai/authorize, then:
export WANDB_API_KEY=... # required
export WANDB_PROJECT=team/project # optional, recommended
pi install https://github.com/kirangadhave/pi-extension-wandbVerify:
pi --list-models | grep wandbUse
pi --provider wandb --model deepseek-ai/DeepSeek-V3.1 "hello"Configuration
| Env var | Required | Notes |
| --- | --- | --- |
| WANDB_API_KEY | yes | From https://wandb.ai/authorize. If unset, the provider is silently skipped (no wandb/* models appear in --list-models). |
| WANDB_PROJECT | no* | Sent as the OpenAI-Project header. Format: team/project. If you belong to multiple W&B teams, set this explicitly — otherwise W&B picks a default team for attribution, which can land usage on the wrong team. Single-team users can safely omit. |
| WANDB_DEBUG | no | 1 enables stderr logging from the extension (fetch errors, cache hits, etc.). |
| WANDB_NO_CACHE | no | 1 bypasses the model-list cache and fetches fresh on every pi startup. |
How it works
On every pi startup the extension:
- Reads
~/.cache/pi-extension-wandb/models.jsonif it's fresh (< 1 hour old). - Otherwise fetches
https://api.inference.wandb.ai/v1/models(5s timeout) and writes the result to the cache. - Registers each returned model under the
wandbprovider withapi: "openai-completions".
If the fetch fails and there is no usable cache, the provider is not
registered — pi --list-models will not show wandb models, and pi falls
back to its other configured providers cleanly.
Known limitations
- Context windows are guesses. W&B's
/v1/modelsdoesn't expose limits. The extension hardcodes known windows for a handful of popular models (KNOWN_CONTEXT_WINDOWSinindex.ts); everything else gets a default of 128K. PRs to extend the map are welcome. - Reasoning detection is heuristic. Substring match against the model id
(
REASONING_MODEL_PATTERNS). Edit the list for new families. - No cost tracking. All models report zero cost. W&B publishes per-token pricing — PRs to encode it are welcome.
- No provider-specific
compatflags. Some reasoning models (Qwen3 thinking, gpt-oss, DeepSeek-R1) may need provider-specific quirks for thinking mode. If you hit a problem, open an issue with the model id and the exact failure.
Contributing
PRs welcome. The only file you typically need to touch is index.ts:
KNOWN_CONTEXT_WINDOWS— add accurate context sizes for new models.REASONING_MODEL_PATTERNS— add model family substrings that support reasoning/thinking.
For editor type-checking, after cloning:
pnpm install
pnpm checkpi loads index.ts directly at runtime (no build step).
License
MIT — see LICENSE.
