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

megallm

v3.1.0

Published

Sign in once, configure Claude Code / Codex / OpenCode. Interactive Ink-based hub with OAuth device flow, named profiles, and per-org API keys.

Readme

MegaLLM CLI

NPM Version License Platform

Quick StartCommandsOpenCodeProfilesTroubleshooting


Quick Start

npx megallm@latest

Lands on the interactive hub: shows your current account, detects installed tools, and lets you sign in or configure them with a single arrow-key choice.

Prefer a one-shot command? All of these work too:

npx megallm login              # OAuth device flow → saves a key
npx megallm setup              # Full wizard (sign in or paste a key, configure tools)
npx megallm link claude        # Wire one tool with the saved key
npx megallm doctor             # Diagnose every check

Why MegaLLM CLI

  • Single sign-in for Claude Code, Codex, and OpenCode — no copy-pasting keys per tool.
  • OAuth device flow (RFC 8628) opens the browser, lands on /activate, mints a per-org API key.
  • Surgical config edits — your existing settings (other providers, custom plugins, model overrides) are preserved.
  • Multi-profile — keep work and personal accounts side-by-side under ~/.megallm/profiles/.
  • Scriptable — every interactive screen has a non-TTY plain-text equivalent for CI.

Commands

| Command | What it does | |---|---| | megallm | Open the interactive hub (auto-detects TTY; prints --help when piped). | | megallm setup | Full wizard: sign in or paste a key, then configure detected tools. | | megallm login | OAuth device flow. After success, asks if you want to wire detected tools. | | megallm logout | Revoke the saved key on the server and clear local creds. | | megallm whoami | Identity behind the current saved key. | | megallm status | Plain-text snapshot of identity + detected tools. | | megallm doctor | Run every health check (creds, tool configs, env vars). | | megallm orgs | List orgs you can switch into. | | megallm switch-org [<id>] | Switch active org and mint a fresh per-org key. Picker is interactive. | | megallm keys list [--org <id>] | List API keys in the active (or given) org. | | megallm keys revoke <key_id> | Revoke a key by id. | | megallm link <tool> | Wire one tool (claude, codex, opencode). | | megallm unlink <tool> | Surgically remove the MegaLLM keys from one tool. | | megallm profile list | List saved credential profiles. | | megallm profile use <name> | Make <name> the active profile. | | megallm profile rm <name> | Delete a saved profile. |

Global flags: --profile <name> (or -p, also MEGALLM_PROFILE env), --help, --version.


How It Works

            ┌─────────────────────────────────┐
            │  npx megallm  (interactive hub) │
            └────────────────┬────────────────┘
                             │
        ┌────────────────────┼────────────────────┐
        ▼                    ▼                    ▼
   megallm login       megallm setup        megallm link <tool>
        │                    │                    │
        ▼                    ▼                    ▼
   /activate page     wizard chooses     wire one tool only
   browser approve   tools + level + key
        │                    │                    │
        └─────── api key ────┴──── apiKey ────────┘
                             │
                             ▼
            ┌─────────────────────────────────┐
            │ ~/.megallm/profiles/<name>/     │
            │   auth.json   (chmod 0600)      │
            │   state.json                    │
            └────────────────┬────────────────┘
                             │
       ┌─────────────────────┼─────────────────────┐
       ▼                     ▼                     ▼
   Claude Code           Codex                 OpenCode
   ~/.claude/         ~/.codex/             ~/.config/opencode/
   settings.json      config.toml           opencode.json

What Gets Written Where

Claude Code — ~/.claude/settings.json

The CLI adds these two env keys, leaves everything else untouched:

{
  // …your existing config (theme, model, plugins) is preserved…
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai.megallm.io",
    "ANTHROPIC_API_KEY": "sk-mega-…"
  }
}

It also approves the key prefix in ~/.claude.json so Claude Code stops re-prompting.

Codex — ~/.codex/config.toml

Adds a megallm provider, switches model_provider to it, leaves your other providers in place:

model_provider = "megallm"
model = "gpt-5"

[model_providers.megallm]
name = "OpenAI using Chat Completions"
base_url = "https://ai.megallm.io/v1"
env_key = "MEGALLM_API_KEY"
query_params = {}

The key is not written into the TOML — it's read from MEGALLM_API_KEY, which the CLI exports into your shell rc (~/.zshrc, ~/.bashrc, etc.).

OpenCode — ~/.config/opencode/opencode.json

Adds provider.anthropic pointing at MegaLLM, plus a fallback list of non-Anthropic models. Other providers (e.g. chutes, google) are preserved:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    // …other providers untouched…
    "anthropic": {
      "models": {
        "gpt-5":      { "id": "gpt-5",      "name": "GPT-5 (Via MegaLLM)" },
        "gpt-4o":     { "id": "gpt-4o",     "name": "GPT-4o (Via MegaLLM)" },
        "gpt-4o-mini":{ "id": "gpt-4o-mini","name": "GPT-4o Mini (Via MegaLLM)" }
      },
      "options": {
        "apiKey": "{env:MEGALLM_API_KEY}",
        "baseURL": "https://ai.megallm.io/v1"
      }
    }
  }
}

When MegaLLM reaches your account, the CLI fetches the live model list from https://ai.megallm.io/models and writes those instead of the three-model fallback above.


Configuring OpenCode

Two equivalent paths:

# A — explicit, single tool
npx megallm login            # one-time sign-in
npx megallm link opencode    # writes the provider block above

# B — interactive
npx megallm                  # pick "Configure / re-configure tools"

Verify:

npx megallm doctor           # → "✓ OpenCode configured for MegaLLM"

To remove just the MegaLLM provider from OpenCode (keeps everything else):

npx megallm unlink opencode

Profiles

Multiple accounts? Pass --profile to any command, or set MEGALLM_PROFILE:

megallm login --profile work
megallm login --profile personal

megallm profile list              # ★ marks the active one
megallm profile use work          # switch
megallm whoami --profile personal # one-shot override

Profiles live in ~/.megallm/profiles/<name>/:

~/.megallm/
├── config.json              # { "current_profile": "work" }
└── profiles/
    ├── work/
    │   ├── auth.json        # chmod 0600 — apiKey, scopes, user, orgId
    │   └── state.json       # cached orgs list
    └── personal/
        ├── auth.json
        └── state.json

Doctor

megallm doctor runs every check the CLI knows about and prints a green/yellow/red report:

  • Node 18+
  • ~/.megallm exists with 0700, auth.json with 0600
  • Saved key is accepted by the backend (/oauth/userinfo)
  • All four scopes present (api:use, profile:read, keys:read, keys:manage)
  • Each tool installed, with config that points at MegaLLM
  • Env vars ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, MEGALLM_API_KEY are exported

Exits non-zero on any critical failure — wire it into CI to catch drift.


Installation Options

# One-shot (recommended)
npx megallm@latest

# Globally
npm install -g megallm
megallm

# Pin a version
npx [email protected]

Requires Node 18 or newer (Ink uses ESM).


Environment Variables

| Variable | Purpose | Default | |---|---|---| | MEGALLM_PROFILE | Active credential profile | default | | MEGALLM_WEB_URL | Web app URL (OAuth host) | https://megallm.io | | MEGALLM_CLI_CLIENT_ID | OAuth client_id for the CLI | mega_pub_cli | | DEBUG | Print stack traces on error | unset |

The CLI exports these into your shell rc when it wires up tools:

| Variable | Read by | |---|---| | ANTHROPIC_BASE_URL | Claude Code | | ANTHROPIC_API_KEY | Claude Code | | MEGALLM_API_KEY | Codex, OpenCode |

After install, source ~/.zshrc (or open a new shell) to pick them up.


Troubleshooting

The server rejected the bearer key. Either you revoked it from the dashboard, or the OAuth app is missing scopes. Re-login:

megallm logout
megallm login

Make sure your OAuth app at /dashboard/developers has all four scopes ticked: api:use, profile:read, keys:read, keys:manage.

The tool's config file exists but doesn't have the MegaLLM block. Wire it:

megallm link claude
megallm link codex
megallm link opencode

Codex and OpenCode read the key from the env, not the config file. The CLI writes the export to your shell rc; you just need to reload:

source ~/.zshrc       # or ~/.bashrc

Or open a new terminal.

You can. The configurators merge instead of overwriting — your other providers, models, plugins, and tools stay intact. To verify, diff before/after:

cp ~/.config/opencode/opencode.json /tmp/before.json
megallm link opencode
diff /tmp/before.json ~/.config/opencode/opencode.json
megallm switch-org           # interactive picker
megallm switch-org org_abc   # direct

Switching mints a fresh per-org API key, replaces the saved key, and rewrites all linked tools to use it.


Documentation


Support

| | | |---|---| | Email | [email protected] | | Issues | GitHub Issues | | Discord | Join Community | | Docs | docs.megallm.io |


License

MIT — see LICENSE.

Built by the MegaLLM team. Star us on GitHub.