SDKs
SDK Overview
Available SDKs
LevelFour provides official SDKs in three languages. All SDKs are generated from the same OpenAPI specification using Fern and share consistent patterns:
- Constructor-level authentication with API key and environment variable fallback
- Typed error hierarchy mapping HTTP status codes to specific exception classes
- Auto-pagination iterators for large result sets
- Webhook signature verification using HMAC-SHA256 (Standard Webhooks)
- Configurable retries for transient failures (2 retries by default)
- 30-second request timeout by default
| SDK | Package | Min Version |
|---|---|---|
| Python | levelfour | Python 3.11+ |
| TypeScript | levelfour | Node.js 22+ |
| Go | github.com/LevelFourAI/levelfour-go | Go 1.24+ |
Constructor Options
All SDK constructors accept the same core options:
| Option | Python | TypeScript | Go | Default |
|---|---|---|---|---|
| API Key | api_key | apiKey | 1st positional arg | LEVELFOUR_API_KEY env var |
| Base URL | base_url | baseURL | levelfour.WithBaseURL() | https://api.levelfour.ai |
| Timeout | timeout | timeoutInSeconds | levelfour.WithHTTPClient() | 30s |
| Max Retries | max_retries | maxRetries | levelfour.WithMaxRetries() | 2 |
| HTTP Client | http_client | fetch | levelfour.WithHTTPClient() | Built-in |
Sub-Clients
Every SDK client exposes the same set of resource sub-clients:
| Sub-Client | Python | TypeScript | Go |
|---|---|---|---|
| Recommendations | client.recommendations | client.recommendations | client.Recommendations |
| Recommendations Audit | client.recommendations.audit | client.recommendations.audit | client.Recommendations.Audit |
| Costs | client.costs | client.costs | client.Costs |
| Providers | client.providers | client.providers | client.Providers |
| API Keys | client.api_keys | client.apiKeys | client.APIKeys |
| Webhooks | client.webhooks | client.webhooks | client.Webhooks |
| Auth | client.auth | client.auth | client.Auth |