Skip to main content

Client options

import { Averta } from "@averta/sdk";

const averta = new Averta({
  apiKey: process.env.AVERTA_API_KEY,
  baseUrl: "https://api.averta.io",   // default
  timeout: 5000,                       // ms, default 10000
  retries: 2,                          // default 2
});

Environment variables

The SDK reads these environment variables automatically:
VariableDescription
AVERTA_API_KEYYour API key (required if not passed to constructor)
AVERTA_BASE_URLOverride the API base URL
AVERTA_TIMEOUTRequest timeout in milliseconds

Error handling

The SDK raises typed errors for common failure modes:
import { AvertaError, RateLimitError, AuthenticationError } from "@averta/sdk";

try {
  const decision = await averta.decisions.create({ ... });
} catch (error) {
  if (error instanceof AuthenticationError) {
    // Invalid or expired API key
  } else if (error instanceof RateLimitError) {
    // Back off and retry
  } else if (error instanceof AvertaError) {
    // Other API error
    console.error(error.status, error.message);
  }
}