# catalogue()

Canonical URL: https://developers.iagenify.com/sdk/ref/iagenify/catalogue/
Language: en

`api.catalogue() → Promise<Price[]>`

Every model the account can call, with its real price. Read it instead of copying a price list into your code.

Status: GET /api/ai/prices · free · the billing grid itself

This is the grid the server bills from, not a copy of it. An application that hardcodes a price drifts the day a model is added, retired or repriced — and the drift is invisible until a user is quoted one number and charged another. One that reads this cannot drift.

## One row {#shape}

```javascript
{
  model: "gemini-3.5-flash",
  service: "text-to-text",
  provider: "gemini",
  unit: "1M tokens",
  credits: null,              // a flat price, when the unit has one
  creditsInput: 375,
  creditsOutput: 2250,
  creditsOutputVideo: null,
  videoOutputTokens: null,
  resolution: null,
  audio: null,
  deprecatedAfter: null,
  contextWindow: 1048576,     // token-billed rows only
  maxOutput: 65536,
  cachedInputRate: 0.25
}
```

## The fields {#fields}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `model` | string |  | The name you pass as `model` everywhere else. |
| `service` | string |  | What this row prices. One model appears once per service it serves. |
| `provider` | string |  | Which family serves it. Informational: you ask for a model, never for a provider. |
| `unit` | string |  | What is counted. It decides which credit field applies — see [Units](#units). |
| `credits` | integer|null |  | The flat price of one unit. `null` on token-billed rows. |
| `creditsInput · creditsOutput` | integer|null |  | Per million tokens, each direction counted and rounded up on its own. |
| `creditsOutputVideo · videoOutputTokens` | integer|null |  | For a model that can answer with video: that output's rate, and its fixed token count. |
| `resolution` | string|null |  | What distinguishes two rows of one model — an image size, a video definition. |
| `audio` | boolean|null |  | Whether this row is the one with sound. A video with sound is a different price. |
| `contextWindow` | integer|null |  | Tokens the model accepts in one turn. Token-billed rows only. |
| `maxOutput` | integer|null |  | The output ceiling the provider accepts. Asking for more is refused. |
| `cachedInputRate` | number|null |  | The share of the input rate paid for a token served from the provider's cache. |
| `deprecatedAfter` | string|null |  | A date after which this row stops being served. Non-null is your notice to migrate. |

## Units, and which field to read {#units}

Reading the wrong field is the common mistake here, because a token row and a flat row are the same shape with different halves filled in.

| unit | Read | Counted as |
| --- | --- | --- |
| 1M tokens | creditsInput · creditsOutput | Per million, each direction rounded up separately. |
| image | credits | One image, at that row's resolution. |
| second | credits | One second of video, at that definition and sound. |
| 1K characters | credits | Per thousand characters of text spoken. |
| minute | credits | Per minute of audio read. |
| song | credits | One track. |
| call | credits | One call, whatever its size. |

> **Never fall back with ||**
>
> On a token row credits is null, and credits || 100 quietly becomes 100. Test the unit, then read the field that unit names. This is the one pattern that produces a wrong number rather than an error.

## The eleven services {#services}

A service is an (input, output) pair, and it is derived from what you ask for rather than declared. The same model therefore holds several rows, one per pair it can serve.

| service | Takes | Gives back |
| --- | --- | --- |
| text-to-text | Text | Text |
| text-to-json | Text, plus a schema | An object matching the schema |
| multimodal-to-text | Text with images, audio, video or documents | Text |
| omni | Mixed input | Mixed output, text and media from one model |
| text-to-image | Text, optionally a starting picture | An image |
| text-to-video | Text, optionally a starting picture | A video |
| text-to-speech | Text | Audio |
| speech-to-text | Audio | Text |
| text-to-music | Text | A track |
| text-to-embedding | Text | A vector |
| text-reranking | A query and documents | The documents, reordered |

## How much comes back {#size}

80 rows, 28 models, 11 services, measured today. The row count exceeds the model count because of the variants: a model that serves three services and comes in four sizes is a dozen rows on its own.

> **Match on the model and the variant, never the model alone**
>
> Taking the first row for a model gives you a price that may belong to another resolution, another service, or the version without sound. Filter on what you are about to ask for.

## Recipes {#recipes}

### Pick the cheapest model that can answer in text

```javascript
const grid = await api.catalogue();

const cheapest = grid
  .filter((row) => row.service === "text-to-text" && !row.deprecatedAfter)
  .sort((a, b) => a.creditsInput - b.creditsInput)[0];

cheapest.model;        // what to pass as `model`
cheapest.maxOutput;    // the ceiling to stay under
```

### Estimate a text turn before making it

Round each direction up on its own, as the billing does. The estimate is a ceiling, not a prediction: the real cost is measured from what the provider reports, and cached input costs less.

```javascript
function estimateCredits(row, inputTokens, outputTokens) {
  if (row.unit !== "1M tokens") throw new Error(`not a token row: ${row.unit}`);
  const input = Math.ceil((inputTokens / 1_000_000) * row.creditsInput);
  const output = Math.ceil((outputTokens / 1_000_000) * row.creditsOutput);
  return input + output;
}

// What the same input costs once the provider is serving it from cache
function cachedInput(row, tokens) {
  return Math.ceil((tokens / 1_000_000) * row.creditsInput * row.cachedInputRate);
}
```

### Price a video before generating one

Video is billed by the second, and the second costs what the definition and the sound cost. So the row you must price against is the one matching both.

```javascript
function videoCost(grid, model, { resolution, audio, seconds }) {
  const row = grid.find((r) =>
    r.model === model &&
    r.service === "text-to-video" &&
    r.resolution === resolution &&
    r.audio === audio,
  );
  if (!row) throw new Error("no row for that combination");
  return row.credits * seconds;
}
```

> **A provider can hand back more than you asked for**
>
> A clip is sometimes a little longer than the requested duration, and the billed seconds are the seconds produced. Treat a per-second estimate as a floor, and leave headroom in a budget that has to cover one.

### Build a model picker

```javascript
const grid = await api.catalogue();

const byModel = new Map();
for (const row of grid) {
  const entry = byModel.get(row.model) || { model: row.model, services: new Set(), rows: [] };
  entry.services.add(row.service);
  entry.rows.push(row);
  byModel.set(row.model, entry);
}

// What one model can do, and what it costs to think with
for (const entry of byModel.values()) {
  const tokens = entry.rows.find((r) => r.unit === "1M tokens");
  console.log(
    entry.model,
    [...entry.services].join(" · "),
    tokens ? `${tokens.creditsInput} in / ${tokens.creditsOutput} out` : "",
    tokens?.contextWindow ?? "",
  );
}
```

### Watch for a model leaving

`deprecatedAfter` is the only warning you get in-band. Logging it turns a future failure into a dated task.

```javascript
const leaving = (await api.catalogue()).filter((row) => row.deprecatedAfter);

for (const row of leaving) {
  console.warn(`${row.model} (${row.service}) stops being served after ${row.deprecatedAfter}`);
}

// And guard the one you depend on
const mine = grid.find((r) => r.model === MODEL && r.service === "text-to-text");
if (!mine) throw new Error(`${MODEL} is no longer in the catalogue`);
```

## How often to read it {#caching}

The grid changes when models do — rarely, and never mid-request. Read it at boot, keep it, and refresh it on a schedule rather than per call. What you must not do is copy it into your source: then a change becomes a deployment, and a wrong quote in between.

```javascript
let grid = null;
let readAt = 0;

export async function catalogue(api, maxAgeMs = 3_600_000) {
  if (!grid || Date.now() - readAt > maxAgeMs) {
    const fresh = await api.catalogue();
    if (fresh.length) { grid = fresh; readAt = Date.now(); }   // keep the last good one
  }
  if (!grid) throw new Error("no catalogue available");
  return grid;
}
```

> **An empty array is a valid answer**
>
> The method hands back the rows it was given, and an empty list rather than throwing. Code that indexes into it without checking breaks against a server serving nothing — which is why the helper above keeps the last good grid.

## A model that is not in the grid {#missing}

There is no implicit fallback: asking for a model the grid does not carry for that service is refused, with the model and the service named. That refusal is deliberate — a silent substitution would bill one model's price for another's answer.

- [Credits](/sdk/concepts/credits): How a call is pre-authorised, settled, and refused.
- [turn()](/sdk/ref/models/turn): The stateless turn these prices are charged against.
- [Output types](/sdk/concepts/outputs): What each service hands back, in the SDK's own shapes.

```python
{
    "model": "gemini-3.5-flash",
    "service": "text-to-text",
    "provider": "gemini",
    "unit": "1M tokens",
    "credits": None,              # a flat price, when the unit has one
    "creditsInput": 375,
    "creditsOutput": 2250,
    "creditsOutputVideo": None,
    "videoOutputTokens": None,
    "resolution": None,
    "audio": None,
    "deprecatedAfter": None,
    "contextWindow": 1048576,     # token-billed rows only
    "maxOutput": 65536,
    "cachedInputRate": 0.25,
}
```

```python
grid = api.catalogue()

cheapest = min(
    (row for row in grid if row["service"] == "text-to-text" and not row["deprecatedAfter"]),
    key=lambda row: row["creditsInput"],
)

cheapest["model"]       # what to pass as model=
cheapest["maxOutput"]   # the ceiling to stay under
```

```python
import math

def estimate_credits(row, input_tokens, output_tokens):
    if row["unit"] != "1M tokens":
        raise ValueError(f"not a token row: {row['unit']}")
    return (math.ceil(input_tokens / 1_000_000 * row["creditsInput"])
            + math.ceil(output_tokens / 1_000_000 * row["creditsOutput"]))

# What the same input costs once the provider is serving it from cache
def cached_input(row, tokens):
    return math.ceil(tokens / 1_000_000 * row["creditsInput"] * row["cachedInputRate"])
```

```python
def video_cost(grid, model, *, resolution, audio, seconds):
    row = next((r for r in grid
                if r["model"] == model and r["service"] == "text-to-video"
                and r["resolution"] == resolution and r["audio"] == audio), None)
    if row is None:
        raise ValueError("no row for that combination")
    return row["credits"] * seconds
```

```python
grid = api.catalogue()

by_model = {}
for row in grid:
    entry = by_model.setdefault(row["model"], {"model": row["model"], "services": set(), "rows": []})
    entry["services"].add(row["service"])
    entry["rows"].append(row)

# What one model can do, and what it costs to think with
for entry in by_model.values():
    tokens = next((r for r in entry["rows"] if r["unit"] == "1M tokens"), None)
    print(
        entry["model"],
        " · ".join(sorted(entry["services"])),
        f"{tokens['creditsInput']} in / {tokens['creditsOutput']} out" if tokens else "",
        (tokens or {}).get("contextWindow") or "",
    )
```

```python
grid = api.catalogue()
leaving = [row for row in grid if row["deprecatedAfter"]]

for row in leaving:
    print(f"{row['model']} ({row['service']}) stops being served after {row['deprecatedAfter']}")

# And guard the one you depend on
mine = next((r for r in grid if r["model"] == MODEL and r["service"] == "text-to-text"), None)
if mine is None:
    raise RuntimeError(f"{MODEL} is no longer in the catalogue")
```

```python
import time

_grid = None
_read_at = 0.0

def catalogue(api, max_age=3600):
    global _grid, _read_at
    if _grid is None or time.monotonic() - _read_at > max_age:
        fresh = api.catalogue()
        if fresh:                       # keep the last good one
            _grid, _read_at = fresh, time.monotonic()
    if _grid is None:
        raise RuntimeError("no catalogue available")
    return _grid
```
