Skip to content

Add pricing for GPT-5.4 nano and GPT-4.5#144

Merged
mike1858 merged 1 commit intomainfrom
feat/add-gpt-5-4-nano-gpt-4-5-and-gpt-5-1-pricing
Apr 20, 2026
Merged

Add pricing for GPT-5.4 nano and GPT-4.5#144
mike1858 merged 1 commit intomainfrom
feat/add-gpt-5-4-nano-gpt-4-5-and-gpt-5-1-pricing

Conversation

@mike1858
Copy link
Copy Markdown
Member

@mike1858 mike1858 commented Apr 19, 2026

Summary

  • add pricing for gpt-5.4-nano with cached input support
  • add pricing for gpt-4.5, including cached input pricing
  • add regression tests covering requested gpt-5.1, gpt-5.4-nano, and gpt-4.5 pricing

Verification

  • cargo fmt --all --quiet
  • cargo build --quiet
  • cargo test --quiet
  • cargo clippy --quiet -- -D warnings
  • cargo doc --quiet

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for two new models: gpt-4.5 and gpt-5.4-nano. Both include input/output pricing and support for cached token pricing.
  • Tests

    • Extended test suite with unit tests to verify new model availability, pricing accuracy, and cost calculations across various token scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: acdf1b30-4ba1-44fe-a5f7-722e5fbb39c1

📥 Commits

Reviewing files that changed from the base of the PR and between d16f884 and 6e01842.

📒 Files selected for processing (1)
  • src/models.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/models.rs

📝 Walkthrough

Walkthrough

This PR adds pricing configurations for two new language models (gpt-4.5 and gpt-5.4-nano) to the static model registry, including caching support settings. It updates the model aliases map for canonical name resolution and adds unit tests validating cost calculations for both new models across input, output, and cache scenarios.

Changes

Cohort / File(s) Summary
Model Pricing Registry
src/models.rs (MODEL_INDEX)
Added pricing entries for gpt-4.5 (flat rate pricing, no caching) and gpt-5.4-nano (flat rate pricing with OpenAI-style cached input support).
Model Aliases
src/models.rs (MODEL_ALIASES)
Added canonical name mappings for gpt-4.5 and gpt-5.4-nano to enable proper model lookup resolution.
Test Coverage
src/models.rs (test functions)
Added unit tests verifying model discovery via get_model_info and cost calculations (calculate_input_cost, calculate_output_cost, calculate_cache_cost) for both new models against 1,000,000-token scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • bl-ue

Poem

🐰 Hop, hop — new models hop into the light,
Tokens counted by day and through the night,
Nano zips in, 4.5 hums along,
Cache and cost sing out a tidy song,
I nibble carrots and cheer: models right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding pricing support for two new models (GPT-5.4 nano and GPT-4.5), which is exactly what the changeset accomplishes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-gpt-5-4-nano-gpt-4-5-and-gpt-5-1-pricing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/models.rs (1)

1021-1021: Consider adding dated aliases for consistency.

Every other OpenAI model in MODEL_ALIASES has at least one date-suffixed alias (e.g. gpt-5.4-mini-2026-03-17gpt-5.4-mini, gpt-4.1-2025-04-14gpt-4.1). The new gpt-4.5 and gpt-5.4-nano entries only register the bare canonical name, so any dated variant reported by the API (e.g. gpt-4.5-preview-2025-02-27) will miss the lookup and fall through to the $0 warning path. Add the corresponding dated aliases if you expect those IDs to appear in usage data.

Also applies to: 1137-1137

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/models.rs` at line 1021, The MODEL_ALIASES map is missing date-suffixed
aliases for the new entries (so dated IDs like "gpt-4.5-preview-2025-02-27"
won't match); update the MODEL_ALIASES definition to include the corresponding
dated aliases for "gpt-4.5" and "gpt-5.4-nano" using the same pattern used
elsewhere (add the expected date-prefixed/preview variants mapping to the
canonical names), e.g. add entries that map common dated forms such as
"gpt-4.5-<date or preview-suffix>" -> "gpt-4.5" and similar for "gpt-5.4-nano"
so lookups in MODEL_ALIASES succeed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/models.rs`:
- Around line 235-242: The ModelInfo entry for the "gpt-4.5" variant currently
uses CachingSupport::None which causes calculate_cache_cost to return $0 for
cached input; update the "gpt-4.5" ModelInfo to use CachingSupport::OpenAI {
cached_input_per_1m: 37.5 } so cached prompt tokens are billed correctly (or, if
caching is intentionally ignored, add a clear comment on the ModelInfo for
"gpt-4.5" explaining why CachingSupport::None is used). Ensure you edit the
ModelInfo mapping where "gpt-4.5" is defined and adjust tests/fixtures that
expect cache charges if present.

---

Nitpick comments:
In `@src/models.rs`:
- Line 1021: The MODEL_ALIASES map is missing date-suffixed aliases for the new
entries (so dated IDs like "gpt-4.5-preview-2025-02-27" won't match); update the
MODEL_ALIASES definition to include the corresponding dated aliases for
"gpt-4.5" and "gpt-5.4-nano" using the same pattern used elsewhere (add the
expected date-prefixed/preview variants mapping to the canonical names), e.g.
add entries that map common dated forms such as "gpt-4.5-<date or
preview-suffix>" -> "gpt-4.5" and similar for "gpt-5.4-nano" so lookups in
MODEL_ALIASES succeed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fc756171-92b5-43a8-85c5-570a827855dd

📥 Commits

Reviewing files that changed from the base of the PR and between 9bf4659 and d16f884.

📒 Files selected for processing (1)
  • src/models.rs

Comment thread src/models.rs
Add GPT-5.4 nano and GPT-4.5 pricing entries plus regression tests covering the requested GPT-5.1 pricing.
@mike1858 mike1858 force-pushed the feat/add-gpt-5-4-nano-gpt-4-5-and-gpt-5-1-pricing branch from 28f55c9 to 6e01842 Compare April 20, 2026 02:14
@mike1858 mike1858 merged commit 43eacfe into main Apr 20, 2026
6 checks passed
@mike1858 mike1858 deleted the feat/add-gpt-5-4-nano-gpt-4-5-and-gpt-5-1-pricing branch April 20, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant