Resources

Costs

The costs methods read what your organization spends: an overall summary, per-day and per-month series, and a per-service breakdown you can page, sort, filter and export as CSV. Some cover the whole organization. The rest take a provider ID and answer the same questions for one cloud.

Organization-wide

Get cost summary

Returns an overall cost summary: total costs, forecast, savings, and a breakdown by provider.

summary = client.costs.get_summary()

List costs

Returns a cost breakdown in one of these formats: table (paginated), chart (aggregated for stacked bar charts), csv (export), or raw (all records). Format scopes some of the parameters below: page and page_size apply to table, granularity to chart.

breakdown = client.costs.list(
    format="table",
    period="2026-03",
    provider_id="aws",
    page=1,
    page_size=50,
    sort_by="cost",
    sort_order="desc",
)

List costs parameters

ParameterTypeDescription
formatstringResponse format: table, chart, csv, raw
periodstringPeriod in YYYY-MM format (defaults to current month)
provider_idstringFilter by provider: aws, gcp, azure, k8s
granularitystringdaily or monthly (for chart format)
group_bystringGrouping dimension: provider or account_id
startstringStart date (ISO 8601)
endstringEnd date (ISO 8601)
pageintPage number (table format only)
page_sizeintItems per page (table format only)
sort_bystringSort field: cost, service, region, account_id, change_percentage
sort_orderstringasc or desc
period defaults to the current month, and the current month is still running. Pass a completed YYYY-MM when the number has to hold still.

Get daily costs

Returns costs aggregated per day for a given date range.

daily = client.costs.get_daily_costs(
    start="2026-03-01T00:00:00.000Z",
    end="2026-03-31T00:00:00.000Z",
)

Get monthly costs

Returns costs aggregated per month across all time.

monthly = client.costs.get_monthly_costs()

One provider

Each of these takes a provider ID. Providers has the IDs, and what a provider-scoped call returns for one your organization has not connected.

Get provider summary

Returns a per-provider cost summary with monthly costs, forecast, potential savings, and the top 3 services for that provider.

summary = client.costs.get_provider_summary("aws")

List by provider

Returns a paginated per-provider cost breakdown. Every row carries its previous-period cost and change percentage, and the response carries per-date totals across all pages, not just the page you asked for.

breakdown = client.costs.list_by_provider(
    "aws",
    preset="30D",
    granularity="daily",
    group_by=["service", "region"],
    service=["EC2", "RDS"],
    region=["us-east-1"],
    page=1,
    page_size=20,
    sort_by="cost",
    sort_order="desc",
)

List by provider parameters

ParameterTypeDescription
formatstringtable, chart, csv, or raw (defaults to table)
startstringStart date (ISO 8601)
endstringEnd date (ISO 8601)
presetstringDate preset: 30D, 6M, or 12M (overrides start/end)
granularitystringdaily or monthly
pageintPage number (1-indexed)
page_sizeintItems per page
sort_bystringSort field: service, environment, region, account_id, cost, previous_cost, change_percentage
sort_by_datestringSort by a specific date column (YYYY-MM-DD or YYYY-MM, overrides sort_by)
sort_orderstringasc or desc
group_bystring[]Multi-dimension grouping: service, account_id, region, tag
servicestring[]Filter by service
environmentstring[]Filter by environment
account_idstring[]Filter by account ID
regionstring[]Filter by region
tag_keystring[]Filter by tag key (required when group_by includes tag)
tag_valuestring[]Filter by tag value
preset overrides start and end. Send all three and the window you get is the preset's, not your dates.

Filtering and sorting turns these parameters into ready-to-run recipes, mostly for the l4 CLI, with the SDK equivalents at the end.

Get provider filters

Returns distinct values available for filtering the per-provider cost breakdown (services, regions, accounts, tag keys, tag values) within a date range. Populate an autocomplete with them, or check a user-supplied filter value before you query with it.

filters = client.costs.get_provider_filters(
    "aws",
    start="2026-01-01T00:00:00.000Z",
    end="2026-01-31T00:00:00.000Z",
)

Get provider timeline

Returns a per-provider cost timeline at the requested granularity. Plot it as a trend chart of one provider's cost over time.

timeline = client.costs.get_provider_timeline(
    "aws",
    start="2026-01-01T00:00:00.000Z",
    end="2026-03-31T00:00:00.000Z",
    granularity="daily",
)

Example: export costs to CSV

from levelfour import LevelFour

client = LevelFour()

csv_data = client.costs.list(
    format="csv",
    start="2026-01-01T00:00:00.000Z",
    end="2026-03-31T00:00:00.000Z",
)
print(csv_data)

Next

  • Providers has the provider IDs and the rest of the provider-scoped surface
  • Pagination has the defaults behind page and page_size, and the iterators that page for you
  • API reference is generated from the schema: every parameter, enum and response field