mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix: bill Opper streams from the gateway's usage.cost
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AcQ2QoVJWZaePBLwGDDdpC
This commit is contained in:
parent
30648f2d2e
commit
95bfde26a7
2 changed files with 8 additions and 1 deletions
|
|
@ -54,7 +54,9 @@ FUNCTION_CALL_ATTRIBUTE: Final = "function_call"
|
|||
_SYNC_ITER_EXHAUSTED: Final = object()
|
||||
|
||||
_GCHUNK_FIELDS: Final[frozenset] = frozenset(GChunk.__annotations__)
|
||||
_USAGE_COST_HEADER_PROVIDERS: Final[frozenset[str]] = frozenset({LlmProviders.OPENROUTER.value})
|
||||
_USAGE_COST_HEADER_PROVIDERS: Final[frozenset[str]] = frozenset(
|
||||
{LlmProviders.OPENROUTER.value, LlmProviders.OPPER.value}
|
||||
)
|
||||
|
||||
|
||||
def _next_sync_or_exhausted(it: Any) -> object:
|
||||
|
|
|
|||
|
|
@ -231,6 +231,11 @@ def test_opper_streaming_dispatch_carries_cost(respx_mock, monkeypatch):
|
|||
complete_response = litellm.stream_chunk_builder(response.chunks, messages=[{"role": "user", "content": "Hello"}])
|
||||
assert complete_response.usage.cost == 3.3e-05
|
||||
|
||||
from litellm.litellm_core_utils.streaming_handler import CustomStreamWrapper
|
||||
|
||||
CustomStreamWrapper._propagate_usage_cost_to_hidden_params(complete_response, "opper")
|
||||
assert complete_response._hidden_params["additional_headers"]["llm_provider-x-litellm-response-cost"] == 3.3e-05
|
||||
|
||||
|
||||
@pytest.mark.respx()
|
||||
def test_opper_reasoning_effort_passes_through(respx_mock, monkeypatch):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue