Framework guide
Next.js App Router integration
Keep the UrTheProduct key in a server-only Route Handler. The client calls your route, never UrTheProduct directly.
Environment
URTHEPRODUCT_BASE_URL=https://urtheproduct.com
URTHEPRODUCT_API_KEY=your-revealed-keyComplete server example
// app/api/my-feature/route.ts
import 'server-only';
import { NextResponse } from 'next/server';
export async function POST(request: Request) {
// Authenticate your own user here.
const { input } = await request.json();
const upstream = await fetch(
process.env.URTHEPRODUCT_BASE_URL + "/v1/text/generate",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.URTHEPRODUCT_API_KEY}`,
"Idempotency-Key": crypto.randomUUID(),
"Content-Type": "application/json",
},
body: JSON.stringify({ input, output_format: "markdown" }),
cache: "no-store",
},
);
const body = await upstream.json();
return NextResponse.json(body, { status: upstream.status });
}Production requirements
- Authenticate and authorize your application user before spending package quota.
- Validate and limit browser input before forwarding it.
- Persist the logical idempotency key in queue or request state.
- Apply timeouts and documented retry behavior.
- Return safe errors to the browser; do not forward internal input, headers, or credentials.
- Validate generated output before rendering or performing any action.