SDKs

SDK Overview

Python, TypeScript and Go side by side: packages and minimum versions, the constructor options under each language's names, and where each client hangs the shared resources.

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
Webhooksclient.webhooksclient.webhooksclient.Webhooks
Authclient.authclient.authclient.Auth
Cost alertsclient.cost_alertsclient.costAlertsclient.CostAlerts
Realized savings detail--client.Audit
Commitments--client.Commitments
Google Cloud--client.GoogleCloud
Tags--client.Tags
Cost views--client.CostViews
Anomalies--client.Anomalies
Accounts--client.Accounts
Integrations--client.Integrations
Automated Savings grants--client.SavingsGrants
Repository binding--client.RepoBinding

A row with only a Go name is in the Go SDK today. Every one of them is also plain REST, so any language reaches it through the API reference.

API keys are created and rotated in the dashboard, not through an SDK. API keys has the steps.

Next

  • Python, TypeScript and Go each carry the install command, the full constructor and the per-request options
  • API 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

On this page

Ask the FinOps Agent about your cloud spend