npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nathancatania/pi-glean

v0.1.1

Published

Pi provider for the Glean LLM Gateway.

Readme

pi-glean banner: a dark terminal window with the pi-glean wordmark and a green "pi"

pi-glean

A Pi provider for the Glean LLM Gateway.

The provider discovers the Glean model catalog at startup and routes each model to the API that Glean exposes for that model.

[!NOTE] This is a community repository. It is not endorsed, sponsored, managed, or supported by Glean. You use the contents at your own risk.

Quick Start

Requirements

  • Node.js 22.19.0 or later

Install

Install the package from GitHub:

pi install git:github.com/nathancatania/pi-glean

OR

Install the package from npm:

pi install npm:@nathancatania/pi-glean

Log in

Run /login, then select Glean. Pi asks for two values.

| Prompt | Value | | --- | --- | | Glean tenant id | The label before -be.glean.com. For https://acme-be.glean.com, enter acme. | | Glean LLM Gateway API key | The LLM Gateway API key for your tenant. Note: This is different to the Client API key. |

For headless runs, set GLEAN_LLM_API_KEY and GLEAN_TENANT_ID as environment variables instead. A stored credential takes priority over the variables.

Pi verifies the pair against the Glean model catalog https://{{GLEAN_TENANT_ID}}-be.glean.com/rest/api/v1/models. If successful, Pi stores the API key and the tenant id in ~/.pi/agent/auth.json.

Environment variables

Use the environment variables for CI and headless runs:

| Variable | Value | | --- | --- | | GLEAN_LLM_API_KEY | The Glean LLM Gateway API key. | | GLEAN_TENANT_ID | The Glean tenant id. |

A stored credential wins over the environment variables. The provider uses GLEAN_LLM_API_KEY and GLEAN_TENANT_ID when no credential exists.

Headless and CI runs

Use the environment variables for CI and headless runs:

| Variable | Value | | --- | --- | | GLEAN_LLM_API_KEY | The Glean LLM Gateway API key. | | GLEAN_TENANT_ID | The Glean tenant id. |

You must set both variables in the environment. Pi will use them when no stored credential exists.

export GLEAN_LLM_API_KEY="<api key>"
export GLEAN_TENANT_ID="acme"

pi install npm:@nathancatania/pi-glean
pi --print --model glean/<model id> "Summarize the failing test"

--print sends one prompt, writes the answer to stdout, and exits. Read the model ids of your tenant first:

pi --list-models glean

Model routing

Glean publishes a supportedEndpoints list for each model. Pi picks the first match in this order.

| Glean endpoint | Pi API | Request URL | | --- | --- | --- | | v1/responses | OpenAI Responses | https://{tenant}-be.glean.com/rest/api/v1/openai/v1/responses | | v1/chat/completions | OpenAI Chat Completions | https://{tenant}-be.glean.com/rest/api/v1/openai/v1/chat/completions | | v1/messages | Anthropic Messages | https://{tenant}-be.glean.com/rest/api/v1/anthropic/v1/messages |

The Responses API wins when a model lists both OpenAI endpoints. Glean supports Chat Completions for streaming only, and Pi always streams.

Every route sends Authorization: Bearer <api_key>. The Anthropic route also sends anthropic-version: 2023-06-01. Pi removes the x-api-key header on that route, because the Anthropic SDK adds it by default.

The provider marks a Claude model for adaptive thinking when Glean lists the xhigh or max thinking level.

Authentication headers

Every route sends Authorization: Bearer <glean_api_key>.

The Anthropic route also sends anthropic-version: 2023-06-01. The provider removes the x-api-key header, because the Anthropic SDK adds it by default.

Catalog mapping

Pi converts each Glean catalog entry into a Pi model.

| Glean field | Pi field | | --- | --- | | displayName | Model name | | First modelAliases entry, then model | Model id | | supportsReasoning | Reasoning flag | | supportedThinkingLevels | Thinking level map | | pricingPerInputToken, pricingPerOutputToken, pricingPerCachedInputTokenRead | Cost per million tokens | | maxContextTokens, maxInputTokens | Context window | | maxOutputTokens | Output limit | | imageExtensions | Image input |

An unlisted thinking level becomes null, so Pi clamps that level.

Pi assumes 128000 tokens when the entry carries no context size, and 8192 tokens when it carries no output limit.

Supported models

The provider keeps models that use v1/responses, v1/chat/completions, or v1/messages.

The provider currently drops models with other endpoints. This includes Gemini streamGenerateContent, Bedrock ConverseStream, realtime, audio, image, and embedding models.

Development

Test a local checkout for one run:

pi -e ./pi-glean

Run the tests:

npm test

Run the type check:

npm install
npm run check

The tests use the Node.js test runner and the Node.js type stripping. They do not need a Glean tenant.

License

MIT. See LICENSE.

Report an Issue