Yasminaai Java Library
Table of Contents
Installation
Gradle
Add the dependency in yourbuild.gradle file:
Maven
Add the dependency in yourpom.xml file:
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.Base Url
You can set a custom base URL when constructing the client.Exception Handling
When the API returns a non-success status code (4xx or 5xx response), an API exception will be thrown.Advanced
Custom Client
This SDK is built to work with any instance ofOkHttpClient. By default, if no client is provided, the SDK will construct one.
However, you can pass your own client like so:
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). Before defaulting to exponential backoff, the SDK will first attempt to respect theRetry-After header (as either in seconds or as an HTTP date), and then the X-RateLimit-Reset header
(as a Unix timestamp in epoch seconds); failing both of those, it will fall back to exponential backoff.
Which status codes are retried depends on the retry-status-codes 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 client option to configure this behavior.
Timeouts
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.Custom Headers
The SDK allows you to add custom headers to requests. You can configure headers at the client level or at the request level.Access Raw Response Data
The SDK provides access to raw response data, including headers, through thewithRawResponse() method.
The withRawResponse() method returns a raw client that wraps all responses with body() and headers() methods.
(A normal client’s response is identical to a raw client’s response.body().)

