Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/rotator_library/provider_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,16 @@ def _load_api_bases(self) -> None:
f"Detected API base override for {provider}: {value}"
)

# Handle firmware provider: has default api_base but LiteLLM doesn't
# recognize it as a native provider. Without this, FIRMWARE_API_KEY_*
# users without explicit FIRMWARE_API_BASE would have requests fail.
if "firmware" not in self._api_bases and "firmware" not in KNOWN_PROVIDERS:
self._api_bases["firmware"] = "https://app.firmware.ai/api/v1"
self._custom_providers.add("firmware")
lib_logger.info(
"Using default api_base for firmware: https://app.firmware.ai/api/v1"
)

def is_known_provider(self, provider: str) -> bool:
"""Check if provider is known to LiteLLM."""
return provider.lower() in KNOWN_PROVIDERS
Expand Down
10 changes: 10 additions & 0 deletions src/rotator_library/providers/firmware_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@
class FirmwareProvider(FirmwareQuotaTracker, ProviderInterface):
"""
Provider implementation for the Firmware.ai API with quota tracking.

Firmware.ai is OpenAI-compatible, so requests are routed through LiteLLM's
OpenAI provider with api_base override. This class provides:
- Quota tracking via the FirmwareQuotaTracker mixin
- Model discovery from Firmware.ai's /models endpoint
- Cost calculation is skipped since Firmware models aren't in LiteLLM's pricing DB
"""

# Skip LiteLLM cost calculation - Firmware.ai models use custom naming
# (e.g., firmware/anthropic/claude-sonnet-4-5) not in LiteLLM's pricing database
skip_cost_calculation: bool = True

# Quota groups for tracking 5-hour rolling window limits
# Uses a virtual model "firmware/_quota" for credential-level quota tracking
model_quota_groups = {
Expand Down