megallm-npm
Health Gecti
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 11 GitHub stars
Code Basarisiz
- process.env — Environment variable access in bin/megallm.js
- process.env — Environment variable access in src/auth/api.js
- network request — Outbound network request in src/auth/api.js
- exec() — Shell command execution in src/auth/oauth.js
- process.env — Environment variable access in src/auth/oauth.js
- network request — Outbound network request in src/auth/oauth.js
- process.env — Environment variable access in src/auth/store.js
- process.env — Environment variable access in src/cli.js
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
MegaLLM npm Package to configure Claude Code & Codex for MegaLLM AI service. Features auto-detection, interactive setup wizard, and secure API key management.
MegaLLM CLI
Sign in once. Use Claude Code, Codex, and OpenCode through MegaLLM.
Quick Start • Commands • OpenCode • Profiles • Troubleshooting
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+
~/.megallmexists with0700,auth.jsonwith0600- 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_KEYare 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
"Saved key is no longer valid"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
"MEGALLM_API_KEY environment variable not set" warning
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.
I want to keep my existing Codex / OpenCode setupYou 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
Switch organizations
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 protected] | |
| Issues | GitHub Issues |
| Discord | Join Community |
| Docs | docs.megallm.io |
License
MIT — see LICENSE.
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi