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

opencode-nanogpt

v1.0.4

Published

Automated setup scripts for configuring [OpenCode](https://opencode.ai) with [NanoGPT](https://nano-gpt.com) integration, featuring automatic model updates, reasoning model support, and built-in MCP server.

Readme

NanoGPT OpenCode Plugin

npm version License: ISC

A Bun-powered CLI plugin for configuring OpenCode with NanoGPT integration. Features automatic model updates, reasoning model support, and built-in MCP server configuration.

Installation

# Install globally with bun
bun install -g opencode-nanogpt

# Or use without installing
bunx opencode-nanogpt

Quick Start

# Initialize with your API key
nanogpt-config init --api-key YOUR_API_KEY

# Update models from NanoGPT API
nanogpt-config update-models

# Validate your configuration
nanogpt-config validate

Features

  • Surgical Editing - Only modifies the nanogpt section, preserves everything else
  • JSONC Support - Preserves comments and formatting in config files
  • Backup & Rollback - Automatic backups before changes with rollback support
  • Validation - Zod schema validation for configuration
  • Type Safety - Full TypeScript support
  • Auto Model Loading - All models automatically fetched from NanoGPT API
  • Reasoning Models - Models with reasoning capabilities configured with interleaved thinking
  • Built-in MCP - NanoGPT MCP server pre-configured
  • Auto Updates - Keep models up-to-date via cron

CLI Commands

init - Initialize Configuration

nanogpt-config init --api-key YOUR_API_KEY

Sets up the NanoGPT provider in your OpenCode configuration with:

  • NanoGPT API provider configuration
  • MCP server setup
  • Default models

update-models - Update Models from API

# Update models (API key auto-detected from auth file or env)
nanogpt-config update-models

# With explicit API key
nanogpt-config update-models --api-key YOUR_API_KEY

# Force update even if no changes detected
nanogpt-config update-models --force

Fetches the latest models from NanoGPT API and updates your configuration.

validate - Validate Configuration

nanogpt-config validate

Validates your OpenCode configuration file against the schema.

rollback - Rollback Changes

nanogpt-config rollback

Restores the configuration from the most recent backup.

format - Format Configuration

# Format config file
nanogpt-config format

# Check if formatting is needed
nanogpt-config format --check

Formats your configuration with proper indentation and structure.

Model Auto-Update

Use cron for periodic automatic updates:

# Open crontab editor
crontab -e

# Add line to update models daily at 6 AM
0 6 * * * nanogpt-config update-models

# Or using bunx (always gets latest version)
0 6 * * * bunx opencode-nanogpt update-models

Other examples:

# Update every hour
0 * * * * nanogpt-config update-models

# Update weekly on Sundays at 3 AM
0 3 * * 0 nanogpt-config update-models

# With logging to track updates
0 6 * * * nanogpt-config update-models >> ~/.local/share/opencode/model-updates.log 2>&1

Configuration

Config Files

  • Auth: ~/.local/share/opencode/auth.json

    • Stores NanoGPT API key securely
    • Permissions: 600 (read/write for owner only)
  • Config: ~/.config/opencode/opencode.json

    • Contains provider and model configuration
    • Includes MCP server settings
    • Permissions: 600 (read/write for owner only)

Default Models

After setup, you'll have access to all NanoGPT models, with these defaults:

  • Primary Model: zai-org/glm-4.7

    • GLM 4.7 base model
    • 200K context, 65K output
  • Thinking Model: zai-org/glm-4.7:thinking

    • GLM 4.7 with reasoning capabilities
    • Interleaved thinking enabled
    • 200K context, 65K output

MCP Server

The plugin automatically configures the NanoGPT MCP (Model Context Protocol) server:

{
  "mcp": {
    "nanogpt": {
      "type": "local",
      "command": ["bunx", "@nanogpt/mcp@latest", "--scope", "user"],
      "environment": { "NANOGPT_API_KEY": "{env:NANOGPT_MCP_API_KEY}" },
      "enabled": true
    }
  }
}

Available MCP Tools

  • nanogpt_chat - Send messages to any AI model
  • nanogpt_web_search - Search the web
  • nanogpt_scrape_urls - Extract content from web pages
  • nanogpt_youtube_transcribe - Get YouTube transcripts
  • nanogpt_image_generate - Generate images
  • nanogpt_get_balance - Check account balance
  • nanogpt_list_text_models - List text models
  • nanogpt_list_image_models - List image models

Learn more: https://docs.nano-gpt.com/integrations/mcp

Switching Models

In OpenCode UI

Use the command palette:

/model

Via Config File

Edit ~/.config/opencode/opencode.json:

{
  "model": "zai-org/glm-4.7:thinking",
  "disabled_providers": ["opencode"]
}

Troubleshooting

OpenCode Not Found

# Install script
curl -fsSL https://opencode.ai/install | bash

# bun (global)
bun install -g opencode-ai@latest

# Homebrew
brew install anomalyco/tap/opencode

Authentication Failed

  1. Check your network connection
  2. Verify your API key at nano-gpt.com/api
  3. Check auth file: cat ~/.local/share/opencode/auth.json

Models Not Loading

  1. Run update manually: nanogpt-config update-models
  2. Check API key is valid
  3. Verify network access to nano-gpt.com

MCP Server Not Working

  1. Ensure bunx is available: which bunx
  2. Install Bun: curl -fsSL https://bun.sh/install | bash
  3. Check MCP server status in OpenCode logs

Advanced Configuration

Custom Base URL

export NANOGPT_BASE_URL=https://your-custom-url.com
nanogpt-config init --api-key YOUR_API_KEY

Adding Custom Models

Edit ~/.config/opencode/opencode.json:

{
  "provider": {
    "nanogpt": {
      "models": {
        "your-custom-model": {
          "name": "Your Custom Model",
          "limit": {
            "context": 128000,
            "output": 4096
          }
        }
      }
    }
  }
}

API Reference

See docs/API.md for programmatic usage:

import { ConfigManager } from "opencode-nanogpt";
import { updateModelsFromApi } from "opencode-nanogpt/api";

const configManager = new ConfigManager();
await updateModelsFromApi(configManager, configPath, apiKey);

Project Structure

opencode-nanogpt/
├── src/
│   ├── cli/           # CLI commands
│   ├── api/           # NanoGPT API integration
│   ├── providers/     # Provider configuration
│   └── *.ts           # Core modules
├── dist/              # Compiled JavaScript
├── docs/              # Documentation
└── package.json

Credits

License

ISC