Skip to content

fix(firmware): skip LiteLLM cost calculation for firmware models - #7

Merged
b3nw merged 1 commit into
devfrom
fix/firmware-cost-calculation
Jan 23, 2026
Merged

fix(firmware): skip LiteLLM cost calculation for firmware models#7
b3nw merged 1 commit into
devfrom
fix/firmware-cost-calculation

Conversation

@b3nw

@b3nw b3nw commented Jan 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Skip LiteLLM cost calculation for Firmware.ai models to eliminate log spam and errors
  • Firmware.ai uses custom model naming (firmware/anthropic/claude-sonnet-4-5) not in LiteLLM's pricing database
  • Added skip_cost_calculation = True class attribute to FirmwareProvider
  • Expanded docstring documenting the OpenAI-compatible routing architecture

Problem

Firmware provider was generating noisy logs:

Provider List: https://docs.litellm.ai/docs/providers  (5x per request)
Could not calculate cost for model firmware/anthropic/claude-haiku-4-5: litellm.BadRequestError

Test plan

  • Deploy to llm-proxy container and verify no more "Provider List" spam
  • Verify cost calculation errors are gone from logs
  • Confirm firmware model requests still work correctly

Firmware.ai uses custom model naming (e.g., firmware/anthropic/claude-sonnet-4-5)
that isn't in LiteLLM's pricing database, causing "Provider List" spam and
BadRequestError during cost calculation.

Add skip_cost_calculation=True to FirmwareProvider to prevent these errors.
The provider is OpenAI-compatible and routes through LiteLLM's OpenAI provider
with api_base override, so no custom acompletion() logic is needed.
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @b3nw, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where LiteLLM was generating excessive log spam and errors due to its inability to calculate costs for Firmware.ai models, which utilize a custom naming convention. By explicitly disabling cost calculation for these models, the PR eliminates these noisy logs and improves system stability. Additionally, the FirmwareProvider class documentation has been enhanced to provide a clearer understanding of its functionality and integration approach.

Highlights

  • LiteLLM Cost Calculation: Disabled LiteLLM cost calculation for Firmware.ai models to prevent log spam and errors, as Firmware.ai uses custom model naming not present in LiteLLM's pricing database.
  • Code Change: Introduced skip_cost_calculation = True as a class attribute in FirmwareProvider.
  • Documentation Improvement: Expanded the docstring for FirmwareProvider to clarify its OpenAI-compatible routing architecture, quota tracking, model discovery, and the rationale behind skipping cost calculation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@b3nw

b3nw commented Jan 23, 2026

Copy link
Copy Markdown
Owner Author

Starting review of the Firmware cost calculation fix. I'll verify the skip_cost_calculation pattern aligns with the existing provider architecture.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves an issue with log spam by skipping LiteLLM cost calculations for Firmware.ai models. The introduction of skip_cost_calculation = True in the FirmwareProvider is a direct and correct fix. I appreciate the expanded docstring, which clearly explains the provider's architecture and the rationale for this change. The implementation is clean and well-documented. No issues found.

@b3nw b3nw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Overall Assessment

Clean, focused fix that follows established patterns in the codebase. The skip_cost_calculation attribute is already used by 7+ other providers (nvidia, nanogpt, qwen_code, iflow, gemini_cli, antigravity, openai_compatible) and is properly defined in the base ProviderInterface class.

Verdict: This PR is ready to merge. ✅

(Note: Formal approval unavailable due to token permissions, but this review is positive with no requested changes.)

What's Good

  • Follows existing patterns: The implementation mirrors how other providers handle cost calculation skipping
  • Well-documented: The expanded docstring clearly explains Firmware.ai's OpenAI-compatible architecture and why cost calculation is skipped
  • Minimal risk: This is a simple configuration flag with no behavioral side effects beyond eliminating the log spam

Architectural Feedback

None - the approach is correct. Firmware.ai uses custom model naming (firmware/anthropic/claude-sonnet-4-5) that LiteLLM's pricing database doesn't recognize, making cost calculation both impossible and unnecessary for this provider.

Questions for the Author

None - the implementation is straightforward and well-explained in the PR description.

This review was generated by an AI assistant.

@b3nw
b3nw merged commit 21509a1 into dev Jan 23, 2026
2 of 3 checks passed
@b3nw
b3nw deleted the fix/firmware-cost-calculation branch January 23, 2026 05:15
b3nw added a commit that referenced this pull request Jan 23, 2026
Firmware.ai uses custom model naming (e.g., firmware/anthropic/claude-sonnet-4-5)
that isn't in LiteLLM's pricing database, causing "Provider List" spam and
BadRequestError during cost calculation.

Add skip_cost_calculation=True to FirmwareProvider to prevent these errors.
The provider is OpenAI-compatible and routes through LiteLLM's OpenAI provider
with api_base override, so no custom acompletion() logic is needed.
b3nw added a commit that referenced this pull request Jan 24, 2026
Firmware.ai uses custom model naming (e.g., firmware/anthropic/claude-sonnet-4-5)
that isn't in LiteLLM's pricing database, causing "Provider List" spam and
BadRequestError during cost calculation.

Add skip_cost_calculation=True to FirmwareProvider to prevent these errors.
The provider is OpenAI-compatible and routes through LiteLLM's OpenAI provider
with api_base override, so no custom acompletion() logic is needed.
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