Small example for generating responses using the ChatGPT library runs in a web browser using Javascript great as it doesn t require any installation and is a fun resource to add something extra document body style minHeight 300pt ref https platform openai com docs api reference chat curl https api openai com v1 chat completions H Content Type application json H Authorization Bearer OPENAI_API_KEY d model gpt 3 5 turbo messages role user content Hello useful curl converter https curlconverter com javascript const OPENAI_API_KEY sk G5Q3AsMTTBomnxxxxxxxxxxxxxxxxxxxx const response await fetch https api openai com v1 chat completions method POST headers Content Type application json Authorization Bearer OPENAI_API_KEY body JSON stringify model gpt 3 5 turbo temperature 0 5 n 1 messages role user role assistant content generate 10 profiles for users providing their age first name second name gender and an occupation const jsonResponse await response json console log jsonResponse Create div and put the reponse on the screen let html jsonResponse choices 0 message content replaceAll n br n let div document createElement div document body appendChild div div style fontSize 14pt div innerHTML Response br html hr
ers Content Type application json Authorization Bearer OPENAI_API_KEY body JSON stringify model gpt 3 5 turbo temperature 0 5 n 1 messages role user role assistant content generate 10 profiles for users providing their age first name second name gender and an occupation const jsonResponse await response json console log jsonResponse Create div and put the reponse on the screen let html jsonResponse choices 0 message content replaceAll n br n let div document createElement div document body appendChild div div style fontSize 14pt div innerHTML Response br html hr