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

@nanogpt/ai-sdk-provider

v0.1.3

Published

NanoGPT community provider for the Vercel AI SDK.

Downloads

25

Readme

@nanogpt/ai-sdk-provider

NanoGPT community provider for the Vercel AI SDK. Use the same ai package helpers (generateText, streamText, embed, generateObject, …) to talk to NanoGPT's OpenAI-compatible endpoints without rewriting application code.

Installation

npm install @nanogpt/ai-sdk-provider
# or
pnpm add @nanogpt/ai-sdk-provider

Quick start

import { generateText, embedMany } from 'ai'
import { createNanoGPT } from '@nanogpt/ai-sdk-provider'

const nanogpt = createNanoGPT({
  apiKey: process.env.NANOGPT_API_KEY!,
  // Optional overrides:
  // baseURL: 'https://nano-gpt.com/api/v1',
  // maxRetries: 5,
  // includeLegacyApiKeyHeader: false,
})

const { text } = await generateText({
  model: nanogpt.languageModel('gpt-5'),
  prompt: 'Summarise the NanoGPT product launch in two sentences.',
})

const { embeddings } = await embedMany({
  model: nanogpt.textEmbeddingModel('text-embedding-3-small'),
  values: ['NanoGPT is fast.', 'NanoGPT is affordable.'],
})

Supported capabilities

  • Chat completions via languageModel() – streaming SSE, JSON mode, tool calls, seed/stop controls, and provider metadata passthrough (<NanoGPT>…</NanoGPT> envelopes).
  • Text embeddings via textEmbeddingModel() – batches up to 2048 items, base64 decoding, and token usage tracking.
  • Error handling consistent with the AI SDK (NanoGPTRequestError). Response metadata stays available for observability.

Image generation is not yet wired through the AI SDK interface. If you need /v1/images/generations today, call it directly with NanoGPTClient.stream/request and stay tuned for a follow-up release.

Provider options

createNanoGPT({
  apiKey: string,
  baseURL?: string,              // default: https://nano-gpt.com/api/v1
  defaultHeaders?: Record<string, string>,
  timeoutMs?: number,            // default: 60_000
  maxRetries?: number,           // default: 2
  includeLegacyApiKeyHeader?: boolean, // default: true
  fetch?: typeof fetch,
})

Per-call headers (e.g. to forward tenant IDs) can be passed from AI SDK helpers:

await generateText({
  model: nanogpt.languageModel('gpt-4.1-mini'),
  prompt,
  headers: {
    'x-nanogpt-session-id': sessionId,
  },
})

Embeddings expose provider-specific options through the standard providerOptions bag:

await embedMany({
  model: nanogpt.textEmbeddingModel('text-embedding-3-small'),
  values,
  providerOptions: {
    nanogpt: {
      encoding_format: 'base64',
      dimensions: 1024,
    },
  },
})

Scripts

  • npm run build – bundle ESM, CJS, and type definitions into dist/
  • npm run type-check – strict TypeScript verification
  • npm run test – Vitest unit suite (chat + embeddings)
  • npm run lint – ESLint for src/
  • npm run format – Prettier across source, configuration, and docs

Release checklist

  • Run npm run release <bump> (e.g. patch, minor, major, or an explicit version). The script checks for a clean git state, runs lint/type-check/test/build, bumps the package via npm version, publishes with npm publish --access public, and pushes commits + tags.
  • For pre-release dist-tags, append npm publish flags after --: npm run release prerelease -- --tag next.

Documentation

  • docs/api-reference.md – working notes mirroring NanoGPT's public API
  • content/ – MDX entry for the AI SDK community provider gallery
  • examples/ – sample applications showing how to swap NanoGPT into popular templates

Issues and pull requests are welcome!