Fetching models pricing

From Menci/Floway · View interactive version

Fetching models pricing is an AI agent skill from the GitHub repository Menci/Floway. Refresh provider model pricing for Floway, including API-equivalent subscription valuation and Ollama official standard rates. Manual research procedure; no script.

How to use this skill

Skill file

Fetching Models Pricing

Maintain the per-token rate cards in:

| Provider | Table | Live catalog | Preferred rate source |

|---|---|---|---|

| Copilot | packages/provider-copilot/src/pricing.ts | Copilot /models | model vendor's first-party API |

| ChatGPT | packages/provider-chatgpt/src/pricing.ts | authenticated /codex/models | OpenAI API pricing |

| Claude Code | packages/provider-claude-code/src/pricing.ts | authenticated Anthropic /v1/models | Anthropic API pricing |

| Kimi Code | packages/provider-kimi-code/src/pricing.ts | Kimi Code /models | Moonshot API pricing |

| Ollama | packages/provider-ollama/src/pricing.ts | /api/tags + /api/show | Ollama official standard rates; vendor/host valuation for other models |

Copilot, ChatGPT, Claude Code and Kimi Code use API-equivalent valuation. Ollama uses its

published standard token rates for covered models and retains vendor/host

valuation for other models. These are request estimates; account consumption

from /api/usage includes Ollama billing adjustments such as off-peak discounts.

ModelPricing.entries[].rates stores decimal-string USD prices per one base

BillingMetric unit. The ten-member BILLING_METRICS array in

packages/protocols/src/common/pricing.ts owns the complete metric domain, and

BillingMetric is derived from it. Read the array rather than copying its

members into this procedure; each provider table may price only the defensible

subset for a model.

Procedure

  1. Fetch the provider's live catalog and diff its ids against the table's

string and RegExp keys. Record new, retired, and renamed models.

  1. Find a defensible rate source for every new id:

host that publishes the required metrics.

version was current.

  1. Cross-check at least two sources. models.dev remains useful as an independent

comparison under its external cost field:

```bash

curl -s https://models.dev/api.json | jq '.<provider>.models["<id>"].cost'

```

OpenRouter prices below first-party rates are usually mirror-host prices,

not the canonical vendor rate.

  1. Author pricing with the token-rate conversion helpers and decimal strings:

```ts

import {

modelPricing,

tokenBasePricing,

tokenPricingEntry,

type PriceVector,

} from '@floway-dev/protocols/common';

const EXAMPLE_BASE_RATES = {

input_tokens: '1',

input_cache_read_tokens: '0.1',

output_tokens: '10',

} satisfies PriceVector;

const EXAMPLE_PRIORITY_RATES = {

input_tokens: '2',

input_cache_read_tokens: '0.2',

output_tokens: '20',

} satisfies PriceVector;

export const BASE_ONLY_PRICING = tokenBasePricing(EXAMPLE_BASE_RATES);

export const TIERED_PRICING = modelPricing(

tokenPricingEntry(EXAMPLE_BASE_RATES),

tokenPricingEntry(EXAMPLE_PRIORITY_RATES, { serviceTier: 'priority' }),

);

```

The numbers above are placeholders. Published token rate cards are normally

USD per million tokens. tokenPricingEntry and tokenBasePricing apply the

existing perMillionTokenRates conversion, so their resulting PriceVector

values are USD per base token. Do not divide manually or pass number literals.

Follow packages/provider-chatgpt/src/pricing.ts for a complete production

example instead of copying a rate vector into this skill.

collectModelPricingIssues in

packages/protocols/src/common/pricing.ts enforces the structural invariants

below, including Base count, matching rate metrics, selector uniqueness, and

threshold-operator consistency. The source-quality rules still require

human judgment.

metric. A metric absent from Base is unpriced everywhere.

marginal token buckets.

coordinates apply only inside that exact scope. Runtime selects the

highest matching global or scoped threshold, then performs one exact rate

lookup.

undocumented Cartesian combination.

adjacent version or similarly named model.

  1. Increment MODEL_CATALOG_REVISION in

packages/gateway/src/repo/models-cache-contract.ts. Static pricing

is serialized inside cached ProviderModel rows; a mismatch makes every

older row cold before TTL evaluation.

  1. Add boundary tests for exact ids, aliases, dated releases, RegExp coverage,

threshold edges, Base fallback, and the per-base-unit result through

priceRequest.

  1. Run the affected provider tests, their typecheck, and lint over the changed files.

CI owns the complete suite.

  1. If an existing rate changed, use $backfill-usage-pricing for the intended

historical usage slice. Catalog revisioning changes future snapshots; it

does not rewrite recorded unit_price values.

Catalog Revision Policy

MODEL_CATALOG_REVISION versions the complete persisted ProviderModel

contract, not only pricing tables. Increment it for any code change that alters

code-derived catalog metadata or its serialized representation. Upstream-only

catalog changes do not require a bump because normal TTL refreshes fetch them.

The revision is global by design. A mismatch blocks on a fresh fetch and never

falls back to the incompatible stored row. Successful fetches overwrite the row

with the current revision; failed fetches leave the old row present but

ineligible.

Provider Identity

-1m in model_key. Its pricing table is keyed by the public id that survives

variant merging: catalog projection merges the raw variants first, and

pricingForCopilotPublicModelId is a plain table match over anchored keys that

normalizes nothing itself.

aliases are merged into public ids.

kimi-for-coding channel and -highspeed sibling name different model versions.

Source Cautions

market prices.

mode from /api/balance, not the tier name. Its inference APIs report cached

token counts; keep their normal protocol accounting. Standard-rate estimates

do not infer peak/off-peak billing from a response service tier.

model; that is another host's price.

document non-obvious source choices next to the table entry.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.