JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q26365F
  • License Apache-2.0

Client for the NanoGPT API

Package Exports

  • nanogpt-client
  • nanogpt-client/dist/index

Readme

NanoGPT Client

An unofficial implementation of the NanoGPT API. This library aims to provide a Typescript client for both browser and node environments. It's built on the inferred OpenAPI spec.

Note: The API might change at any time which can render this client unusable, use at your own risk.

Install

npm install nanogpt-client

How to use

Chat

Simple chat

import { NanoGPTClient } from 'nanogpt-client'
;(async () => {
  const nano = new NanoGPTClient({
    apiKey: '<NanoGPT API Key>'
  })
  const textResponse = await nano.chat().simple('test', 'chatgpt-4o-latest')
  console.log(textResponse)
})()

Streaming chat

import { NanoGPTClient } from 'nanogpt-client'
;(async () => {
  const nano = new NanoGPTClient({
    apiKey: '<NanoGPT API Key>'
  })
  const stream = await nano.chat().stream().simple('test', 'chatgpt-4o-latest')
  for await (const part of stream) {
    console.log(part) // Prints each response
  }
})()

Images

Simple image

import { NanoGPTClient } from 'nanogpt-client'
;(async () => {
  const nano = new NanoGPTClient({
    apiKey: '<NanoGPT API Key>'
  })
  const base64EncodedData = await nano.image().simple('Cat with glasses', 'fast-sdxl')
})()

Contributing

Please consult CONTRIBUTING for guidelines on contributing to this project.