Yasminaai TypeScript Library
Table of Contents
- Installation
- Reference
- Usage
- Environments
- Request and Response Types
- Exception Handling
- Advanced
- Contributing
Installation
Reference
A full reference for this library is available here.Usage
Instantiate and use the client with the following:Environments
This SDK allows you to configure different environments for API requests.Request and Response Types
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the following namespace:Exception Handling
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.Advanced
Subpackage Exports
This SDK supports direct imports of subpackage clients, which allows JavaScript bundlers to tree-shake and include only the imported subpackage code. This results in much smaller bundle sizes.Additional Headers
If you would like to send additional headers as part of the request, use theheaders request option.
Additional Query String Parameters
If you would like to send additional query string parameters as part of the request, use thequeryParams request option.
Retries
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2). Which status codes are retried depends on theretryStatusCodes generator configuration:
legacy (current default): retries on
recommended: retries on
- 408 (Timeout)
- 429 (Too Many Requests)
- 502 (Bad Gateway)
- 503 (Service Unavailable)
- 504 (Gateway Timeout)
maxRetries request option to configure this behavior.
Timeouts
The SDK defaults to a 60 second timeout. Use thetimeoutInSeconds option to configure this behavior.
Aborting Requests
The SDK allows users to abort requests at any point by passing in an abort signal.Access Raw Response Data
The SDK provides access to raw response data, including headers, through the.withRawResponse() method.
The .withRawResponse() method returns a promise that results to an object with a data and a rawResponse property.
Logging
The SDK supports logging. You can configure the logger by passing in alogging object to the client options.
logging object can have the following properties:
level: The log level to use. Defaults tologging.LogLevel.Info.logger: The logger to use. Defaults to alogging.ConsoleLogger.silent: Whether to silence the logger. Defaults totrue.
level property can be one of the following values:
logging.LogLevel.Debuglogging.LogLevel.Infologging.LogLevel.Warnlogging.LogLevel.Error
logging.ILogger interface.
Custom Fetch
The SDK provides a low-levelfetch method for making custom HTTP requests while still
benefiting from SDK-level configuration like authentication, retries, timeouts, and logging.
This is useful for calling API endpoints not yet supported in the SDK.
Runtime Compatibility
The SDK works in the following runtimes:- Node.js 18+
- Vercel
- Cloudflare Workers
- Deno v1.25+
- Bun 1.0+
- React Native

