SDKs

SDK Overview

Python, TypeScript and Go, each generated from the same OpenAPI specification with Fern. Method and option names follow the conventions of the language you are working in. The API underneath is the same one.

SDKPackageMin Version
PythonlevelfourPython 3.11+
TypeScriptlevelfourNode.js 22+
Gogithub.com/LevelFourAI/levelfour-goGo 1.24+
Working in another language? The SDKs sit on the same REST API. API reference has the endpoints, and l4 api sends an authenticated request to any of them from a shell.

The behavior all three share lives on the page that owns it:

  • The API key goes in the constructor, and falls back to the LEVELFOUR_API_KEY environment variable when you leave it out. Authentication has key formats, scopes and rotation.
  • A typed error hierarchy maps HTTP status codes to specific exception classes. Error handling has the status table, and the failures each client retries before you ever see them.
  • Auto-pagination iterators walk large result sets. Pagination has the response envelope and the iteration forms.
  • Webhook signature verification using HMAC-SHA256 (Standard Webhooks). Webhooks has the header contract, the algorithm and the timestamp tolerance.

Constructor options

The same settings in every SDK, under each language's own name.

OptionPythonTypeScriptGoDefault
API Keyapi_keyapiKey1st positional argLEVELFOUR_API_KEY env var
Base URLbase_urlbaseURLlevelfour.WithBaseURL()https://api.levelfour.ai
TimeouttimeouttimeoutInSecondslevelfour.WithHTTPClient()30s
Max Retriesmax_retriesmaxRetrieslevelfour.WithMaxRetries()2
HTTP Clienthttp_clientfetchlevelfour.WithHTTPClient()Built-in
Go has no standalone timeout option, which is why two rows name the same function. Set Timeout on the http.Client you hand to levelfour.WithHTTPClient(). The Go SDK page has the example.

Sub-clients

Each client hangs the resources off a sub-client. The names follow the language.

Sub-ClientPythonTypeScriptGo
Recommendationsclient.recommendationsclient.recommendationsclient.Recommendations
Recommendations Auditclient.recommendations.auditclient.recommendations.auditclient.Recommendations.Audit
Costsclient.costsclient.costsclient.Costs
Providersclient.providersclient.providersclient.Providers
API Keysclient.api_keysclient.apiKeysclient.APIKeys
Webhooksclient.webhooksclient.webhooksclient.Webhooks
Authclient.authclient.authclient.Auth

Next

  • Python, TypeScript and Go each carry the install command, the full constructor and the per-request options
  • Quickstart is install, key, first call
  • Resources is every method with its parameters and response shapes, in Python, TypeScript and Go
  • API reference is the REST surface the clients are generated from
  • CLI is the same data from the terminal