Client

catalogue()

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.

GET /api/ai/pricesfreethe billing grid itself
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

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

{
  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
}
{
    "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,
}

The fields

modelstring

The name you pass as model everywhere else.

servicestring

What this row prices. One model appears once per service it serves.

providerstring

Which family serves it. Informational: you ask for a model, never for a provider.

unitstring

What is counted. It decides which credit field applies — see Units.

creditsinteger|null

The flat price of one unit. null on token-billed rows.

creditsInput · creditsOutputinteger|null

Per million tokens, each direction counted and rounded up on its own.

creditsOutputVideo · videoOutputTokensinteger|null

For a model that can answer with video: that output's rate, and its fixed token count.

resolutionstring|null

What distinguishes two rows of one model — an image size, a video definition.

audioboolean|null

Whether this row is the one with sound. A video with sound is a different price.

contextWindowinteger|null

Tokens the model accepts in one turn. Token-billed rows only.

maxOutputinteger|null

The output ceiling the provider accepts. Asking for more is refused.

cachedInputRatenumber|null

The share of the input rate paid for a token served from the provider's cache.

deprecatedAfterstring|null

A date after which this row stops being served. Non-null is your notice to migrate.

Units, and which field to read

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.

unitReadCounted as
1M tokenscreditsInput · creditsOutputPer million, each direction rounded up separately.
imagecreditsOne image, at that row's resolution.
secondcreditsOne second of video, at that definition and sound.
1K characterscreditsPer thousand characters of text spoken.
minutecreditsPer minute of audio read.
songcreditsOne track.
callcreditsOne 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

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.

serviceTakesGives back
text-to-textTextText
text-to-jsonText, plus a schemaAn object matching the schema
multimodal-to-textText with images, audio, video or documentsText
omniMixed inputMixed output, text and media from one model
text-to-imageText, optionally a starting pictureAn image
text-to-videoText, optionally a starting pictureA video
text-to-speechTextAudio
speech-to-textAudioText
text-to-musicTextA track
text-to-embeddingTextA vector
text-rerankingA query and documentsThe documents, reordered

How much comes back

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

Pick the cheapest model that can answer in text

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
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

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.

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);
}
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"])

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.

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;
}
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
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

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 ?? "",
  );
}
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 "",
    )

Watch for a model leaving

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

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`);
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")

How often to read it

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.

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;
}
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
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

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.