> This page is for Gateway.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Cost governance and savings

> Where Gateway reports spend (Usage & spend, Logs, and per-response cost), how managed and BYOK costs read, and the routing, compression, and caching settings that lower spend.

Gateway reports spend from every vendor in one place and offers settings that lower it without application changes. To cap spend, use [Budgets](/merge-gateway/cost/budgets); for what you're billed, see [Plans and pricing](/merge-gateway/cost/pricing).

## Where spend is reported

**Usage & spend** in the [dashboard](https://gateway.merge.dev/usage-spend/overview) totals managed and BYOK spend, tokens, and requests across every vendor.

| Tab                | Breaks spend down by                                                             |
| ------------------ | -------------------------------------------------------------------------------- |
| **Overview**       | Totals over time, managed vs BYOK                                                |
| **By source**      | Model, provider, or vendor                                                       |
| **By attribution** | Project, policy, customer, or API key. Policies are labeled by their model alias |
| **Performance**    | Latency for the same traffic                                                     |

For a single request, open it in [Logs](https://gateway.merge.dev/logs): **Estimated cost** shows its cost with Merge's fee underneath, and the summary strip totals both over every request matching your filters. The figures read differently by key type:

| Key                 | Estimated cost                                            | Merge fee                                                 |
| ------------------- | --------------------------------------------------------- | --------------------------------------------------------- |
| **Merge-managed**   | What you're billed, with your plan rate applied           | The fee's share of that                                   |
| **Your own (BYOK)** | What the tokens cost on your vendor account at list price | What Merge bills you, the only part on your Merge invoice |

In your own tooling, read [`usage.cost`](/merge-gateway/api-overview#per-call-cost) from each response; it's `null`, not `0`, when the serving route has no price on file. Tools that read it automatically, such as Langfuse, need no setup.

> **Tip**
>
> Scope traffic to [projects](/merge-gateway/cost/projects) by team, product, or environment so **By attribution** shows who spent what.

## Savings levers

Levers stack: routing picks a cheaper model or vendor, while compression and caching shrink what each request sends.

| Lever                                                                                        | What it does                                                                                             | Configure it                                                |
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [Intelligent routing](/merge-gateway/routing/intelligent) on the **Cost** axis               | Scores each prompt's complexity and pushes most traffic toward the cheaper models in the policy          | **Routing policies**                                        |
| [Priority routing](/merge-gateway/routing/deterministic-strategies)                          | Puts a cheaper model first and falls back to others only on failure                                      | **Routing policies**                                        |
| [Tag-based routing](/merge-gateway/routing/overview#tag-based-routing)                       | Switches tagged low-stakes traffic, such as internal tools, to a cheaper strategy within the same policy | The project's **Routing** tab                               |
| [Context compression](/merge-gateway/cost/context-compression) in **Cost optimization** mode | Compacts JSON and trims long conversations before they reach the model                                   | **Configure → Request settings → Defaults**, or per project |
| [Prompt caching](/merge-gateway/capabilities/prompt-caching)                                 | Bills a repeated prompt prefix at the vendor's lower cached rate                                         | Cache markers or session hints on the request               |

To measure a lever, compare the affected project or policy on **By attribution** before and after.

## Next steps

#### [Budgets](/merge-gateway/cost/budgets)

Cap spend at the organization, project, key, or customer scope

#### [Routing policies](/merge-gateway/routing/overview)

Route by cost, performance, or capability across vendors

#### [Context compression](/merge-gateway/cost/context-compression)

Reduce input tokens on long or JSON-heavy requests