feat: add model-specific cache pricing - #45
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for model-specific prompt-cache pricing metadata to the docs site’s model pipeline, and surfaces a calculated cache-read price (per 1M input tokens) in both the models catalog page and individual model pages when the required realtime tariff + cache metadata are present.
Changes:
- Extend model normalization (
transformModels) to parsecache_pricinginto a typedcachePricingfield. - Compute and expose
cacheReadPricePer1M(+ multiplier) in generated model artifacts, and render it in the models index table + model detail markdown. - Update copy in the models index markdown to remove the blanket “~10%” cache discount claim in favor of model-specific guidance.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/lib/models.ts | Adds ModelCachePricing, parses cache_pricing from the admin models response, and exports transformModels for direct testing. |
| src/lib/models.test.ts | Adds focused tests covering cache pricing normalization (enabled/disabled/absent). |
| src/lib/model-artifacts.ts | Calculates cache-read pricing when metadata + realtime pricing exist, renders it in the index table and model markdown, and factors out renderModelsIndexMarkdown for testing. |
| src/lib/model-artifacts.test.ts | Adds tests ensuring cache-read pricing is only computed when appropriate and is rendered (or omitted) correctly in markdown outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Impact
Customers can see the current cache-read price per 1M input tokens for each supported model. Unsupported models display an unavailable marker, and model detail pages only show cache pricing when the required metadata and realtime tariff are present.
Validation
npm run test:run -- src/lib/models.test.ts src/lib/model-artifacts.test.ts(10 tests pass)npm run buildgit diff --checkThe full test suite retains one unrelated existing failure in
src/lib/search.test.ts(stripMarkdownremoves inline code instead of preserving its text).