Code Guide
Python

Python

Define 'api_key' and 'base_url' as shown below:

import openai
 
client = openai.OpenAI(
    api_key="JSONMODE_API_KEY",
    base_url="https://jsonmode.com/v1"
)
 
chat_completion = client.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"'}
    ]
)
 
response = chat_completion.choices[0].message.content
print("Response:", response)