Quickstart

Prerequisites

  1. A LevelFour account with API access enabled
  2. An API key (create one in Settings > API Keys in the dashboard)

API keys use the format l4_live_* for production and l4_test_* for test environments.

Install the SDK

pip install levelfour

Set Your API Key

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

export LEVELFOUR_API_KEY="l4_live_your_key_here"

Make Your First Request

Verify your connection by calling the whoami endpoint:

from levelfour import LevelFour

client = LevelFour()

me = client.auth.get_whoami()
print(me)

Get Savings by Provider

Retrieve a summary of potential savings grouped by cloud provider:

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

List Recommendations

Paginate through all recommendations:

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

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

Next Steps

  • Authentication - API key configuration, rotation, and security
  • SDKs - Complete language-specific reference
  • Resources - Per-resource guides with all methods and examples
  • Error Handling - Catch and handle specific error types
  • Pagination - Iterate through large result sets