TypeScript client reference
Install algenta-sdk, construct an AlgentaClient, and learn the promise-based method surface and the typed error hierarchy before you call the engine.
The TypeScript and JavaScript client is published to npm as algenta-sdk. It wraps the HTTP API in one typed AlgentaClient, works on Node.js 18+ and modern browsers, and uses fetch with no required dependencies. The method surface itself is split across four reference pages linked at the end.
Install
Install the public npm package:
npm install algenta-sdkConstruct the client
new AlgentaClient(config) takes an optional config object. If you omit apiKey, the client reads it from ALGENTA_API_KEY, then the legacy DE_API_KEY. If none is set, the constructor throws with guidance rather than failing silently.
import { AlgentaClient } from "algenta-sdk";
const client = new AlgentaClient({
apiKey: process.env.ALGENTA_API_KEY, // falls back to DE_API_KEY, then throws
baseUrl: "https://api.algenta.ai", // or http://localhost:8000 for self-host
});
const models = await client.listModels();
console.log(models);new AlgentaClient(config) accepts an AlgentaClientConfig:
apiKey
string
ALGENTA_API_KEY, then DE_API_KEY
Required. Read from the environment if not passed.
baseUrl
string
https://api.algenta.ai (DEFAULT_BASE_URL)
Set an explicit origin for a self-hosted engine.
timeout
number
120000
Per-request timeout in milliseconds, enforced with AbortController.
maxRetries
number
3
Retries with exponential backoff; honors Retry-After on 429.
defaultHeaders
Record<string, string>
{}
Merged into every request.
Calls return promises
Every method returns a Promise, so use await (or .then). Streaming methods — streamChatCompletions and streamResponses — return an AsyncGenerator, so iterate them with for await.
Errors
All client errors extend DecisionEngineError and carry a normalized errorCode, a statusCode, the raw responseBody, and a details accessor (with validationErrors for 422 bodies). Import the subclass you want to branch on.
AuthenticationError
401
No
NotFoundError
404
No
ValidationError
422
No
RateLimitError
429
Yes, honoring Retry-After up to maxRetries
ServerError
5xx
Yes, with exponential backoff
DecisionEngineError
other
Base class for the hierarchy
Where to go next
Pick the method group you need — each page tables every method with its HTTP route and runnable examples.
Last updated
Was this helpful?