mirror of
https://github.com/block/buzz.git
synced 2026-11-25 10:42:26 +00:00
feat(models): Phase 3 — pricing axis to D2' (authority, model) exact-lookup contract
Replaces lookup_pricing(raw_model_id) + normalize_for_pricing + 17 prefix rules
with an exact (billing-authority domain, billable-model-string) lookup. Billing
authority is a distinct namespace from the runtime transport Provider enum.
Match is exact: no case normalization, no prefix matching, no inference.
Manifest (scripts/model-capabilities.json):
- Removed pricing_rules (17 prefix-match rules), pricing_exact_records (3 records)
- Added flat pricing_records list of 20 exact records, each with authority + model +
usd_per_mtok (input/output/cache_read/cache_write) + _source provenance
- Authorities: api.anthropic.com, api.openai.com — registered bare-host tokens per
D2'/NIP-AM; not transport Provider enum values
- Semantics: current list prices (ccusage-aligned); cache_write scoped to ephemeral;
other classes unknown
Generator (scripts/generate-model-capabilities.mjs):
- Removed all old pricing machinery (pricingNormalize, normalizeVersionSeparators,
pricingRules, pricingExactRecords, resolvePricing, all TS rule-resolver emission)
- Strict pricing-record validation: registered authority (closed set: api.anthropic.com,
api.openai.com, openrouter.ai); nonempty verbatim model; no control/NUL/quote/backslash
in key fields; finite nonnegative input/output; both cache_read and cache_write required
(absent member is hard error; use null for unpublished); _source provenance required;
duplicate detection on exact emitted identities
- byAuthority grouping uses exact record values — no toLowerCase() anywhere in
pricing generation path
- REGISTERED_AUTHORITIES set; hasUnsafeKeyChars() guard
- TS PRICING_TABLE: key is ${authority}\0${model} (exact strings, no transforms)
- lookupModelPricing(authority, model) performs exact Map lookup (no normalization)
- modelPricing.ts is standalone (no import from modelCapabilities)
Generated artifacts:
- generated_model_capabilities.rs: lookup_pricing(authority: &str, model: &str)
performs exact match — no to_ascii_lowercase() calls, no fallback
- modelPricing.ts: exact PRICING_TABLE + lookupModelPricing(authority, model)
CI (.github/workflows/ci.yml):
- Replaced two-step "regenerate + git diff" check with a single
node scripts/generate-model-capabilities.mjs --check step, which validates
all three generated artifacts (Rust capabilities, TS capabilities, TS pricing)
and exits 1 if any are stale. Self-maintains if a fourth artifact is added.
Tests (generated_model_capabilities_tests.rs, 23 pricing tests):
- Anthropic models with correct rates (claude-fable-5, claude-opus-5, claude-sonnet-5,
claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5)
- OpenAI models incl. gpt-5.6-luna different tier, gpt-5.5 null cache_write, gpt-5-pro
null cache fields
- Null guards: unknown authority, custom base URL, unknown model, empty authority,
empty model, both empty, wrong authority for known model
- Exact-match guards: uppercase authority -> None, mixed-case authority -> None,
mixed-case model -> None (no case folding)
- Databricks guards: workspace URL authority -> None, 'databricks' authority -> None
Manifest validator tests (scripts/test-manifest-validator.mjs, 45 tests total):
- 21 new pricing-record mutation tests covering: missing authority, unregistered/path-
bearing/scheme authority, empty model, unsafe chars (double-quote, backslash, NUL,
control), missing output, negative rates, invalid cache rate, deleted cache_read,
deleted cache_write, missing/empty provenance, duplicate records, uppercase authority
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
parent
c898da7149
commit
4855d95252
@@ -7,7 +7,8 @@
|
||||
"anthropic_thinking": "https://platform.claude.com/docs/en/build-with-claude/extended-thinking (July 2025)",
|
||||
"anthropic_effort": "https://platform.claude.com/docs/en/build-with-claude/effort (July 2025)",
|
||||
"openai_reasoning": "https://platform.openai.com/docs/guides/reasoning (July 2025)",
|
||||
"goose_known_models": "goose revision 6789d4af (crates/goose-providers/src/databricks_v2.rs:41-42) \u2014 two IDs: databricks-gpt-5-5, databricks-claude-opus-4-7"
|
||||
"goose_known_models": "goose revision 6789d4af (crates/goose-providers/src/databricks_v2.rs:41-42) — two IDs: databricks-gpt-5-5, databricks-claude-opus-4-7",
|
||||
"models_dev_pricing": "https://models.dev/api.json (retrieved 2026-08-03, SHA-256 6fd293aec9fc4274cf2ff1d7bdbe180156b8dde9b80dc9cc0c7e72757931c494) — providers.anthropic and providers.openai cost fields, USD per million tokens"
|
||||
},
|
||||
"family_tokens": [
|
||||
"claude-",
|
||||
@@ -622,7 +623,7 @@
|
||||
"medium",
|
||||
"high"
|
||||
],
|
||||
"source": "models.dev reasoning_options: low|medium|high (family rule adds none+xhigh \u2014 adopt provider-advertised)",
|
||||
"source": "models.dev reasoning_options: low|medium|high (family rule adds none+xhigh — adopt provider-advertised)",
|
||||
"_reconciliation": "adopt",
|
||||
"_reconciliation_note": "models.dev advertises low|medium|high. Family rule (gpt5-4) adds none+xhigh. Provider-advertised wins per plan F1 policy.",
|
||||
"_reconciliation_doc": "https://models.dev/api.json (retrieved 2026-07-31, SHA-256 d5a4974cd69f19b0f67713acaa6bb3b16e920defdc07ecbdf6b0a936181bb0e0): providers.databricks.models[\"databricks-gpt-5-4-mini\"].reasoning_options=[{\"type\":\"effort\",\"values\":[\"low\",\"medium\",\"high\"]}]"
|
||||
@@ -651,7 +652,7 @@
|
||||
"high",
|
||||
"max"
|
||||
],
|
||||
"source": "models.dev reasoning_options: low|medium|high|max (family rule adds none+xhigh \u2014 provider-advertised wins per plan F1)",
|
||||
"source": "models.dev reasoning_options: low|medium|high|max (family rule adds none+xhigh — provider-advertised wins per plan F1)",
|
||||
"_reconciliation": "adopt",
|
||||
"_reconciliation_note": "models.dev advertises [low, medium, high, max]. Family rule (gpt5-6) has none+xhigh+max; sol endpoint does not expose none or xhigh. Provider-advertised wins.",
|
||||
"_reconciliation_doc": "https://models.dev/api.json (retrieved 2026-07-31, SHA-256 d5a4974cd69f19b0f67713acaa6bb3b16e920defdc07ecbdf6b0a936181bb0e0): providers.databricks.models[\"databricks-gpt-5-6-sol\"].reasoning_options=[{\"type\":\"effort\",\"values\":[\"low\",\"medium\",\"high\",\"max\"]}]"
|
||||
@@ -660,7 +661,7 @@
|
||||
"provider": "databricks_v2",
|
||||
"raw_model_id": "databricks-gpt-5-5",
|
||||
"registry_label": "GPT-5.5",
|
||||
"source": "models.dev reasoning_options: low|medium|high (family rule adds none+xhigh \u2014 provider-advertised wins per plan F1)",
|
||||
"source": "models.dev reasoning_options: low|medium|high (family rule adds none+xhigh — provider-advertised wins per plan F1)",
|
||||
"_reconciliation": "adopt",
|
||||
"_reconciliation_note": "models.dev (pinned payload) advertises [low, medium, high]. Family rule (gpt5-5) has none+xhigh; this Databricks endpoint does not expose none or xhigh. Provider-advertised wins.",
|
||||
"supported_efforts_override": [
|
||||
@@ -676,7 +677,7 @@
|
||||
"registry_label": "Claude Opus 4.7",
|
||||
"source": "DATABRICKS_V2_KNOWN_MODELS; family rule anthropic-adaptive-xhigh-opus-4-7 applies",
|
||||
"_reconciliation": "no-effort-divergence",
|
||||
"_reconciliation_note": "models.dev advertises reasoning_options=[{\"type\":\"budget_tokens\",\"min\":1024}]. This is a different capability axis (extended thinking token budget), not an effort-level selector. No effort divergence to reconcile \u2014 efforts for this model come from the anthropic family rule (anthropic-adaptive-xhigh-opus-4-7).",
|
||||
"_reconciliation_note": "models.dev advertises reasoning_options=[{\"type\":\"budget_tokens\",\"min\":1024}]. This is a different capability axis (extended thinking token budget), not an effort-level selector. No effort divergence to reconcile — efforts for this model come from the anthropic family rule (anthropic-adaptive-xhigh-opus-4-7).",
|
||||
"_reconciliation_doc": "https://models.dev/api.json (retrieved 2026-07-31, SHA-256 d5a4974cd69f19b0f67713acaa6bb3b16e920defdc07ecbdf6b0a936181bb0e0): providers.databricks.models[\"databricks-claude-opus-4-7\"].reasoning_options=[{\"type\":\"budget_tokens\",\"min\":1024}]"
|
||||
}
|
||||
],
|
||||
@@ -864,5 +865,230 @@
|
||||
"normalization_policy": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"_comment_pricing": "Pricing manifest: USD per million tokens (usd_per_mtok). Lookup is exact (authority, model) — no prefix inference, no normalization. authority is the canonical billing-authority domain; model is the exact string the provider API returns in its response body. null fields mean the price is not published — never treat as zero. Databricks routes are corporate-internal and are not represented here; the publisher must omit PricingIdentity for those routes. Source: models.dev/api.json (retrieved 2026-08-03, SHA-256 6fd293ae). Semantics: current list prices, labeled estimated at current prices (ccusage-aligned). cache_write prices are scoped to the default ephemeral cache class; other classes/TTLs are not priced here.",
|
||||
"pricing_records": [
|
||||
{
|
||||
"_comment": "Anthropic — authority: api.anthropic.com. model strings are the canonical IDs returned by the Anthropic API.",
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-fable-5",
|
||||
"usd_per_mtok": {
|
||||
"input": 10.0,
|
||||
"output": 50.0,
|
||||
"cache_read": 1.0,
|
||||
"cache_write": 12.5
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-fable-5"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-sonnet-5",
|
||||
"usd_per_mtok": {
|
||||
"input": 2.0,
|
||||
"output": 10.0,
|
||||
"cache_read": 0.2,
|
||||
"cache_write": 2.5
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-sonnet-5"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-opus-5",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 25.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": 6.25
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-opus-5"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-opus-4-8",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 25.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": 6.25
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-opus-4-8"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-opus-4-7",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 25.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": 6.25
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-opus-4-7"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-opus-4-6",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 25.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": 6.25
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-opus-4-6"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-opus-4-5",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 25.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": 6.25
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-opus-4-5"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-sonnet-4-6",
|
||||
"usd_per_mtok": {
|
||||
"input": 3.0,
|
||||
"output": 15.0,
|
||||
"cache_read": 0.3,
|
||||
"cache_write": 3.75
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-sonnet-4-6"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-sonnet-4-5",
|
||||
"usd_per_mtok": {
|
||||
"input": 3.0,
|
||||
"output": 15.0,
|
||||
"cache_read": 0.3,
|
||||
"cache_write": 3.75
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-sonnet-4-5"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-haiku-4-5",
|
||||
"usd_per_mtok": {
|
||||
"input": 1.0,
|
||||
"output": 5.0,
|
||||
"cache_read": 0.1,
|
||||
"cache_write": 1.25
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-haiku-4-5"
|
||||
},
|
||||
{
|
||||
"authority": "api.anthropic.com",
|
||||
"model": "claude-opus-4-1",
|
||||
"usd_per_mtok": {
|
||||
"input": 15.0,
|
||||
"output": 75.0,
|
||||
"cache_read": 1.5,
|
||||
"cache_write": 18.75
|
||||
},
|
||||
"_source": "models.dev anthropic/claude-opus-4-1 (listed as claude-opus-4 legacy tier)"
|
||||
},
|
||||
{
|
||||
"_comment": "OpenAI — authority: api.openai.com. model strings are the canonical IDs returned by the OpenAI API.",
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5-pro",
|
||||
"usd_per_mtok": {
|
||||
"input": 15.0,
|
||||
"output": 120.0,
|
||||
"cache_read": null,
|
||||
"cache_write": null
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5-pro"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5.6",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 30.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": 6.25
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5.6"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5.6-sol",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 30.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": 6.25
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5.6-sol (same price tier as gpt-5.6)"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5.6-luna",
|
||||
"usd_per_mtok": {
|
||||
"input": 0.2,
|
||||
"output": 1.2,
|
||||
"cache_read": 0.02,
|
||||
"cache_write": 0.25
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5.6-luna (different price tier from gpt-5.6-sol/base)"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5.6-terra",
|
||||
"usd_per_mtok": {
|
||||
"input": 2.0,
|
||||
"output": 12.0,
|
||||
"cache_read": 0.2,
|
||||
"cache_write": 2.5
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5.6-terra"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5.5",
|
||||
"usd_per_mtok": {
|
||||
"input": 5.0,
|
||||
"output": 30.0,
|
||||
"cache_read": 0.5,
|
||||
"cache_write": null
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5.5"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5.4",
|
||||
"usd_per_mtok": {
|
||||
"input": 2.5,
|
||||
"output": 15.0,
|
||||
"cache_read": 0.25,
|
||||
"cache_write": null
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5.4"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5.1",
|
||||
"usd_per_mtok": {
|
||||
"input": 1.25,
|
||||
"output": 10.0,
|
||||
"cache_read": 0.125,
|
||||
"cache_write": null
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5.1"
|
||||
},
|
||||
{
|
||||
"authority": "api.openai.com",
|
||||
"model": "gpt-5",
|
||||
"usd_per_mtok": {
|
||||
"input": 1.25,
|
||||
"output": 10.0,
|
||||
"cache_read": 0.125,
|
||||
"cache_write": null
|
||||
},
|
||||
"_source": "models.dev openai/gpt-5"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user