Update LLM pricing in the local repo
This skill is
not a second API spec — it describes
what you can implement using the
listing API that
documents (
GET https://www.narev.ai/api/models/pricing
): paginate, map each row to
your schema, and write a committed file. For path/query/body contracts,
/
, and
calculate, use
. You do
not need the Narev SDK or Vercel AI SDK — any HTTP client and file I/O in the repo's language is enough.
When to use this skill
- "Update LLM model price snapshot present in your project"
- "Refresh committed pricing registry with the latest rates (find where the project stores rates, or add a file or script if nothing exists yet)."
If the user only needs
how the API works or
cost for one call (
calculate), point them at
.
Inputs you need
The Narev pricing API is public. No API key or bearer token is required.
- Target file path and format (TypeScript object, JSON, YAML, Python module, etc.). Confirm before overwriting.
- Scope: which values to refresh (API slugs), or the full catalog. Use the query parameter; omit it to fetch everything (paginate until ).
- Local units: the API returns USD per token. Some codebases store USD per million tokens — multiply by only when writing that shape, and document it in the script.
API response shape (what you read)
Paginate with
,
(max
), and optional
,
,
,
. Response:
{ data: ModelPricingEntry[], meta: { total_pages, ... } }
.
Each row has
,
,
, and
. When
is
, skip the row (enterprise-only or unavailable).
Useful
fields (snake_case, USD per unit unless noted):
| Field | Meaning |
|---|
| Input token |
| Output token |
| / | Cached input tokens |
| Reasoning tokens |
| Flat per request |
| Per web-search invocation |
| Fraction –, not a percent |
,
,
, etc. may appear — carry them through only if your local registry supports them.
Mapping to your registry (default path)
-
Inspect the repo: find the existing pricing map or config and match
key style (
only vs
),
units (per token vs per 1M tokens), and
which fields the app reads.
-
Implement a script in the project's language (
scripts/update-pricing.ts
,
scripts/update_pricing.py
, etc.) that:
- Loops pages until done.
- Optionally filters by one or more query values per run (or omit for full catalog).
- Merges or replaces according to product needs: common pattern is merge — keep unrelated providers in file, overwrite keys returned by this fetch.
- Writes a generated-file banner when the format allows.
- Exits non-zero on HTTP errors so CI can fail visibly.
-
Document the run command in a comment or README snippet (
,
uv run python scripts/...
, etc.).
Reference pattern: merge into an existing TS registry (strip + regenerate block)
Repos like Mission Control sometimes keep
in TypeScript with
/
. Adapt paths and regex to the real file:
- Fetch with repeated per catalog you care about, or no for full catalog.
- Convert API per-token rates to per-million:
inputPerMTok = price_prompt * 1_000_000
, same for completion.
- Key both and if the app resolves either style.
- Parse the existing block, merge new rows into the dict, sort keys if you want stable diffs, replace the block with , write the file.
This is illustrative — match the project's exact types and formatting.
Reference pattern: offline resolver (optional)
If the user
already uses the Narev SDK,
createObjectPriceResolver
expects
in USD per token (do not multiply to per-million for the SDK map). Map API → SDK like this:
Output
Record<string, ModelPricing>
keyed by how the app resolves models (see multi-provider note below). Then:
ts
import { createObjectPriceResolver } from "@ai-billing/core";
import { pricing } from "./pricing";
export const priceResolver = createObjectPriceResolver(pricing);
Workflow (agent checklist)
1. Confirm scope and target file
Providers, model subset (if any), output path, and whether units are per token or per 1M in the file.
2. Add or update a snapshot script
Use the repo's language and dependencies (
/
/
/
). Paginate
GET https://www.narev.ai/api/models/pricing
. Transform into the local schema. Prefer idempotent writes and small, reviewable diffs.
3. Run it
Use the project's package runner. Do not assume
or
— check
,
, etc. Inspect the diff before committing.
4. Wire into the app (only if applicable)
For custom registries, point the app at the updated file or import. For
, swap
for
createObjectPriceResolver
as above.
5. Schedule refreshes (optional)
CI on a schedule that runs the script and opens a PR keeps rates fresh with human review.
Constraints and edge cases
- Multi-provider models share a . If you need per-provider rates, key with (and align lookup). Otherwise last write wins for bare .
- Skip .
- is a fraction ( = 10% off). Pass through if your registry supports it; many simple token maps ignore it.
- API = USD per token. Scale to per-1M (or per-1K) only in your script when the destination format requires it — do not double-scale.
- Snapshot drift. Re-run before releases that depend on accurate math.
- Generated files. Banner comment + formatter ignore if needed.
Reference
- List pricing API:
/platform/api-reference/endpoint/pricing/list-model-pricing
- SDK overview (optional):
createObjectPriceResolver
: /sdk/ai-billing/reference/core/typedoc/functions/createObjectPriceResolver
- (live):
/sdk/ai-billing/reference/core/typedoc/functions/createNarevPriceResolver
- :
/sdk/ai-billing/reference/core/typedoc/interfaces/ModelPricing