Back to APIs list

ChatGPT API examples & templates

Use these vals as a playground to view and fork ChatGPT API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
jdan avatar
blobImages
@jdan
http
Calorie Count via Photo Uploads your photo to ChatGPT's new vision model to automatically categorize the food and estimate the calories.
jdan avatar
emojiGuessr
@jdan
http
Calorie Count via Photo Uploads your photo to ChatGPT's new vision model to automatically categorize the food and estimate the calories.
tfayyaz avatar
tahirsTil
@tfayyaz
http
Inspiration for having a blog and TIL/read taken from https://simonwillison.net/ https://bradfrost.com/blog/ https://geoffgraham.me/blog/ https://matthewstrom.com/ To-do: Buy tahirfayyaz.dev domain from iwantmyname.com Use SQLlite to store all the posts Create an editor to post to SQLlite maybe with live preview? Update site to use HTMX Active Search - https://htmx.org/examples/active-search/
xkonti avatar
videoGameIdeaGPT
@xkonti
http
The idea for the GPT is so that the user comes up with a fun idea for a Video Game. When the user submits the idea, the AI will submit it to the API. The API will return a different idea from the pool of ideas already submitted to the API. This makes this GPT kind-of multiplayer as you will likely get ideas for video games that other people submitted.
onixoni avatar
chat
@onixoni
script
OpenAI ChatGPT helper function This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free. import { chat } from "https://esm.town/v/stevekrouse/openai"; const { content } = await chat("Hello, GPT!"); console.log(content); import { chat } from "https://esm.town/v/stevekrouse/openai"; const { content } = await chat( [ { role: "system", content: "You are Alan Kay" }, { role: "user", content: "What is the real computer revolution?"} ], { max_tokens: 50, model: "gpt-4" } ); console.log(content);
tfayyaz avatar
whiteMongoose
@tfayyaz
http
@jsxImportSource https://esm.sh/react
stevekrouse avatar
valwriter
@stevekrouse
http
@jsxImportSource npm:hono@3/jsx
stevekrouse avatar
calories
@stevekrouse
http
Calorie Count via Photo Uploads your photo to ChatGPT's new vision model to automatically categorize the food and estimate the calories.
stevekrouse avatar
cron_client_react_fork
@stevekrouse
http
CronGPT This is a minisite to help you create cron expressions, particularly for crons on Val Town. It was inspired by Cron Prompt , but also does the timezone conversion from wherever you are to UTC (typically the server timezone). Tech Hono for routing ( GET / and POST /compile .) Hono JSX HTML (probably overcomplicates things; should remove) @stevekrouse/openai, which is a light wrapper around @std/openai TODO [ ] simplify by removing HTMX (try doing the form as a GET request, manual JS script, or client side react) [ ] make the timezone picker better (fewer options, searchable) [ ] add a copy button?
stevekrouse avatar
cron_client_side_script_fork
@stevekrouse
http
CronGPT This is a minisite to help you create cron expressions, particularly for crons on Val Town. It was inspired by Cron Prompt , but also does the timezone conversion from wherever you are to UTC (typically the server timezone). Tech Hono for routing ( GET / and POST /compile .) Hono JSX HTML (probably overcomplicates things; should remove) @stevekrouse/openai, which is a light wrapper around @std/openai
stevekrouse avatar
cron
@stevekrouse
http
CronGPT This is a minisite to help you create cron expressions, particularly for crons on Val Town. It was inspired by Cron Prompt , but also does the timezone conversion from wherever you are to UTC (typically the server timezone). Tech Hono for routing ( GET / and POST /compile .) Hono JSX HTMX (probably overcomplicates things; should remove) @stevekrouse/openai, which is a light wrapper around @std/openai I'm finding HTMX a bit overpowered for this, so I have two experimental forks without it: Vanilla client-side JavaScript: @stevekrouse/cron_client_side_script_fork Client-side ReactJS (no SSR): @stevekrouse/cron_client_react_fork I think (2) Client-side React without any SSR is the simplest architecture. Maybe will move to that.
mxis avatar
chat
@mxis
script
OpenAI ChatGPT helper function This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free. import { chat } from "https://esm.town/v/stevekrouse/openai"; const { content } = await chat("Hello, GPT!"); console.log(content); import { chat } from "https://esm.town/v/stevekrouse/openai"; const { content } = await chat( [ { role: "system", content: "You are Alan Kay" }, { role: "user", content: "What is the real computer revolution?"} ], { max_tokens: 50, model: "gpt-4" } ); console.log(content);
stevekrouse avatar
modifyImage
@stevekrouse
script
Code from https://deno.com/blog/build-image-resizing-api Useful for compressing an image before sending to chatgpt4v, for example
yawnxyz avatar
valwriter
@yawnxyz
http
Doesn't seem to work on val.town, should work in principle
stevekrouse avatar
cron2
@stevekrouse
http
@jsxImportSource npm:hono@3/jsx