Overview
TheClientOptions interface defines all configuration options available when creating a new Limrun client instance. These options control authentication, networking, retries, timeouts, logging, and more.
Type Definition
Options
apiKey
Your Limrun API key for authentication. This key is used to authenticate all requests to the Limrun API.Default: Reads from
process.env.LIM_API_KEYExample:Set to
null to explicitly omit API key authentication. You must then provide custom Authorization headers for each request.baseURL
Override the default base URL for API requests. Useful for testing against staging environments or using regional endpoints.Default: Reads from
process.env.LIMRUN_BASE_URL, falls back to https://api.limrun.comExample:timeout
The maximum amount of time (in milliseconds) that the client will wait for a response from the server before timing out a single request.Default:
300000 (5 minutes)Unit: millisecondsExample:Request timeouts are retried by default based on the
maxRetries setting. In a worst-case scenario, you may wait up to timeout * (maxRetries + 1) milliseconds before the promise fails.maxRetries
The maximum number of times the client will retry a request in case of temporary failures, such as network errors or 5XX server errors.Default: Retries are automatically performed for:
2Example:- Network connection errors
- Request timeouts (408)
- Conflict errors (409)
- Rate limit errors (429)
- Server errors (5XX)
fetchOptions
Additional options to pass to the underlying Common use cases:
fetch implementation. These options are merged with per-request options, with per-request options taking precedence.Default: undefinedExample:- Setting custom headers for all requests
- Configuring CORS mode
- Setting credentials policy
- Configuring cache behavior
fetch
Specify a custom Example:Use cases:
fetch function implementation. This is useful for environments where the global fetch is not available or when you need to inject custom networking behavior.Default: Uses the global fetch functionType:- Node.js environments without native fetch
- Custom HTTP clients (e.g., axios wrapper)
- Request interception and logging
- Testing with mock fetch implementations
logLevel
Set the logging verbosity level. Controls which log messages are output by the SDK.Default: Reads from Log Levels:
process.env.LIMRUN_LOG, falls back to 'warn'Type: 'debug' | 'info' | 'warn' | 'error'Example:debug- Detailed debugging information including request/response detailsinfo- General informational messages about requestswarn- Warning messages (default)error- Error messages only
logger
Provide a custom logger implementation for handling SDK log output.Default: Example:Use cases:
globalThis.consoleType:- Integrate with application logging systems (e.g., Winston, Pino)
- Send logs to monitoring services
- Format log output for specific environments
- Suppress logs entirely
defaultHeaders
Default headers to include with every request to the API. These headers can be overridden or removed in individual requests.Default:
undefinedType: Headers | Record<string, string | undefined> | Array<[string, string]>Example:To remove a default header in a specific request, set it to
null in the request options.defaultQuery
Default query parameters to include with every request to the API. These parameters can be overridden or removed in individual requests.Default:
undefinedExample:To remove a default query parameter in a specific request, set it to
undefined in the request options.Configuration Examples
Minimal Configuration
Use environment variables for all configuration:Development Configuration
Detailed logging and longer timeouts:Production Configuration
Optimized for production with custom logging:Testing Configuration
Mock fetch and custom base URL:Regional Configuration
Connect to a specific regional endpoint:Custom Headers and Query Parameters
Set default headers and query params for all requests:Environment Variables
The following environment variables are automatically read by the Limrun client:| Variable | Description | Default |
|---|---|---|
LIM_API_KEY | Your Limrun API key | null |
LIMRUN_BASE_URL | Base URL for API requests | https://api.limrun.com |
LIMRUN_LOG | Log level | 'warn' |
TypeScript Types
LogLevel
Logger
Fetch
HeadersLike
Best Practices
Use Environment Variables for Sensitive Data
Use Environment Variables for Sensitive Data
Always store API keys and other sensitive configuration in environment variables rather than hardcoding them:
Configure Appropriate Timeouts
Configure Appropriate Timeouts
Set timeouts based on your expected operation duration:
Use Debug Logging During Development
Use Debug Logging During Development
Enable debug logging to troubleshoot issues:
Integrate with Your Logging System
Integrate with Your Logging System
Provide a custom logger to integrate with your application’s logging infrastructure:
Configure Retries Based on Operation Type
Configure Retries Based on Operation Type
Adjust retry settings based on the criticality and idempotency of your operations:
See Also
- Limrun Client - Main client documentation
- Authentication - Authentication setup guide
- Retries & Timeouts - Detailed retry behavior
- Logging - Advanced logging configuration