Get Started

API Quickstart

Install a LevelFour SDK for Python, TypeScript or Go, point it at an API key, and make your first call.

LevelFour publishes official SDKs for Python, TypeScript and Go, all generated from the same OpenAPI spec. Install one, give it an API key, and your code reads the same cloud spend and savings backlog the dashboard shows.

Prerequisites

  • A LevelFour account with API access enabled.
  • An API key, created in the dashboard under Settings > API Keys. Authentication has the key formats and what each scope reaches.

Set up

Install an SDK

pip install levelfour

Set your API key

Export the key as an environment variable. All SDKs auto-detect it:

export LEVELFOUR_API_KEY="l4_live_your_key_here"
Keep the key out of anything you commit. An l4_live_ key reaches production data, and an l4_test_ key is the one to experiment with. Authentication covers keeping a key out of your source.

Make your first request

Call the whoami endpoint:

from levelfour import LevelFour

client = LevelFour()

me = client.auth.get_whoami()
print(me)
That response is the proof: the SDK found your key and the API accepted it.
A 401 back from that call means the API rejected the key. Re-check the export, then confirm the key is still active under Settings > API Keys. Error handling maps each status code to a typed error class.

Read your data

Neither of these calls depends on the other, so run whichever you need.

Savings by provider

One call totals the potential savings LevelFour has found, split by cloud provider:

summary = client.recommendations.get_savings_by_provider()
print(summary)

List recommendations

The list method pages itself, so one loop walks every recommendation:

page = client.recommendations.list(page_size=10)

for rec in page:
    print(f"{rec.service}: ${rec.monthly_savings}/mo")

Every method, parameter and response shape lives in Recommendations. Pagination covers the response envelope and taking page control by hand.

Next

  • Authentication covers key scopes, rotation, and what to do when a key leaks
  • SDKs is the per-language reference, with constructor options and sub-clients
  • Resources is every method, grouped by the resource it reads
  • Error handling maps each status code to a typed error class, and names what the SDKs retry before you see it
  • Pagination is the response envelope and manual page control when the auto-iterator is not what you want
  • CLI is the same data from the terminal, where l4 whoami stands in for this page
  • MCP puts the same data in Claude Code, Claude, Cursor, VS Code or Windsurf
  • Quickstart connects the cloud accounts these numbers come from

On this page

Ask the FinOps Agent about your cloud spend