Skip to main content

JavaScript SDK 0.2.1 — API errors, cancellation and CommonJS

JavaScript SDK 0.2.1 throws ValenAPIError for HTTP errors, adds per-request signal and timeout, types System One answers, and can be loaded with require.

Upgrade notes​

Node.js 22.12+ is required.

Changes​

  • HTTP error responses throw ValenAPIError: a non-JSON error page (such as a gateway's HTML 502) keeps its status code, request ID and text, and network failures keep their cause.
  • A self-hosted server's {"error": {"message": ...}} becomes the error message, and the hosted APIs' x-llm-proxy-request-id fills requestId.
  • Requests take signal and timeout options to cancel one request or set its own timeout. A cancelled request rejects with the signal's reason at once, including during the wait between retries, and is not retried. Passing signal uses AbortSignal.any; requests without one work as before.
  • Node sends User-Agent: valen-sdk-js/<version>; VERSION is exported.
  • CommonJS can require('@valen-team/sdk').
  • System One answers are typed by type (NoulAnswer, SystemOneChoiceAnswer, SystemOneScoreAnswer, with legend on scores), and predict returns DecisionResponse or SystemOneResponse for those request shapes.
  • Releases publish from the npm-v* tag through GitHub Actions with npm provenance.

Install​

Terminal
npm install @valen-team/sdk@0.2.1