> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Max cost

> Learn how to use the max cost test

## Definition

The max cost test ensures that the maximum request cost (in USD) for the data is within a given range.

## Taxonomy

* **Task types**: LLM.
* **Availability**: development (Continuously evaluate your models and datasets as you iterate on their versions.)
  and monitoring (Monitor a model in production, measure its health, check for drifts and set up alerts.).

## Why it matters

* If you use an external API to get the model predictions, you might be charged for each request. This is the case for most third-party LLMs, such as OpenAI GPTs. Setting up tests for the cost of the requests is important to avoid unexpected costs.

## Test configuration examples

If you are writing a `tests.json`, here are a few valid configurations for the character length test:

```json Development theme={null}
[
  {
    "name": "Max cost below $ 0.5",
    "description": "Make sure that the max cost for a single inference is below $ 0.5",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "maxCost",
        "operator": "<",
        "value": 0.5
      }
    ],
    "subpopulationFilters": null,
    "mode": "development",
    "usesValidationDataset": true,
    "usesTrainingDataset": false,
    "usesMlModel": true,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

```json Monitoring theme={null}
[
  {
    "name": "Max cost below $ 0.5",
    "description": "Make sure that the max cost for a single inference is below $ 0.5",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "maxCost",
        "operator": "<",
        "value": 0.5
      }
    ],
    "subpopulationFilters": null,
    "mode": "monitoring",
    "usesProductionData": true,
    "evaluationWindow": 3600,
    "delayWindow": 0,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

## Related

* [Mean cost](https://docs.openlayer.com/tests/performance/mean-cost).
* [Total cost](https://docs.openlayer.com/tests/performance/total-cost).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.