A dead-simple example of setting up a simple GPT bot API.
MIT License
This is a simple template to set up a Worker with a minimal, CORS-enabled API with an endpoint for demonstrating communication with ChatGPT. This is far from a feature complete API/implementation; consider it a barebones skeleton to get you started on your journey!
<3
npm install
(install the dependencies)wrangler.toml.example
to wrangler.toml
, and replace the placeholder values with your own.wrangler secret put OPENAI_API_KEY
then paste the key.npm run dev
- launches dev mode to allow testing locally/in browserwrangler publish
- publishes the Worker to CloudflarePOST /gpt
Send a raw message (text or JSON encoded) to this endpoint, expecting the extracted response in reply.
Here's an example from the console (using itty-fetcher for simplification):