Connect the TypeScript client
Use the versioned SDK package and connection details supplied for your Deploy pilot. Ask for developer access if you do not have them. Examples here describe the client interface; they are not connected to a live public demo.
The package is @retvest/client. This Node.js example loads the company API URL and raw Retvest API key from the environment. Keep long-lived automation credentials on the server; do not embed them in a public browser bundle.
import { RetvestClient } from "@retvest/client";
const baseUrl = process.env.RETVEST_API_URL;
const apiKey = process.env.RETVEST_API_KEY;
if (!baseUrl || !apiKey) {
throw new Error("Set the Retvest connection details.");
}
const client = new RetvestClient({ baseUrl, apiKey });
const answer = await client.query({
question: "Summarise the approved sample policy.",
topK: 5,
});Use the typed request shape
The TypeScript query example uses question and topK. Keep request and response types aligned with the delivered package and server contract. A matching method name does not establish compatibility across different release versions.
Place the client in the right application layer
Use a server-side service to hold long-lived automation credentials. Let that service call the Retvest client and pass only the permitted response to your user interface. A browser application must use its approved authentication path; it should not receive a shared administrative key.
Keep request construction, response handling and presentation separate enough to show errors and incomplete work clearly. Store the company base URL in configuration so environments do not require source edits.
Keep application and model credentials separate
apiKey is the raw Retvest API key, without a Bearer prefix. The company model endpoint is configured by the Deploy operator. Client applications do not need to impersonate that model service.
Handle partial work explicitly
Capture bounded error metadata for support. Treat a failed or interrupted stream as incomplete. Do not show partial streamed text as a successfully completed task unless the terminal event establishes completion.
Make retries depend on the operation
A safe retry policy for a read does not apply automatically to a document upload or review decision. Where the contract supports idempotency, retain the operation’s key and expected version according to that contract. If a response is ambiguous, reconcile the existing result before issuing another write.
Choose the right session
Session-owned administrative operations require the appropriate authorised session. Do not move session cookies or administrative credentials into an untrusted browser application.