# Forecast your spending

> Forecast a project's spending for the coming days or months with Cost Explorer, based on its recent daily average.

This guide forecasts a project's spending for the rest of the month. Read
[Forecasts](/cost-explorer/concepts/forecasts) first to know what a forecast can and cannot predict.

## Before you begin

Sign in with the [CLI](/developer/cli), get a
[token](/identity/get-a-token) for the API, or create the
[Python client](/cost-explorer/guides/use-the-python-client).

## 1. Request the forecast

A forecast period starts today or later and ends within 90 days. Choose `daily` rows to see each
day, or `monthly` for one total per month. This request forecasts from today, October 7, to the
end of October, using the last 7 days of spending:

<CodeBlockTabs defaultValue="CLI">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="CLI">
      CLI
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="API">
      API
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="Python">
      Python
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="CLI">
    ```sh
    openstack cost forecast create \
      --start 2026-10-07 \
      --end 2026-11-01 \
      --granularity monthly \
      --lookback-days 7
    ```
  </CodeBlockTab>

  <CodeBlockTab value="API">
    ```sh
    curl --request POST https://cost-explorer.public.global.vexxhost.net/v1/cost_forecasts \
      --header "X-Auth-Token: $TOKEN" \
      --header "Content-Type: application/json" \
      --data '{
        "time_period": {"start": "2026-10-07T00:00:00Z", "end": "2026-11-01T00:00:00Z"},
        "granularity": "monthly",
        "lookback_days": 7
      }'
    ```
  </CodeBlockTab>

  <CodeBlockTab value="Python">
    ```python
    forecast = costs.cost_forecasts.create(
        time_period={"start": "2026-10-07T00:00:00Z", "end": "2026-11-01T00:00:00Z"},
        granularity="monthly",
        lookback_days=7,
    )
    ```
  </CodeBlockTab>
</CodeBlockTabs>

Forecasts take the same filters as cost reports. See
[Break down your costs](/cost-explorer/guides/break-down-costs#3-filter-what-counts).

## 2. Read the result

```
+----------------------+----------------------+------------------+------+-----------+
| Start                | End                  | Amount           | Unit | Estimated |
+----------------------+----------------------+------------------+------+-----------+
| 2026-10-07T15:20:00Z | 2026-11-01T00:00:00Z | 865.425000000000 | USD  | True      |
+----------------------+----------------------+------------------+------+-----------+
```

The API returns the same forecast with the history it averaged:

```json
{
  "as_of": "2026-10-07T15:20:00Z",
  "model": "trailing_spend_average",
  "estimated": true,
  "history_period": {"start": "2026-09-30T15:20:00Z", "end": "2026-10-07T15:20:00Z"},
  "total": {"amount": "865.425000000000", "unit": "USD"},
  "regions": [{"name": "ca-ymq-1", "data_through": "2026-10-07T14:00:00Z"}],
  "forecast_results_by_time": [
    {
      "time_period": {"start": "2026-10-07T15:20:00Z", "end": "2026-11-01T00:00:00Z"},
      "mean_value": "865.425000000000"
    }
  ]
}
```

A period that starts today begins at the current time, which `as_of` shows. The project is
forecast to spend about 865 more by the end of October.

## Verify

Compare the forecast with what the month has cost so far: add a cost report from October 1 to
today, and the sum is the expected total for October.

## Next steps

* Get alerted when a month is forecast to go over with a
  [budget's forecasted threshold](/budgets/concepts/thresholds).
* Look up every field in the [API reference](/cost-explorer/api).
