JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q48964F
  • License MIT

Call OpenAI's GPT APIs with structured responses

Package Exports

  • gpt-json
  • gpt-json/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gpt-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gpt-json

gpt-json is a library that enables interaction with OpenAI's GPT models using JSON and supports schema validation with yup. You can execute requests to retrieve specific information and get a validated result back.

Upcoming features

  • Streaming
  • Multi message support
  • Schema labeling

Getting started

Install

npm install gpt-json

Usage

import GPTJSON from 'gpt-json';
import { object, number } from 'yup';

const client = new GPTJSON({
  apiKey: 'YOUR_OPENAI_API_KEY',
});

const response = await client.executeRequest({
  model: 'gpt-4',
  request: 'Give me basic data about city Tallinn, Estonia',
  schema: object({
    population: number().required(),
    area: number().required(),
  }),
});

//=> 'hello from my package'