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

# Transforms

> Turn the usage events, Prometheus metrics, and OpenTelemetry metrics your services already emit into cost data

A transform turns usage your services already emit into cost data. It reads one
event shape, maps it to cost columns, prices it, and records the result beside
the rest of your spend. Use it when you have usage but no bill, such as tokens per
customer from your own AI gateway or requests counted by a Prometheus counter.

If you already have billing records with costs, send them with
[Push FOCUS data](https://docs.costgraph.ai/costgraph/integrations/focus-push.md) instead.

## Supported formats

Each transform accepts one format. You choose it when you create the transform.

| Format | What you send | How CostGraph reads it |
| - | - | - |
| JSON | Any JSON object, including CloudEvents, posted to the API. | Each event becomes one cost row. |
| OpenTelemetry | Delta sums, gauges, and delta histograms from an OpenTelemetry Collector. | Each sum or histogram data point becomes one cost row. Each gauge value becomes one row for the time it was held. |
| Prometheus | Counters or gauges sent with Prometheus `remote_write`. | Each counter increase becomes one cost row. Each gauge value becomes one row for the time it was held. |

## Counters and gauges

A counter, such as tokens or requests served, only goes up. CostGraph bills each
increase. A gauge, such as seats in use or running instances, goes up and down.
CostGraph bills a gauge by value and time: 10 seats held for 30 minutes is 5
seat-hours. Price a gauge per unit-hour.

OpenTelemetry metrics declare their own type. For Prometheus, choose
**Metric type** on the transform.

![Prometheus transform with Metric type set to Gauge, priced per unit-hour from value\_hours.](https://mintcdn.com/baselinehq/dzvOs31RAcxRfsEK/images/transforms/prometheus-gauge.png?fit=max\&auto=format\&n=dzvOs31RAcxRfsEK\&q=85\&s=37e1743293b3b85d3faeb3b9f0abafa3)

## Transform setup

A transform is set up in four parts, each on its own tab of the transform:

1. **Mapping** turns a sample event into a cost row. [Create a transform](https://docs.costgraph.ai/costgraph/integrations/transforms/create.md).
2. **Cost** prices each row. [Price usage](https://docs.costgraph.ai/costgraph/integrations/transforms/cost.md).
3. **Send usage** shows the endpoint and configuration for your format. [Send usage](https://docs.costgraph.ai/costgraph/integrations/transforms/send.md).
4. **Recent events** shows what was accepted and rejected. [Fix rejected events](https://docs.costgraph.ai/costgraph/integrations/transforms/recent-events.md).

The transform checks your sample event as you edit and shows the row it produces.
You can save only when that preview is ready.

## Requirements

* Membership in the organization to create, edit, or delete transforms.
* A push connection for each source of usage. Create it in **Integrations**. Refer to
  [Create the connection](https://docs.costgraph.ai/costgraph/integrations/focus-push.md#create-the-connection).
* An API key with the `focus:write` scope, created in **Settings > API keys**.

## Next steps

> [card] [Create a transform](https://docs.costgraph.ai/costgraph/integrations/transforms/create.md)
>
> Map a sample event to cost columns and save it.


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