Runnable Next.js App Router example that submits OpenAI-compatible work through ReqRun instead of calling the model provider directly.
- a browser form talking to local Next.js route handlers
- a route handler that submits work to
POST /v1/chat/completions - a second route handler that proxies
GET /v1/requests/{id} - idempotency keys and async request ids without exposing the ReqRun API key to the browser
This repo does not contain ReqRun backend code. It is only a thin app-side integration that talks to the hosted ReqRun API at https://api.reqrun.com.
- Node.js 20+
- a ReqRun project API key from https://app.reqrun.com
- Copy the env template:
cp .env.example .env.local- Fill in:
REQRUN_API_KEY=REQRUN_LIVE_YOUR_PROJECT_KEY_HERE
REQRUN_BASE_URL=https://api.reqrun.com- Install dependencies:
npm install- Run the app:
npm run devThe page sends your prompt to /api/run, which then sends this payload to ReqRun:
{
"model": "gpt-5-nano",
"messages": [
{ "role": "system", "content": "Return concise, useful output." },
{ "role": "user", "content": "Your prompt here" }
],
"wait": false,
"idempotency_key": "nextjs-demo-job-001"
}When ReqRun returns an async response, the page can then call /api/requests/{id} to fetch the durable status by request id.
- Product docs: https://www.reqrun.com/docs
- Quickstart: https://www.reqrun.com/docs/quickstart
- API reference: https://www.reqrun.com/docs/api