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

# Estimate Cost

> Estimates the cost of the original and rewritten version of a query.

Estimate the cost of running a query before and after Isofold optimization.

This endpoint is primarily supported for **BigQuery**, where dry-run mode provides exact byte scan estimates. For other warehouses, estimates are heuristic-based.

***

## Request

Make a `GET` request to `/cost` with a `query` parameter:

```bash theme={null}
curl -G https://api.isofold.com/cost \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "query=SELECT * FROM users"
```

### Query Parameters

| Parameter | Type   | Required | Description               |
| --------- | ------ | -------- | ------------------------- |
| `query`   | string | ✅        | Raw SQL query to evaluate |

***

## Response

```json theme={null}
{
  "original_cost": 0.29,
  "optimized_cost": 0.11,
  "savings": 0.18
}
```

### Fields

| Field            | Type   | Description                                    |
| ---------------- | ------ | ---------------------------------------------- |
| `original_cost`  | number | Cost estimate of the unoptimized query (USD)   |
| `optimized_cost` | number | Cost estimate of the rewritten query (USD)     |
| `savings`        | number | Difference between original and optimized cost |

***

## Notes

* On **BigQuery**, this uses real dry-run estimates.
* On other engines, costs are approximated using:
  * Column count
  * Join complexity
  * Filter selectivity
* Use this endpoint to evaluate query rewrites without executing them.

***

Next: [Verify Result Equivalence](/api-reference/endpoint/verify)


## OpenAPI

````yaml GET /cost
openapi: 3.1.0
info:
  title: Isofold API
  description: >-
    Programmatic interface for sending queries, estimating cost, and verifying
    outputs using Isofold.
  version: 1.0.0
servers:
  - url: https://api.isofold.com
security:
  - bearerAuth: []
paths:
  /cost:
    get:
      description: Estimates the cost of the original and rewritten version of a query.
      parameters:
        - name: query
          in: query
          description: SQL query string
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Cost estimate result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CostEstimate'
components:
  schemas:
    CostEstimate:
      type: object
      properties:
        original_cost:
          type: number
        optimized_cost:
          type: number
        savings:
          type: number
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````