Installation
Quick Start
Authentication
The SDK authenticates using your Avala API key, which is sent via theX-Avala-Api-Key header on every request.
You can provide the key directly or let the SDK read it from the environment.
Option 1: Pass the key directly
Working with Datasets
List Datasets
Get a Dataset
Working with Projects
List Projects
Get a Project
Working with Tasks
List Tasks
Get a Task
Working with Exports
Create an Export
Poll for Completion
TypeScript Types
The SDK exports full TypeScript interfaces for all API objects. Use them to type your functions and variables.Error Handling
The SDK throws typed errors so you can handle different failure modes precisely.| Exception | Description |
|---|---|
AvalaError | Base error class for all Avala API errors. |
AuthenticationError | Invalid or missing API key (HTTP 401). |
NotFoundError | The requested resource does not exist (HTTP 404). |
RateLimitError | You have exceeded the API rate limit (HTTP 429). Includes a retryAfter property. |
ValidationError | The request payload failed validation (HTTP 400/422). |
ServerError | The server returned an internal error (HTTP 5xx). |
Pagination
List methods return aCursorPage<T> object with cursor-based pagination.
Configuration
You can customize the client behavior at initialization time.| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey | string | AVALA_API_KEY env var | Your Avala API key. |
baseUrl | string | https://server.avala.ai/api/v1 | The API base URL. |
timeout | number | 30000 | Request timeout in milliseconds. |
maxRetries | number | 2 | Number of automatic retries on transient failures (5xx, timeouts). |
Zero Dependencies
The@avala/sdk package has zero runtime dependencies. It uses the native fetch API available in Node.js 18+, Deno, and Bun.