Code Guide
JavaScript

JavaScript

Super simple to drop in to your existing workflows: simply define 'baseURL' and set a new (free) jsonmode.com API key as shown below:

  const { OpenAI } = require("openai");
 
  const openai = new OpenAI({
      apiKey: "JSONMODE_API_KEY",
      baseURL: "https://jsonmode.com/v1"
  });
  
  async function main() {
      const completion = await openai.chat.completions.create({
          model: "any",
          messages: [{
              role: "user", content: '[{city, population: int,  country}] Data: "city","city_ascii","lat","lng","country","iso2","iso3","admin_name","capital","population","id" "Tokyo","Tokyo","35.6897","139.6922","Japan","JP","JPN","Tōkyō","primary","37732000","1392685764" "Jakarta","Jakarta","-6.1750","106.8275","Indonesia","ID","IDN","Jakarta","primary","33756000","1360771077" "Delhi","Delhi","28.6100","77.2300","India","IN","IND","Delhi","admin","32226000","1356872604" "Guangzhou", "Guangzhou","23.1300","113.2600","China","CN","CHN","Guangdong","admin","26940000","1156237133" "Mumbai","Mumbai","19.0761","72.8775","India","IN","IND","Mahārāshtra","admin","24973000","1356226629" "Manila","Manila","14.5958","120.9772","Philippines","PH","PHL","Manila","primary","24922000","1608618140"'
          }]
      });
      console.log(completion.choices[0].message.content);
  }
  
  main();