Framework guide
Node.js and TypeScript integration
Use the built-in fetch API from a backend process or job worker. Keep a caller-supplied logical idempotency key across worker retries.
Environment
URTHEPRODUCT_BASE_URL=https://urtheproduct.com
URTHEPRODUCT_API_KEY=your-revealed-keyComplete server example
export async function generateText(input, idempotencyKey) {
const response = await fetch(
process.env.URTHEPRODUCT_BASE_URL + "/v1/text/generate",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.URTHEPRODUCT_API_KEY}`,
"Idempotency-Key": idempotencyKey,
"Content-Type": "application/json",
},
body: JSON.stringify({ input, output_format: "markdown" }),
},
);
const body = await response.json();
if (!response.ok) throw Object.assign(new Error(body.error.message), body.error);
return body;
}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.