Problem
Webhook senders retry delivery, so your handler must avoid duplicate LLM calls. ReqRun handles the model request; your app still receives and validates the webhook.
Code
Use the provider event id as idempotency_key.
export async function POST(request: Request) {
const event = await request.json();
const response = await reqrun.chat.completions.create({
model: "gpt-5-nano",
messages: [{ role: "user", content: "Summarize the webhook event." }],
wait: false,
idempotency_key: event.id,
});
return Response.json({ request_id: response.id });
}