Installation
First, create a new Next.js project with:Start Local QStash Server
Next, start the local QStash server with the following:Set Environment Variables
Once you start the QStash server, you’ll seeQSTASH_URL
and QSTASH_TOKEN
values in the console. Add these values to your .env.local
file together with OPENAI_API_KEY
env variable:
.env.local
Define an endpoint
Next, we will define the endpoint to run the agent.app/workflow/route.ts
Calling the Endpoint
To run the endpoint, first run the Next.js app with:If you are using a local tunnel, replace the url above (
http://127.0.0.1:3000
)
with the public URL.
communicationTool
. Tool was executed and OpenAI was called with the result of the tool. OpenAI then responded with the final response.