# Read prices

> Every task's prices, per option, read live from the price list — the same figures `POST /v1/tasks/{name}/estimate` answers for each option.

`GET https://api.refabric.com/v1/pricing`

**Filters and sorting**

- `task` answers one task only.

**Authentication.** Any key: the price list is the same for every key of your account.

**Key features**

- Read live: a price change shows here at once.

**Common use cases**

- Show what each option costs before anyone runs a task.

**Example values.** Read live from `GET /v1/pricing`.

**See also**

- `POST /v1/tasks/{name}/estimate`
- `GET /v1/account/usage`

Authentication: `Authorization: Key $REFABRIC_API_KEY`.

## Query parameters

- `task` (string, _optional_, default: ``) — Only this task (`image.generate`).

## Header parameters

- `Refabric-Version` (string, _optional_, format: date) — The contract version you wrote against (a date). Absent: the current version.
- `X-Request-ID` (string, _optional_, max length 128) — Your own id for this request; we answer it back under X-Client-Request-ID.

## Response 200

Done: the answer is in the body.

- `items` (array<object>, _required_) — One entry per task, by name.
  - `task` (string, _required_) — The task.
    Example: `image.generate`
  - `credit_types` (array<string> | null, _optional_) — The credit types its prices are in.
    Values: `refabric_credits` (Spent by tasks.); `model_credits` (Credits for model training.)
    Example: `["refabric_credits"]`
  - `prices` (array<object> | null, _optional_) — One row per combination of the options that change the price.
    - `options` (object, _required_) — The options, by field name, this price is for.
      Example: `{"resolution":"4k"}`
    - `credits` (integer, _required_) — The credits this combination costs. Read it live: `GET /v1/pricing`.
    - `credit_type` (string | null, _required_) — Which kind of credit an amount is counted in.
      Values: `refabric_credits` (Spent by tasks.); `model_credits` (Credits for model training.)
      Example: `refabric_credits`
  - `unchanged` (array<string> | null, _optional_) — The options that do not change the price.
    Example: `["aspect_ratio"]`
  - `per` (string | null, _optional_) — The count or list the price is a multiple of: a row is the price of one.
    Example: `image_count`
  - `sizes` (object | null, _optional_) — By list field: the price at every length it takes, in runs of equal price.
  - `rule` (string | null, _optional_) — How the price depends on what you send, when it does.
    Example: `The price depends on how many photos the shoot plans.`
  - `example` (object | null, _optional_) — With `rule` or `sizes`: the example the price was measured on.
    - `body` (object, _required_) — The example's request body.
      Example: `{"prompt":"A linen dress"}`
    - `credits` (integer, _required_) — The credits the example costs. Read it live: `GET /v1/pricing`.
    - `credit_type` (string | null, _required_) — Which kind of credit an amount is counted in.
      Values: `refabric_credits` (Spent by tasks.); `model_credits` (Credits for model training.)
      Example: `refabric_credits`

```json
{
  "items": []
}
```

## Response 400

The request cannot be read as it was sent (a header, the URL or the body's form).

```json
{
  "error": {
    "code": "string",
    "type": "invalid_request",
    "message": "string",
    "field": "string",
    "retryable": true,
    "docs": "string",
    "request_id": "string",
    "ctx": {
      "required": 0,
      "balance": 0,
      "retry_after": 0
    },
    "input": null,
    "job_id": "string",
    "required": 0,
    "balance": 0
  }
}
```

## Response 401

No valid API key was sent.

```json
{
  "error": {
    "code": "string",
    "type": "invalid_request",
    "message": "string",
    "field": "string",
    "retryable": true,
    "docs": "string",
    "request_id": "string",
    "ctx": {
      "required": 0,
      "balance": 0,
      "retry_after": 0
    },
    "input": null,
    "job_id": "string",
    "required": 0,
    "balance": 0
  }
}
```

## Response 403

Your key or your plan does not allow this.

```json
{
  "error": {
    "code": "string",
    "type": "invalid_request",
    "message": "string",
    "field": "string",
    "retryable": true,
    "docs": "string",
    "request_id": "string",
    "ctx": {
      "required": 0,
      "balance": 0,
      "retry_after": 0
    },
    "input": null,
    "job_id": "string",
    "required": 0,
    "balance": 0
  }
}
```

## Response 422

A field is missing or has a value this operation cannot use.

```json
{
  "error": {
    "code": "string",
    "type": "invalid_request",
    "message": "string",
    "field": "string",
    "retryable": true,
    "docs": "string",
    "request_id": "string",
    "ctx": {
      "required": 0,
      "balance": 0,
      "retry_after": 0
    },
    "input": null,
    "job_id": "string",
    "required": 0,
    "balance": 0
  }
}
```

## Response 429

Too many requests: wait for the number of seconds in the Retry-After header.

```json
{
  "error": {
    "code": "string",
    "type": "invalid_request",
    "message": "string",
    "field": "string",
    "retryable": true,
    "docs": "string",
    "request_id": "string",
    "ctx": {
      "required": 0,
      "balance": 0,
      "retry_after": 0
    },
    "input": null,
    "job_id": "string",
    "required": 0,
    "balance": 0
  }
}
```

## Response 500

Something went wrong on our side; retry, and quote the request id if it keeps happening.

```json
{
  "error": {
    "code": "string",
    "type": "invalid_request",
    "message": "string",
    "field": "string",
    "retryable": true,
    "docs": "string",
    "request_id": "string",
    "ctx": {
      "required": 0,
      "balance": 0,
      "retry_after": 0
    },
    "input": null,
    "job_id": "string",
    "required": 0,
    "balance": 0
  }
}
```

## Request

```python
import os
import requests

url = "https://api.refabric.com/v1/pricing"

headers = {"Authorization": f"Key {os.environ['REFABRIC_API_KEY']}"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.refabric.com/v1/pricing';
const options = {method: 'GET', headers: {Authorization: `Key ${process.env.REFABRIC_API_KEY}`}};

try {
    const response = await fetch(url, options);
    const data = await response.json();
    console.log(data);
} catch (error) {
    console.error(error);
}
```

```bash
curl --request GET \
    --url https://api.refabric.com/v1/pricing \
    --header "Authorization: Key $REFABRIC_API_KEY"
```
