Reference
TypeScript SDK
A typed, dependency-free client for Node.js, Deno, Bun and edge runtimes.
@relaypoint/sdk is a small typed client built on fetch, with no dependencies. It works wherever fetch exists (Node.js 18+, Deno, Bun, edge runtimes). Use it on your servers only: it needs your secret API key.
npm install @relaypoint/sdkimport { RelayPoint } from "@relaypoint/sdk";
const rp = new RelayPoint({
apiKey: process.env.RELAYPOINT_API_KEY, // required
// baseUrl: "https://api.relaypoints.online", // default
// subAccount: "org_…", // act for a sub-account on every call
// timeoutMs: 60_000,
// maxRetries: 2, // 429, 5xx and network errors are retried
});Resources
Methods mirror the endpoints and return the JSON responses described in the API reference.
| Resource | Methods |
|---|---|
rp.chat.completions | create(body), stream(body) |
rp.embeddings | create(body) |
rp.images | generate(body) |
rp.audio.speech | create(body) → ArrayBuffer |
rp.audio.transcriptions | create({ file, model, language, response_format }) |
rp.jobs | create, retrieve, list, wait(id, { intervalMs, timeoutMs }) |
rp.models, rp.balance, rp.usage, rp.catalog | list(), retrieve(), list(params), list() |
rp.connections | list, retrieve, create, delete, request(id, { method, path, query, headers, body }), credentials(id) |
rp.connectLinks | create, list, retrieve, revoke |
rp.subAccounts | create, list, retrieve, update, close, transfer(id, { amount_usd, direction, memo }) |
rp.webhookEndpoints | create, list, retrieve, update, delete, rotateSecret, test |
rp.withSubAccount(id) | A client that sends RelayPoint-Account: id |
await verifyWebhook(raw, header, secret, { toleranceSeconds }) | Checks RelayPoint-Signature and returns the event; throws WebhookSignatureError |
Per-call options
Every method accepts a last argument with idempotencyKey (sent as Idempotency-Key, see Rate limits & idempotency) and signal (an AbortSignal).
const controller = new AbortController();
await rp.jobs.create(
{ model: "rp/ocr", input: { document_url: "https://example.com/lease.pdf", max_pages: 20 } },
{ idempotencyKey: "lease-77-ocr", signal: controller.signal },
);Streaming
rp.chat.completions.stream() returns an async iterable of chunks (use it directly with for await); the last chunk carries usage. See Chat & text.
let text = "";
for await (const chunk of rp.chat.completions.stream({
model: "rp/text-pro",
messages: [{ role: "user", content: "Summarise this lease in 5 bullet points: …" }],
})) {
text += chunk.choices[0]?.delta?.content ?? "";
}Errors and retries
API errors throw a RelayPointError with status, code, message, requestId and details (the extra fields of the error, such as verify_url or amount_owed_usd). 429, 5xx and network errors are retried up to maxRetries times (default 2) with backoff, honouring Retry-After. Every POST carries an Idempotency-Key (yours, or one the SDK generates), so a retry is never charged twice.
import { RelayPoint, RelayPointError } from "@relaypoint/sdk";
try {
await rp.subAccounts.create({ name: "Acme Realty" });
} catch (e) {
if (e instanceof RelayPointError) {
console.error(e.status, e.code, e.message, e.requestId, e.details);
if (e.code === "kyc_required") {
// e.details.verify_url
}
}
}