@gavai/sdk is the official high-level client for the gavAI public REST API. It wraps every resource in typed methods, ships request and response shapes in the same package (no separate @types install), and authenticates with a bearer token. By the end of this page you will have it installed, authenticated, and calling the 14 resource namespaces it exposes.
Install
Minimal example
One file, one read call. If this prints youruser_id, the SDK is wired correctly.
The call below maps to .
client.ts
bun run client.ts.
Authentication
The constructor accepts exactly one token. PassapiKey or sessionToken — never both.
See Authentication for the full token lifecycle — scopes, rotation, and revocation.
The 14 resource namespaces
Every resource hangs off theGavai instance as a typed namespace. Each namespace exposes the methods listed in the API reference for that resource.
Constructor options
Everything is passed tonew Gavai({ ... }).
A composite example
This block shows the patterns you will use most: construct, inject hooks, call multiple namespaces, narrow errors by class.composite.ts
Errors at a glance
The SDK throwsGavaiError for API-level failures and GavaiNetworkError for transport failures (DNS, connection refused, timeout). GavaiError carries status, code, message, details, and headers — headers["x-request-id"] is what you attach to a support ticket.
Common code values: token_expired, insufficient_scope, rate_limited, workspace_forbidden, not_found.
Full catch patterns and retry guidance live in Error handling.
Versioning
The public API is versioned by URL prefix (/v1, /v2, …). Each major SDK version tracks the matching API version — they ship together. Mixing major SDK and API versions is not supported.