Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(cost): add BridgeCostParityTestCase with a gpt-6-sol /v1/messages to Responses pair (#46130)

devin-ai-integration[bot]ff0c6e0a5143
diff --git a/tests/integration/cost_calculation/assertions.py b/tests/integration/cost_calculation/assertions.py
index 58a0fe99aab..bf5985a409d 100644
--- a/tests/integration/cost_calculation/assertions.py
+++ b/tests/integration/cost_calculation/assertions.py
@@ -62,20 +62,25 @@ def assert_breakdown(
assert (header is None and omitted_component_allowed) or (
header is not None and approx_equal(float(header), expected_component)
), f"{case_name}: {header_name} {header} != expected {expected_component}"
- if response is not None and expected.cost_header and response_content_type == "application/json" and any(
- component is not None
- for component in (
- expected.cache_read_cost,
- expected.cache_creation_cost,
- expected.reasoning_cost,
- expected.tool_usage_cost,
+ if (
+ response is not None
+ and expected.cost_header
+ and response_content_type == "application/json"
+ and any(
+ component is not None
+ for component in (
+ expected.cache_read_cost,
+ expected.cache_creation_cost,
+ expected.reasoning_cost,
+ expected.tool_usage_cost,
+ )
)
):
input_header: str | None = response.headers.get("x-litellm-response-cost-input")
output_header: str | None = response.headers.get("x-litellm-response-cost-output")
- expected_input_header: float = expected.input_cost - (
- expected.cache_read_cost or 0.0
- ) - (expected.cache_creation_cost or 0.0)
+ expected_input_header: float = (
+ expected.input_cost - (expected.cache_read_cost or 0.0) - (expected.cache_creation_cost or 0.0)
+ )
assert input_header is not None and approx_equal(float(input_header), expected_input_header), (
f"{case_name}: x-litellm-response-cost-input {input_header} != expected {expected_input_header}"
)
diff --git a/tests/integration/cost_calculation/bridge_cost_parity/__init__.py b/tests/integration/cost_calculation/bridge_cost_parity/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/integration/cost_calculation/bridge_cost_parity/case.py b/tests/integration/cost_calculation/bridge_cost_parity/case.py
new file mode 100644
index 00000000000..a3970a156a7
--- /dev/null
+++ b/tests/integration/cost_calculation/bridge_cost_parity/case.py
@@ -0,0 +1,63 @@
+from dataclasses import dataclass
+from typing import Final
+
+from integration.cost_calculation.cost_tracking_case import CostTrackingTestCase, ExactExpected
+
+ROW_FIELDS: Final = frozenset({"spend", "prompt_tokens", "completion_tokens"})
+_EXPECTED_FIELDS: Final = frozenset(ExactExpected.model_fields)
+
+
+@dataclass(frozen=True, slots=True, kw_only=True)
+class ProviderCostQuirk:
+ """A provider-level reason the bridged leg legitimately bills a different row: the `ExactExpected` fields that
+ differ, why, and the provider document that says so."""
+
+ fields: frozenset[str]
+ reason: str
+ source: str
+
+ def __post_init__(self) -> None:
+ unknown: Final = self.fields - _EXPECTED_FIELDS
+ if not self.fields or unknown:
+ raise ValueError(f"quirk fields must be non-empty ExactExpected fields, got {sorted(unknown)}")
+ if not self.source.startswith("https://"):
+ raise ValueError("a quirk cites the provider document that explains it")
+
+
+@dataclass(frozen=True, slots=True, kw_only=True)
+class BridgeCostParityTestCase:
+ """One stored provider response billed through the provider's own API (`native`) and through a client API that
+ LiteLLM bridges into it (`bridged`). Both legs bill the one row unless `quirk` names the fields that differ."""
+
+ native: CostTrackingTestCase
+ bridged: CostTrackingTestCase
+ quirk: ProviderCostQuirk | None = None
+
+ def __post_init__(self) -> None:
+ if self.native.endpoint == self.bridged.endpoint:
+ raise ValueError(f"{self.id}: native and bridged cases must use different client endpoints")
+ if self.native.response != self.bridged.response:
+ raise ValueError(f"{self.id}: native and bridged cases must share one stored provider response")
+ if (self.native.model, self.native.deployment) != (self.bridged.model, self.bridged.deployment):
+ raise ValueError(f"{self.id}: native and bridged cases must share model and deployment")
+ if not isinstance(self.native.expected, ExactExpected) or not isinstance(self.bridged.expected, ExactExpected):
+ raise ValueError(f"{self.id}: both legs need an ExactExpected row")
+ native: Final = self.native.expected.model_dump()
+ bridged: Final = self.bridged.expected.model_dump()
+ differing: Final = frozenset(field for field in _EXPECTED_FIELDS if native[field] != bridged[field])
+ if differing != self.quirk_fields:
+ raise ValueError(
+ f"{self.id}: expected rows differ in {sorted(differing)} but the quirk covers {sorted(self.quirk_fields)}"
+ )
+
+ @property
+ def quirk_fields(self) -> frozenset[str]:
+ return self.quirk.fields if self.quirk is not None else frozenset()
+
+ @property
+ def compared_row_fields(self) -> frozenset[str]:
+ return ROW_FIELDS - self.quirk_fields
+
+ @property
+ def id(self) -> str:
+ return self.bridged.name
diff --git a/tests/integration/cost_calculation/bridge_cost_parity/runner.py b/tests/integration/cost_calculation/bridge_cost_parity/runner.py
new file mode 100644
index 00000000000..5300913534b
--- /dev/null
+++ b/tests/integration/cost_calculation/bridge_cost_parity/runner.py
@@ -0,0 +1,12 @@
+from typing import Final
+
+from integration._support.client import Gateway
+from integration.cost_calculation.bridge_cost_parity.case import BridgeCostParityTestCase
+from integration.cost_calculation.stream_parity.runner import bill_legs
+
+
+def assert_bridge_cost_parity(case: BridgeCostParityTestCase, gateway: Gateway) -> None:
+ billed: Final = bill_legs(case.id, (case.native, case.bridged), gateway)
+ native: Final = billed[case.native.name].model_dump(include=set(case.compared_row_fields))
+ bridged: Final = billed[case.bridged.name].model_dump(include=set(case.compared_row_fields))
+ assert bridged == native, (case.id, billed[case.native.name], billed[case.bridged.name])
diff --git a/tests/integration/cost_calculation/bridge_cost_parity/test_basic.py b/tests/integration/cost_calculation/bridge_cost_parity/test_basic.py
new file mode 100644
index 00000000000..9f0ca44636d
--- /dev/null
+++ b/tests/integration/cost_calculation/bridge_cost_parity/test_basic.py
@@ -0,0 +1,21 @@
+"""A request through a bridged client API bills exactly what the provider's native API bills for the same response.
+
+A bridge translates one API into another before the provider call and translates the provider's usage back after it
+(LIT-7730, LIT-9098). Each case is one stored provider response sent twice through the same key, once through the
+provider's own API and once through a client API LiteLLM bridges into it. Both LiteLLM_SpendLogs rows must bill the
+case's row, and they must agree with each other except where a documented provider quirk says otherwise.
+"""
+
+import pytest
+from integration._support.client import Gateway
+from integration.cost_calculation.bridge_cost_parity.case import BridgeCostParityTestCase
+from integration.cost_calculation.bridge_cost_parity.runner import assert_bridge_cost_parity
+from integration.cost_calculation.catalog import BRIDGE_COST_PARITY_CASES
+
+
[email protected]("case", BRIDGE_COST_PARITY_CASES, ids=[case.id for case in BRIDGE_COST_PARITY_CASES])
+def test_bridged_request_bills_the_same_row_as_the_native_request(
+ case: BridgeCostParityTestCase, gateway: Gateway
+) -> None:
+ assert_bridge_cost_parity(case, gateway)
diff --git a/tests/integration/cost_calculation/cases/anthropic.py b/tests/integration/cost_calculation/cases/anthropic.py
index c0d10c274bb..1ea9cb44868 100644
--- a/tests/integration/cost_calculation/cases/anthropic.py
+++ b/tests/integration/cost_calculation/cases/anthropic.py
@@ -7,6 +7,8 @@ from typing import Final
from integration.cost_calculation.cost_tracking_case import (
CostTrackingTestCase,
ExactExpected,
+ FailureDetails,
+ FailureExpected,
JsonResponse,
RecountExpected,
RecountRates,
@@ -5823,6 +5825,837 @@ CLAUDE_OPUS_5_5_MESSAGES_INPUT_TEXT: Final = CostTrackingTestCase(
),
)
+CLAUDE_SONNET_5_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="claude-sonnet-5-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-sonnet-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "545ca20285d9 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-sonnet-5-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "tool_use",
+ "id": "toolu_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "caller": {"type": "direct"},
+ }
+ ],
+ "container": None,
+ "stop_reason": "tool_use",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1840,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.01287, input_cost=0.006072, output_cost=0.006798, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+CLAUDE_SONNET_5_5_THINKING: Final = CostTrackingTestCase(
+ name="claude-sonnet-5-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-sonnet-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "87d4acad824b summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-sonnet-5-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [{"type": "text", "text": "scripted answer 87d4acad824b"}],
+ "container": None,
+ "stop_reason": "end_turn",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1240,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.01089, input_cost=0.004092, output_cost=0.006798, prompt_tokens=1240, completion_tokens=412
+ ),
+)
+
+CLAUDE_HAIKU_5_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="claude-haiku-5-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-haiku-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "69e58cd95315 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-haiku-5-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "tool_use",
+ "id": "toolu_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "caller": {"type": "direct"},
+ }
+ ],
+ "container": None,
+ "stop_reason": "tool_use",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1840,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00429, input_cost=0.002024, output_cost=0.002266, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+CLAUDE_HAIKU_5_5_THINKING: Final = CostTrackingTestCase(
+ name="claude-haiku-5-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-haiku-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "eadef5247ccc summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-haiku-5-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "thinking",
+ "thinking": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ },
+ {"type": "text", "text": "scripted answer eadef5247ccc"},
+ ],
+ "container": None,
+ "stop_reason": "end_turn",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1240,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 4040,
+ "output_tokens_details": {"thinking_tokens": 3480},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.023584, input_cost=0.001364, output_cost=0.02222, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+CLAUDE_FABLE_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="claude-fable-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-fable-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "80901cc6dd89 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-fable-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "tool_use",
+ "id": "toolu_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "caller": {"type": "direct"},
+ }
+ ],
+ "container": None,
+ "stop_reason": "tool_use",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1840,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0585, input_cost=0.0276, output_cost=0.0309, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+CLAUDE_FABLE_5_THINKING: Final = CostTrackingTestCase(
+ name="claude-fable-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-fable-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "d4bb9ddb7e64 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-fable-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "thinking",
+ "thinking": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ },
+ {"type": "text", "text": "scripted answer d4bb9ddb7e64"},
+ ],
+ "container": None,
+ "stop_reason": "end_turn",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1240,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 4040,
+ "output_tokens_details": {"thinking_tokens": 3480},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.3216, input_cost=0.0186, output_cost=0.303, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+CLAUDE_FABLE_5_1_TOOL_CALL: Final = CostTrackingTestCase(
+ name="claude-fable-5-1-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-fable-5-1",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "e0fdc87d1c48 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-fable-5-1",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "tool_use",
+ "id": "toolu_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "caller": {"type": "direct"},
+ }
+ ],
+ "container": None,
+ "stop_reason": "tool_use",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1840,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0624, input_cost=0.02944, output_cost=0.03296, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+CLAUDE_FABLE_5_1_THINKING: Final = CostTrackingTestCase(
+ name="claude-fable-5-1-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-fable-5-1",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "bf3807156155 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-fable-5-1",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [{"type": "text", "text": "scripted answer bf3807156155"}],
+ "container": None,
+ "stop_reason": "end_turn",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1240,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0528, input_cost=0.01984, output_cost=0.03296, prompt_tokens=1240, completion_tokens=412
+ ),
+)
+
+CLAUDE_OPUS_5_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="claude-opus-5-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "31f57d0ee701 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-opus-5-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "tool_use",
+ "id": "toolu_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "caller": {"type": "direct"},
+ }
+ ],
+ "container": None,
+ "stop_reason": "tool_use",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1840,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0156, input_cost=0.00736, output_cost=0.00824, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+CLAUDE_OPUS_5_5_THINKING: Final = CostTrackingTestCase(
+ name="claude-opus-5-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "d4af5bf007f7 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-opus-5-5",
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "thinking",
+ "thinking": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ },
+ {"type": "text", "text": "scripted answer d4af5bf007f7"},
+ ],
+ "container": None,
+ "stop_reason": "end_turn",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1240,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 4040,
+ "output_tokens_details": {"thinking_tokens": 3480},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.08576, input_cost=0.00496, output_cost=0.0808, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+CLAUDE_OPUS_5_5_UPSTREAM_404_ZERO_SPEND: Final = CostTrackingTestCase(
+ name="claude-opus-5-5-upstream_404_zero_spend",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [{"role": "user", "content": "scripted upstream failure 404"}],
+ "stream": False,
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "type": "error",
+ "error": {"type": "not_found_error", "message": "model: scripted-missing-model"},
+ "request_id": "req_$REQUEST_ID",
+ },
+ status=404,
+ ),
+ expected=FailureExpected(failure=FailureDetails(status=404)),
+)
+
+CLAUDE_OPUS_5_5_INPUT_TEXT_ROLLUPS: Final = CostTrackingTestCase(
+ name="claude-opus-5-5-input_text_rollups",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "fed41894bd20 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "allowed_openai_params": [],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "model": "claude-opus-5-5",
+ "id": "msg_$UNIQUE_ID",
+ "type": "message",
+ "role": "assistant",
+ "content": [{"type": "text", "text": "scripted answer fed41894bd20"}],
+ "container": None,
+ "stop_reason": "end_turn",
+ "stop_sequence": None,
+ "stop_details": None,
+ "usage": {
+ "input_tokens": 1840,
+ "cache_creation_input_tokens": 0,
+ "cache_read_input_tokens": 0,
+ "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
+ "output_tokens": 412,
+ "output_tokens_details": {"thinking_tokens": 0},
+ "service_tier": "standard",
+ "inference_geo": "global",
+ },
+ "diagnostics": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0156, input_cost=0.00736, output_cost=0.00824, prompt_tokens=1840, completion_tokens=412, rollups=True
+ ),
+)
+
CASES: Final[tuple[CostTrackingTestCase, ...]] = (
CLAUDE_HAIKU_4_5_INPUT_TEXT,
CLAUDE_HAIKU_4_5_CACHE_READ,
@@ -5926,6 +6759,18 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = (
CLAUDE_OPUS_5_5_CACHE_WRITE_5M,
CLAUDE_OPUS_5_5_CACHE_WRITE_1H,
CLAUDE_OPUS_5_5_MESSAGES_INPUT_TEXT,
+ CLAUDE_SONNET_5_5_TOOL_CALL,
+ CLAUDE_SONNET_5_5_THINKING,
+ CLAUDE_HAIKU_5_5_TOOL_CALL,
+ CLAUDE_HAIKU_5_5_THINKING,
+ CLAUDE_FABLE_5_TOOL_CALL,
+ CLAUDE_FABLE_5_THINKING,
+ CLAUDE_FABLE_5_1_TOOL_CALL,
+ CLAUDE_FABLE_5_1_THINKING,
+ CLAUDE_OPUS_5_5_TOOL_CALL,
+ CLAUDE_OPUS_5_5_THINKING,
+ CLAUDE_OPUS_5_5_UPSTREAM_404_ZERO_SPEND,
+ CLAUDE_OPUS_5_5_INPUT_TEXT_ROLLUPS,
)
PARITY: Final[tuple[StreamParityTestCase, ...]] = (
diff --git a/tests/integration/cost_calculation/cases/azure.py b/tests/integration/cost_calculation/cases/azure.py
index 6c3aaa0c673..b6d6d0496da 100644
--- a/tests/integration/cost_calculation/cases/azure.py
+++ b/tests/integration/cost_calculation/cases/azure.py
@@ -9,6 +9,8 @@ from integration.cost_calculation.cost_tracking_case import (
CostTrackingTestCase,
Deployment,
ExactExpected,
+ FailureDetails,
+ FailureExpected,
JsonResponse,
RecountExpected,
RecountRates,
@@ -4525,6 +4527,1051 @@ AZURE_GPT_6_1_SOL_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase(
),
)
+AZURE_GPT_6_SOL_REASONING: Final = CostTrackingTestCase(
+ name="azure/gpt-6-sol-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "5c0e79234ed5 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "choices": [
+ {
+ "content_filter_results": _GPT_6_CONTENT_FILTER_RESULTS,
+ "finish_reason": "stop",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "annotations": [],
+ "content": "scripted answer 5c0e79234ed5",
+ "refusal": None,
+ "role": "assistant",
+ },
+ }
+ ],
+ "created": 1791855585,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-sol-2026-09-22",
+ "object": "chat.completion",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r15-dp0-prefill"},
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "usage": {
+ "completion_tokens": 4040,
+ "completion_tokens_details": {
+ "accepted_prediction_tokens": 0,
+ "audio_tokens": 0,
+ "reasoning_tokens": 3480,
+ "rejected_prediction_tokens": 0,
+ },
+ "latency_checkpoint": {
+ "engine_tbt_ms": 6,
+ "engine_ttft_ms": 152,
+ "engine_ttlt_ms": 305,
+ "pre_inference_ms": 102,
+ "service_tbt_ms": 9,
+ "service_ttft_ms": 389,
+ "service_ttlt_ms": 608,
+ "user_visible_ttft_ms": 288,
+ },
+ "prompt_tokens": 1240,
+ "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0},
+ "total_tokens": 5280,
+ },
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.049312, input_cost=0.002852, output_cost=0.04646, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+AZURE_GPT_6_SOL_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="azure/gpt-6-sol-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="azure/gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "29fbe99c40db summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "choices": [],
+ "created": 0,
+ "id": "",
+ "model": "",
+ "object": "",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {},
+ "delta": {"content": "", "refusal": None, "role": "assistant"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-sol-2026-09-22",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "5A3jk",
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}},
+ "delta": {"content": "scripted answer 29fbe99c40db"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-sol-2026-09-22",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Q2x",
+ },
+ {
+ "choices": [
+ {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None}
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-sol-2026-09-22",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Uz14j7Ajk4CYaTB",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=2.3e-06, output_cost_per_token=1.15e-05)),
+)
+
+AZURE_GPT_6_LUNA_REASONING: Final = CostTrackingTestCase(
+ name="azure/gpt-6-luna-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6-luna",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "21c501e3e521 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "choices": [
+ {
+ "content_filter_results": _GPT_6_CONTENT_FILTER_RESULTS,
+ "finish_reason": "stop",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "annotations": [],
+ "content": "scripted answer 21c501e3e521",
+ "refusal": None,
+ "role": "assistant",
+ },
+ }
+ ],
+ "created": 1791855585,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-luna-2026-09-22",
+ "object": "chat.completion",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r15-dp0-prefill"},
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "usage": {
+ "completion_tokens": 4040,
+ "completion_tokens_details": {
+ "accepted_prediction_tokens": 0,
+ "audio_tokens": 0,
+ "reasoning_tokens": 3480,
+ "rejected_prediction_tokens": 0,
+ },
+ "latency_checkpoint": {
+ "engine_tbt_ms": 6,
+ "engine_ttft_ms": 152,
+ "engine_ttlt_ms": 305,
+ "pre_inference_ms": 102,
+ "service_tbt_ms": 9,
+ "service_ttft_ms": 389,
+ "service_ttlt_ms": 608,
+ "user_visible_ttft_ms": 288,
+ },
+ "prompt_tokens": 1240,
+ "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0},
+ "total_tokens": 5280,
+ },
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0027872, input_cost=0.0001612, output_cost=0.002626, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+AZURE_GPT_6_LUNA_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="azure/gpt-6-luna-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="azure/gpt-6-luna",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "fef24d05a468 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "choices": [],
+ "created": 0,
+ "id": "",
+ "model": "",
+ "object": "",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {},
+ "delta": {"content": "", "refusal": None, "role": "assistant"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-luna-2026-09-22",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "5A3jk",
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}},
+ "delta": {"content": "scripted answer fef24d05a468"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-luna-2026-09-22",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Q2x",
+ },
+ {
+ "choices": [
+ {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None}
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-luna-2026-09-22",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Uz14j7Ajk4CYaTB",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=1.3e-07, output_cost_per_token=6.5e-07)),
+)
+
+AZURE_GPT_6_ASTRA_REASONING: Final = CostTrackingTestCase(
+ name="azure/gpt-6-astra-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6-astra",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "d7f4aaa662f3 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "choices": [
+ {
+ "content_filter_results": _GPT_6_CONTENT_FILTER_RESULTS,
+ "finish_reason": "stop",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "annotations": [],
+ "content": "scripted answer d7f4aaa662f3",
+ "refusal": None,
+ "role": "assistant",
+ },
+ }
+ ],
+ "created": 1791855585,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-astra-2026-09-03",
+ "object": "chat.completion",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r15-dp0-prefill"},
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "usage": {
+ "completion_tokens": 4040,
+ "completion_tokens_details": {
+ "accepted_prediction_tokens": 0,
+ "audio_tokens": 0,
+ "reasoning_tokens": 3480,
+ "rejected_prediction_tokens": 0,
+ },
+ "latency_checkpoint": {
+ "engine_tbt_ms": 6,
+ "engine_ttft_ms": 152,
+ "engine_ttlt_ms": 305,
+ "pre_inference_ms": 102,
+ "service_tbt_ms": 9,
+ "service_ttft_ms": 389,
+ "service_ttlt_ms": 608,
+ "user_visible_ttft_ms": 288,
+ },
+ "prompt_tokens": 1240,
+ "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0},
+ "total_tokens": 5280,
+ },
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.268, input_cost=0.0155, output_cost=0.2525, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+AZURE_GPT_6_ASTRA_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="azure/gpt-6-astra-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="azure/gpt-6-astra",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "65e182029270 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "choices": [],
+ "created": 0,
+ "id": "",
+ "model": "",
+ "object": "",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {},
+ "delta": {"content": "", "refusal": None, "role": "assistant"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-astra-2026-09-03",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "5A3jk",
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}},
+ "delta": {"content": "scripted answer 65e182029270"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-astra-2026-09-03",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Q2x",
+ },
+ {
+ "choices": [
+ {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None}
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-astra-2026-09-03",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Uz14j7Ajk4CYaTB",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=1.25e-05, output_cost_per_token=6.25e-05)),
+)
+
+AZURE_GPT_6_1_SOL_REASONING: Final = CostTrackingTestCase(
+ name="azure/gpt-6.1-sol-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6.1-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "8ac8b47d17d4 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "choices": [
+ {
+ "content_filter_results": _GPT_6_CONTENT_FILTER_RESULTS,
+ "finish_reason": "stop",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "annotations": [],
+ "content": "scripted answer 8ac8b47d17d4",
+ "refusal": None,
+ "role": "assistant",
+ },
+ }
+ ],
+ "created": 1791855585,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6.1-sol-2026-09-29",
+ "object": "chat.completion",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r15-dp0-prefill"},
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "usage": {
+ "completion_tokens": 4040,
+ "completion_tokens_details": {
+ "accepted_prediction_tokens": 0,
+ "audio_tokens": 0,
+ "reasoning_tokens": 3480,
+ "rejected_prediction_tokens": 0,
+ },
+ "latency_checkpoint": {
+ "engine_tbt_ms": 6,
+ "engine_ttft_ms": 152,
+ "engine_ttlt_ms": 305,
+ "pre_inference_ms": 102,
+ "service_tbt_ms": 9,
+ "service_ttft_ms": 389,
+ "service_ttlt_ms": 608,
+ "user_visible_ttft_ms": 288,
+ },
+ "prompt_tokens": 1240,
+ "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0},
+ "total_tokens": 5280,
+ },
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.051456, input_cost=0.002976, output_cost=0.04848, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+AZURE_GPT_6_1_SOL_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="azure/gpt-6.1-sol-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="azure/gpt-6.1-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "20e483d62a14 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "choices": [],
+ "created": 0,
+ "id": "",
+ "model": "",
+ "object": "",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {},
+ "delta": {"content": "", "refusal": None, "role": "assistant"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6.1-sol-2026-09-29",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "5A3jk",
+ },
+ {
+ "choices": [
+ {
+ "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}},
+ "delta": {"content": "scripted answer 20e483d62a14"},
+ "finish_reason": None,
+ "index": 0,
+ "logprobs": None,
+ }
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6.1-sol-2026-09-29",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Q2x",
+ },
+ {
+ "choices": [
+ {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None}
+ ],
+ "created": 1791855587,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6.1-sol-2026-09-29",
+ "object": "chat.completion.chunk",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "obfuscation": "Uz14j7Ajk4CYaTB",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=2.4e-06, output_cost_per_token=1.2e-05)),
+)
+
+AZURE_GPT_6_SOL_UPSTREAM_404_ZERO_SPEND: Final = CostTrackingTestCase(
+ name="azure/gpt-6-sol-upstream_404_zero_spend",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [{"role": "user", "content": "scripted upstream failure 404"}],
+ "stream": False,
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "error": {
+ "type": "invalid_request_error",
+ "code": "DeploymentNotFound",
+ "message": "The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.",
+ }
+ },
+ status=404,
+ ),
+ expected=FailureExpected(failure=FailureDetails(status=404)),
+)
+
+AZURE_GPT_6_SOL_INPUT_TEXT_ROLLUPS: Final = CostTrackingTestCase(
+ name="azure/gpt-6-sol-input_text_rollups",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "c01175bb4811 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "allowed_openai_params": [],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "choices": [
+ {
+ "content_filter_results": _GPT_6_CONTENT_FILTER_RESULTS,
+ "finish_reason": "stop",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "annotations": [],
+ "content": "scripted answer c01175bb4811",
+ "refusal": None,
+ "role": "assistant",
+ },
+ }
+ ],
+ "created": 1791855585,
+ "id": "chatcmpl-$UNIQUE_ID",
+ "model": "gpt-6-sol-2026-09-22",
+ "object": "chat.completion",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r15-dp0-prefill"},
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "usage": {
+ "completion_tokens": 412,
+ "completion_tokens_details": {
+ "accepted_prediction_tokens": 0,
+ "audio_tokens": 0,
+ "reasoning_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ "latency_checkpoint": {
+ "engine_tbt_ms": 6,
+ "engine_ttft_ms": 152,
+ "engine_ttlt_ms": 305,
+ "pre_inference_ms": 102,
+ "service_tbt_ms": 9,
+ "service_ttft_ms": 389,
+ "service_ttlt_ms": 608,
+ "user_visible_ttft_ms": 288,
+ },
+ "prompt_tokens": 1840,
+ "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0},
+ "total_tokens": 2252,
+ },
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00897,
+ input_cost=0.004232,
+ output_cost=0.004738,
+ prompt_tokens=1840,
+ completion_tokens=412,
+ rollups=True,
+ ),
+)
+
+AZURE_GPT_6_SOL_TOOL_CALL: Final = CostTrackingTestCase(
+ name="azure/gpt-6-sol-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "59601dc5d1c2 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "reasoning_effort": "none",
+ "allowed_openai_params": ["tool_choice", "reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "choices": [
+ {
+ "content_filter_results": _GPT_6_CONTENT_FILTER_RESULTS,
+ "finish_reason": "tool_calls",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "annotations": [],
+ "content": None,
+ "refusal": None,
+ "role": "assistant",
+ "tool_calls": [
+ {
+ "function": {
+ "arguments": '{"city":"Berlin","days":7,"units":"metric"}',
+ "name": "get_weather",
+ },
+ "id": "call_$REQUEST_ID",
+ "type": "function",
+ }
+ ],
+ },
+ }
+ ],
+ "created": 1791855585,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-sol-2026-09-22",
+ "object": "chat.completion",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r15-dp0-prefill"},
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "usage": {
+ "completion_tokens": 412,
+ "completion_tokens_details": {
+ "accepted_prediction_tokens": 0,
+ "audio_tokens": 0,
+ "reasoning_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ "latency_checkpoint": {
+ "engine_tbt_ms": 6,
+ "engine_ttft_ms": 152,
+ "engine_ttlt_ms": 305,
+ "pre_inference_ms": 102,
+ "service_tbt_ms": 9,
+ "service_ttft_ms": 389,
+ "service_ttlt_ms": 608,
+ "user_visible_ttft_ms": 288,
+ },
+ "prompt_tokens": 1840,
+ "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0},
+ "total_tokens": 2252,
+ },
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00897, input_cost=0.004232, output_cost=0.004738, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+AZURE_GPT_6_LUNA_TOOL_CALL: Final = CostTrackingTestCase(
+ name="azure/gpt-6-luna-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="azure/gpt-6-luna",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "2dc3f74a8aa3 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "reasoning_effort": "none",
+ "allowed_openai_params": ["tool_choice", "reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "choices": [
+ {
+ "content_filter_results": _GPT_6_CONTENT_FILTER_RESULTS,
+ "finish_reason": "tool_calls",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "annotations": [],
+ "content": None,
+ "refusal": None,
+ "role": "assistant",
+ "tool_calls": [
+ {
+ "function": {
+ "arguments": '{"city":"Berlin","days":7,"units":"metric"}',
+ "name": "get_weather",
+ },
+ "id": "call_$REQUEST_ID",
+ "type": "function",
+ }
+ ],
+ },
+ }
+ ],
+ "created": 1791855585,
+ "id": "chatcmpl-$REQUEST_ID",
+ "model": "gpt-6-luna-2026-09-22",
+ "object": "chat.completion",
+ "prompt_filter_results": _GPT_6_PROMPT_FILTER_RESULTS,
+ "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r15-dp0-prefill"},
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "usage": {
+ "completion_tokens": 412,
+ "completion_tokens_details": {
+ "accepted_prediction_tokens": 0,
+ "audio_tokens": 0,
+ "reasoning_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ "latency_checkpoint": {
+ "engine_tbt_ms": 6,
+ "engine_ttft_ms": 152,
+ "engine_ttlt_ms": 305,
+ "pre_inference_ms": 102,
+ "service_tbt_ms": 9,
+ "service_ttft_ms": 389,
+ "service_ttlt_ms": 608,
+ "user_visible_ttft_ms": 288,
+ },
+ "prompt_tokens": 1840,
+ "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0},
+ "total_tokens": 2252,
+ },
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.000507, input_cost=0.0002392, output_cost=0.0002678, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
CASES: Final[tuple[CostTrackingTestCase, ...]] = (
AZURE_GPT_5_4_MINI_INPUT_TEXT,
AZURE_GPT_5_4_MINI_CACHE_READ,
@@ -4584,6 +5631,18 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = (
AZURE_GPT_6_1_SOL_STREAM,
AZURE_GPT_6_1_SOL_SERVICE_TIER_FLEX,
AZURE_GPT_6_1_SOL_SERVICE_TIER_PRIORITY,
+ AZURE_GPT_6_SOL_REASONING,
+ AZURE_GPT_6_SOL_STREAM_NO_USAGE,
+ AZURE_GPT_6_LUNA_REASONING,
+ AZURE_GPT_6_LUNA_STREAM_NO_USAGE,
+ AZURE_GPT_6_ASTRA_REASONING,
+ AZURE_GPT_6_ASTRA_STREAM_NO_USAGE,
+ AZURE_GPT_6_1_SOL_REASONING,
+ AZURE_GPT_6_1_SOL_STREAM_NO_USAGE,
+ AZURE_GPT_6_SOL_UPSTREAM_404_ZERO_SPEND,
+ AZURE_GPT_6_SOL_INPUT_TEXT_ROLLUPS,
+ AZURE_GPT_6_SOL_TOOL_CALL,
+ AZURE_GPT_6_LUNA_TOOL_CALL,
)
PARITY: Final[tuple[StreamParityTestCase, ...]] = (
diff --git a/tests/integration/cost_calculation/cases/bedrock_converse.py b/tests/integration/cost_calculation/cases/bedrock_converse.py
index 8582ce08168..7e33b700a48 100644
--- a/tests/integration/cost_calculation/cases/bedrock_converse.py
+++ b/tests/integration/cost_calculation/cases/bedrock_converse.py
@@ -10,6 +10,8 @@ from integration.cost_calculation.cost_tracking_case import (
EventStreamEvent,
EventStreamResponse,
ExactExpected,
+ FailureDetails,
+ FailureExpected,
JsonResponse,
RecountExpected,
RecountRates,
@@ -4857,6 +4859,1071 @@ US_ANTHROPIC_CLAUDE_FABLE_5_1_CACHE_WRITE_1H: Final = CostTrackingTestCase(
),
)
+US_ANTHROPIC_CLAUDE_SONNET_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-sonnet-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-sonnet-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "c87a264a36d3 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "reasoningContent": {
+ "reasoningText": {
+ "text": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ }
+ }
+ },
+ {
+ "toolUse": {
+ "toolUseId": "tooluse_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "type": "tool_use",
+ }
+ },
+ ],
+ }
+ },
+ "stopReason": "tool_use",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.01404, input_cost=0.006624, output_cost=0.007416, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_SONNET_5_THINKING: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-sonnet-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-sonnet-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "2736f5db99fa summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "reasoningContent": {
+ "reasoningText": {
+ "text": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ }
+ }
+ },
+ {"text": "scripted answer 2736f5db99fa"},
+ ],
+ }
+ },
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1240,
+ "outputTokens": 4040,
+ "totalTokens": 5280,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.077184, input_cost=0.004464, output_cost=0.07272, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_SONNET_5_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-sonnet-5-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-sonnet-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "a19e69e4777a summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "toolUse": {
+ "toolUseId": "tooluse_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "type": "tool_use",
+ }
+ }
+ ],
+ }
+ },
+ "stopReason": "tool_use",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.01443, input_cost=0.006808, output_cost=0.007622, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_SONNET_5_5_THINKING: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-sonnet-5-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-sonnet-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "fe9c9714d04d summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {"message": {"role": "assistant", "content": [{"text": "scripted answer fe9c9714d04d"}]}},
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1240,
+ "outputTokens": 412,
+ "totalTokens": 1652,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.01221, input_cost=0.004588, output_cost=0.007622, prompt_tokens=1240, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_OPUS_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-opus-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-opus-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "d2235a5023bf summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "toolUse": {
+ "toolUseId": "tooluse_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "type": "tool_use",
+ }
+ }
+ ],
+ }
+ },
+ "stopReason": "tool_use",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0234, input_cost=0.01104, output_cost=0.01236, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_OPUS_5_THINKING: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-opus-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-opus-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "50c5c1415303 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "reasoningContent": {
+ "reasoningText": {
+ "text": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ }
+ }
+ },
+ {"text": "scripted answer 50c5c1415303"},
+ ],
+ }
+ },
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1240,
+ "outputTokens": 4040,
+ "totalTokens": 5280,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.12864, input_cost=0.00744, output_cost=0.1212, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_OPUS_5_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-opus-5-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "6095fb901387 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "toolUse": {
+ "toolUseId": "tooluse_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "type": "tool_use",
+ }
+ }
+ ],
+ }
+ },
+ "stopReason": "tool_use",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.01716, input_cost=0.008096, output_cost=0.009064, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_OPUS_5_5_THINKING: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-opus-5-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "2ba98156d243 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "reasoningContent": {
+ "reasoningText": {
+ "text": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ }
+ }
+ },
+ {"text": "scripted answer 2ba98156d243"},
+ ],
+ }
+ },
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1240,
+ "outputTokens": 4040,
+ "totalTokens": 5280,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.094336, input_cost=0.005456, output_cost=0.08888, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_HAIKU_5_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-haiku-5-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-haiku-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "7d7caefb1f0d summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "toolUse": {
+ "toolUseId": "tooluse_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "type": "tool_use",
+ }
+ }
+ ],
+ }
+ },
+ "stopReason": "tool_use",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00468, input_cost=0.002208, output_cost=0.002472, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_HAIKU_5_5_THINKING: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-haiku-5-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-haiku-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "90a6bb1996a5 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {"message": {"role": "assistant", "content": [{"text": "scripted answer 90a6bb1996a5"}]}},
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1240,
+ "outputTokens": 412,
+ "totalTokens": 1652,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00396, input_cost=0.001488, output_cost=0.002472, prompt_tokens=1240, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_FABLE_5_TOOL_CALL: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-fable-5-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-fable-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "a51000416e04 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "toolUse": {
+ "toolUseId": "tooluse_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "type": "tool_use",
+ }
+ }
+ ],
+ }
+ },
+ "stopReason": "tool_use",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0663, input_cost=0.03128, output_cost=0.03502, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_FABLE_5_THINKING: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-fable-5-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-fable-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "24888a505ee9 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "reasoningContent": {
+ "reasoningText": {
+ "text": "",
+ "signature": "CAQS1gQKEAgSGAI4AUIIdGhpbmtpbmcSDOsCmv80YWY0IrUDvBoMog2",
+ }
+ }
+ },
+ {"text": "scripted answer 24888a505ee9"},
+ ],
+ }
+ },
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1240,
+ "outputTokens": 4040,
+ "totalTokens": 5280,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.36448, input_cost=0.02108, output_cost=0.3434, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_FABLE_5_1_TOOL_CALL: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-fable-5-1-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-fable-5-1",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "7f97ab74e808 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "allowed_openai_params": ["tool_choice"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "toolUse": {
+ "toolUseId": "tooluse_$REQUEST_ID",
+ "name": "get_weather",
+ "input": {"city": "Berlin", "days": 7, "units": "metric"},
+ "type": "tool_use",
+ }
+ }
+ ],
+ }
+ },
+ "stopReason": "tool_use",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0702, input_cost=0.03312, output_cost=0.03708, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_FABLE_5_1_THINKING: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-fable-5-1-thinking",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-fable-5-1",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "bca700fd52a2 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {"message": {"role": "assistant", "content": [{"text": "scripted answer bca700fd52a2"}]}},
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1240,
+ "outputTokens": 412,
+ "totalTokens": 1652,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.0594, input_cost=0.02232, output_cost=0.03708, prompt_tokens=1240, completion_tokens=412
+ ),
+)
+
+US_ANTHROPIC_CLAUDE_OPUS_5_5_UPSTREAM_400_ZERO_SPEND: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-opus-5-5-upstream_400_zero_spend",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [{"role": "user", "content": "scripted upstream failure 400"}],
+ "stream": False,
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={"message": "The provided model identifier is invalid."},
+ status=400,
+ ),
+ expected=FailureExpected(failure=FailureDetails(status=400)),
+)
+
+US_ANTHROPIC_CLAUDE_OPUS_5_5_INPUT_TEXT_ROLLUPS: Final = CostTrackingTestCase(
+ name="us.anthropic.claude-opus-5-5-input_text_rollups",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="us.anthropic.claude-opus-5-5",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "75e5a866d0e3 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "allowed_openai_params": [],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "output": {
+ "message": {"role": "assistant", "content": [{"text": "scripted answer 75e5a866d0e3 $UNIQUE_ID"}]}
+ },
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412,
+ "totalTokens": 2252,
+ "cacheReadInputTokens": 0,
+ "cacheWriteInputTokens": 0,
+ },
+ "metrics": {"latencyMs": 2071},
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.01716,
+ input_cost=0.008096,
+ output_cost=0.009064,
+ prompt_tokens=1840,
+ completion_tokens=412,
+ rollups=True,
+ ),
+)
+
CASES: Final[tuple[CostTrackingTestCase, ...]] = (
ANTHROPIC_CLAUDE_SONNET_5_V1_0_INPUT_TEXT,
ANTHROPIC_CLAUDE_SONNET_5_V1_0_CACHE_READ,
@@ -4951,6 +6018,22 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = (
US_ANTHROPIC_CLAUDE_FABLE_5_1_CACHE_READ,
US_ANTHROPIC_CLAUDE_FABLE_5_1_CACHE_WRITE_5M,
US_ANTHROPIC_CLAUDE_FABLE_5_1_CACHE_WRITE_1H,
+ US_ANTHROPIC_CLAUDE_SONNET_5_TOOL_CALL,
+ US_ANTHROPIC_CLAUDE_SONNET_5_THINKING,
+ US_ANTHROPIC_CLAUDE_SONNET_5_5_TOOL_CALL,
+ US_ANTHROPIC_CLAUDE_SONNET_5_5_THINKING,
+ US_ANTHROPIC_CLAUDE_OPUS_5_TOOL_CALL,
+ US_ANTHROPIC_CLAUDE_OPUS_5_THINKING,
+ US_ANTHROPIC_CLAUDE_OPUS_5_5_TOOL_CALL,
+ US_ANTHROPIC_CLAUDE_OPUS_5_5_THINKING,
+ US_ANTHROPIC_CLAUDE_HAIKU_5_5_TOOL_CALL,
+ US_ANTHROPIC_CLAUDE_HAIKU_5_5_THINKING,
+ US_ANTHROPIC_CLAUDE_FABLE_5_TOOL_CALL,
+ US_ANTHROPIC_CLAUDE_FABLE_5_THINKING,
+ US_ANTHROPIC_CLAUDE_FABLE_5_1_TOOL_CALL,
+ US_ANTHROPIC_CLAUDE_FABLE_5_1_THINKING,
+ US_ANTHROPIC_CLAUDE_OPUS_5_5_UPSTREAM_400_ZERO_SPEND,
+ US_ANTHROPIC_CLAUDE_OPUS_5_5_INPUT_TEXT_ROLLUPS,
)
PARITY: Final[tuple[StreamParityTestCase, ...]] = (
diff --git a/tests/integration/cost_calculation/cases/openai.py b/tests/integration/cost_calculation/cases/openai.py
index 64753827ac1..6268ec2b463 100644
--- a/tests/integration/cost_calculation/cases/openai.py
+++ b/tests/integration/cost_calculation/cases/openai.py
@@ -21,6 +21,7 @@ from integration.cost_calculation.cost_tracking_case import (
)
from pydantic import JsonValue
from integration.cost_calculation.stream_parity.case import StreamParityTestCase, sse_frames
+from integration.cost_calculation.bridge_cost_parity.case import BridgeCostParityTestCase
# gpt-5.3-codex
@@ -8587,6 +8588,18 @@ GPT_6_SOL_RESPONSES_NATIVE_JSON: Final = CostTrackingTestCase(
),
)
+GPT_6_SOL_MESSAGES_BRIDGED_JSON: Final = GPT_6_SOL_RESPONSES_NATIVE_JSON.model_copy(
+ update={
+ "name": "gpt-6-sol-messages_bridged_json",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [{"role": "user", "content": "responses native fixture"}],
+ },
+ }
+)
+
GPT_6_LUNA_INPUT_TEXT: Final = CostTrackingTestCase(
name="gpt-6-luna-input_text",
covers="quota_management.spend_tracking.cost_matrix.logs_cost",
@@ -9643,170 +9656,1071 @@ GPT_6_1_SOL_RESPONSES_NATIVE_JSON: Final = CostTrackingTestCase(
),
)
-CASES: Final[tuple[CostTrackingTestCase, ...]] = (
- GPT_5_3_CODEX_INPUT_TEXT,
- GPT_5_3_CODEX_CACHE_READ,
- GPT_5_3_CODEX_REASONING,
- GPT_5_3_CODEX_SERVICE_TIER_FLEX,
- GPT_5_3_CODEX_SERVICE_TIER_PRIORITY,
- GPT_5_3_CODEX_WEB_SEARCH_MEDIUM,
- GPT_5_3_CODEX_WEB_SEARCH_LOW,
- GPT_5_3_CODEX_WEB_SEARCH_HIGH,
- GPT_5_3_CODEX_FILE_SEARCH,
- GPT_5_3_CODEX_STREAM,
- GPT_5_3_CODEX_STREAM_NO_USAGE,
- GPT_5_3_CODEX_STREAM_NO_USAGE_TOOL_CALL,
- GPT_5_3_CODEX_STREAM_NO_USAGE_IMAGE_INPUT,
- GPT_5_3_CODEX_STREAM_INCOMPLETE,
- GPT_5_3_CODEX_STREAM_NO_USAGE_INCOMPLETE,
- GPT_5_3_CODEX_STREAM_UNVALIDATED,
- GPT_5_3_CODEX_STREAM_NO_USAGE_UNVALIDATED,
- GPT_5_3_CODEX_RESPONSE_MODEL_OVERRIDE,
- GPT_5_3_CODEX_STREAM_RESPONSE_MODEL_OVERRIDE,
- GPT_5_3_CODEX_TOOL_CALL,
- GPT_5_3_CODEX_STREAM_TOOL_CALL,
- GPT_5_3_CODEX_STREAM_FULL_USAGE,
- GPT_5_4_MINI_INPUT_TEXT,
- GPT_5_4_MINI_CACHE_READ,
- GPT_5_4_MINI_AUDIO_INPUT,
- GPT_5_4_MINI_AUDIO_OUTPUT,
- GPT_5_4_MINI_REASONING,
- GPT_5_4_MINI_SERVICE_TIER_FLEX,
- GPT_5_4_MINI_SERVICE_TIER_PRIORITY,
- GPT_5_4_MINI_WEB_SEARCH_MEDIUM,
- GPT_5_4_MINI_WEB_SEARCH_LOW,
- GPT_5_4_MINI_WEB_SEARCH_HIGH,
- GPT_5_4_MINI_STREAM,
- GPT_5_4_MINI_STREAM_NO_USAGE,
- GPT_5_4_MINI_STREAM_NO_USAGE_TOOL_CALL,
- GPT_5_4_MINI_STREAM_NO_USAGE_IMAGE_INPUT,
- GPT_5_4_MINI_RESPONSE_MODEL_OVERRIDE,
- GPT_5_4_MINI_STREAM_RESPONSE_MODEL_OVERRIDE,
- GPT_5_4_MINI_TOOL_CALL,
- GPT_5_4_MINI_STREAM_TOOL_CALL,
- GPT_5_4_MINI_STREAM_FULL_USAGE,
- GPT_5_5_PRO_INPUT_TEXT,
- GPT_5_5_PRO_CACHE_READ,
- GPT_5_5_PRO_REASONING,
- GPT_5_5_PRO_SERVICE_TIER_FLEX,
- GPT_5_5_PRO_SERVICE_TIER_PRIORITY,
- GPT_5_5_PRO_WEB_SEARCH_MEDIUM,
- GPT_5_5_PRO_WEB_SEARCH_LOW,
- GPT_5_5_PRO_WEB_SEARCH_HIGH,
- GPT_5_5_PRO_FILE_SEARCH,
- GPT_5_5_PRO_STREAM,
- GPT_5_5_PRO_STREAM_NO_USAGE,
- GPT_5_5_PRO_STREAM_NO_USAGE_TOOL_CALL,
- GPT_5_5_PRO_STREAM_NO_USAGE_IMAGE_INPUT,
- GPT_5_5_PRO_STREAM_INCOMPLETE,
- GPT_5_5_PRO_STREAM_NO_USAGE_INCOMPLETE,
- GPT_5_5_PRO_STREAM_UNVALIDATED,
- GPT_5_5_PRO_STREAM_NO_USAGE_UNVALIDATED,
- GPT_5_5_PRO_RESPONSE_MODEL_OVERRIDE,
- GPT_5_5_PRO_STREAM_RESPONSE_MODEL_OVERRIDE,
- GPT_5_5_PRO_TOOL_CALL,
- GPT_5_5_PRO_STREAM_TOOL_CALL,
- GPT_5_5_PRO_STREAM_FULL_USAGE,
- GPT_5_6_INPUT_TEXT,
- GPT_5_6_CACHE_READ,
- GPT_5_6_AUDIO_INPUT,
- GPT_5_6_AUDIO_OUTPUT,
- GPT_5_6_REASONING,
- GPT_5_6_SERVICE_TIER_FLEX,
- GPT_5_6_SERVICE_TIER_PRIORITY,
- GPT_5_6_WEB_SEARCH_MEDIUM,
- GPT_5_6_WEB_SEARCH_LOW,
- GPT_5_6_WEB_SEARCH_HIGH,
- GPT_5_6_STREAM,
- GPT_5_6_STREAM_NO_USAGE,
- GPT_5_6_STREAM_NO_USAGE_TOOL_CALL,
- GPT_5_6_STREAM_NO_USAGE_IMAGE_INPUT,
- GPT_5_6_RESPONSE_MODEL_OVERRIDE,
- GPT_5_6_STREAM_RESPONSE_MODEL_OVERRIDE,
- GPT_5_6_TOOL_CALL,
- GPT_5_6_STREAM_TOOL_CALL,
- GPT_5_6_STREAM_FULL_USAGE,
- GPT_5_6_RESPONSES_NATIVE_JSON,
- GPT_5_6_UPSTREAM_500_ZERO_SPEND,
- GPT_5_6_UPSTREAM_429_ZERO_SPEND,
- WHISPER_NEXT_TRANSCRIPTIONS_PER_SECOND,
- WHISPER_VERBOSE_NEXT_TRANSCRIPTIONS_DURATION,
- GPT_4O_TRANSCRIBE_NEXT_TRANSCRIPTIONS_TOKENS,
- TTS_NEXT_SPEECH_PER_CHARACTER,
- TTS_NEXT_HD_SPEECH_PER_CHARACTER,
- DALL_E_3_NEXT_IMAGES_STANDARD,
- DALL_E_3_NEXT_IMAGES_HD,
- DALL_E_3_NEXT_IMAGES_WIDE,
- DALL_E_3_NEXT_IMAGES_TWO,
- GPT_IMAGE_NEXT_IMAGES_LOW,
- GPT_IMAGE_NEXT_IMAGES_EDIT,
- TEXT_EMBEDDINGS_4_SMALL_SINGLE,
- TEXT_EMBEDDINGS_4_SMALL_BATCH,
- TEXT_EMBEDDINGS_4_SMALL_TOKEN_ARRAY,
- TEXT_EMBEDDINGS_3_LARGE_DIMENSIONS,
- OMNI_MODERATIONS_NEXT_SINGLE,
- OMNI_MODERATIONS_NEXT_LIST,
- GPT_5_6_RESPONSES_CACHE_READ,
- GPT_5_6_RESPONSES_REASONING,
- GPT_5_6_RESPONSES_STREAM,
- GPT_5_6_RESPONSES_STREAM_CACHE_READ,
- GPT_5_6_RESPONSES_INCOMPLETE,
- GPT_5_6_RESPONSES_PREVIOUS_RESPONSE_ID,
- GPT_5_6_RESPONSES_WEB_SEARCH_MEDIUM,
- GPT_5_6_RESPONSES_WEB_SEARCH_REPORTED_COUNT_MIXED_ACTIONS,
- GPT_5_6_RESPONSES_WEB_SEARCH_REPORTED_COUNT_OPEN_PAGE_ONLY,
- GPT_5_6_RESPONSES_WEB_SEARCH_REPORTED_COUNT_MIXED_ACTIONS_STREAM,
- GPT_5_3_CODEX_RESPONSES_FILE_SEARCH,
- GPT_5_6_RESPONSES_SERVICE_TIER_FLEX,
- GPT_5_6_RESPONSES_SERVICE_TIER_PRIORITY,
- OPENAI_DEPLOYMENT_PRICING_OVERRIDE,
- OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER,
- OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER_STREAM,
- OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER_MESSAGES,
- OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER_RESPONSES,
- OPENAI_DEPLOYMENT_PRICING_IGNORES_UPSTREAM_COST_HEADER,
- GPT_5_6_UPSTREAM_COST_HEADER_BILLS_HEADER_VALUE,
- GPT_5_6_UPSTREAM_400_ZERO_SPEND,
- GPT_5_6_UPSTREAM_401_ZERO_SPEND,
- GPT_5_6_UPSTREAM_500_STREAM_REQUEST_ZERO_SPEND,
- GPT_5_6_RESPONSES_UPSTREAM_500_ZERO_SPEND,
- CLAUDE_SONNET_5_MESSAGES_UPSTREAM_500_ZERO_SPEND,
- GPT_5_6_FALLBACK_BILLED_TO_ANSWERING_DEPLOYMENT,
- GPT_5_6_N_2_CHOICES,
- GPT_5_6_FINISH_REASON_LENGTH,
- GPT_5_6_STREAM_USAGE_IN_EMPTY_CHOICES_CHUNK,
- GPT_5_6_STREAM_USAGE_IN_LAST_DELTA_CHUNK,
- GPT_5_6_UNKNOWN_MODEL_RESPONSE_MODEL_UNKNOWN,
- GPT_5_6_UNKNOWN_MODEL_RESPONSE_MODEL_KNOWN,
- GPT_5_6_CHAT_REQUEST_TO_EMBEDDING_ENTRY,
- GPT_5_6_CLIENT_DISCONNECT_MID_STREAM,
- GPT_6_1_SOL_INPUT_TEXT,
- OPENAI_GPT_6_LUNA_DECISIONS,
- OPENAI_GPT_6_LUNA_SYSTEMONE,
- OPENAI_GPT_6_LUNA_DECISIONS_LONG_CONTEXT,
- OPENAI_GPT_6_LUNA_SYSTEMONE_LONG_CONTEXT,
- GPT_6_SOL_INPUT_TEXT,
- GPT_6_SOL_STREAM,
- GPT_6_SOL_SERVICE_TIER_FLEX,
- GPT_6_SOL_SERVICE_TIER_PRIORITY,
- GPT_6_SOL_RESPONSES_NATIVE_JSON,
- GPT_6_LUNA_INPUT_TEXT,
- GPT_6_LUNA_STREAM,
- GPT_6_LUNA_SERVICE_TIER_FLEX,
- GPT_6_LUNA_SERVICE_TIER_PRIORITY,
- GPT_6_LUNA_RESPONSES_NATIVE_JSON,
- GPT_6_ASTRA_INPUT_TEXT,
- GPT_6_ASTRA_STREAM,
- GPT_6_ASTRA_SERVICE_TIER_FLEX,
- GPT_6_ASTRA_SERVICE_TIER_PRIORITY,
- GPT_6_ASTRA_RESPONSES_NATIVE_JSON,
- GPT_6_1_SOL_STREAM,
- GPT_6_1_SOL_SERVICE_TIER_FLEX,
- GPT_6_1_SOL_SERVICE_TIER_PRIORITY,
- GPT_6_1_SOL_RESPONSES_NATIVE_JSON,
+GPT_6_SOL_TOOL_CALL: Final = CostTrackingTestCase(
+ name="gpt-6-sol-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "b2ce2f555743 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "reasoning_effort": "none",
+ "allowed_openai_params": ["tool_choice", "reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion",
+ "created": 1791855452,
+ "model": "gpt-6-sol",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": None,
+ "tool_calls": [
+ {
+ "id": "call_$REQUEST_ID",
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "arguments": '{"city":"Berlin","days":7,"units":"metric"}',
+ },
+ }
+ ],
+ "refusal": None,
+ "annotations": [],
+ },
+ "finish_reason": "tool_calls",
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 1840,
+ "completion_tokens": 412,
+ "total_tokens": 2252,
+ "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0, "audio_tokens": 0},
+ "completion_tokens_details": {
+ "reasoning_tokens": 0,
+ "audio_tokens": 0,
+ "accepted_prediction_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ },
+ "service_tier": "default",
+ "system_fingerprint": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00858, input_cost=0.004048, output_cost=0.004532, prompt_tokens=1840, completion_tokens=412
+ ),
)
-PARITY: Final[tuple[StreamParityTestCase, ...]] = (
+GPT_6_SOL_REASONING: Final = CostTrackingTestCase(
+ name="gpt-6-sol-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "3646649ee64b summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion",
+ "created": 1791855452,
+ "model": "gpt-6-sol",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "scripted answer 3646649ee64b",
+ "refusal": None,
+ "annotations": [],
+ },
+ "finish_reason": "stop",
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 1240,
+ "completion_tokens": 4040,
+ "total_tokens": 5280,
+ "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0, "audio_tokens": 0},
+ "completion_tokens_details": {
+ "reasoning_tokens": 3480,
+ "audio_tokens": 0,
+ "accepted_prediction_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ },
+ "service_tier": "default",
+ "system_fingerprint": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.047168, input_cost=0.002728, output_cost=0.04444, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+GPT_6_SOL_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="gpt-6-sol-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "e026eaee0c4e summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-sol",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [
+ {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None}
+ ],
+ "obfuscation": "5A3jk",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-sol",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {"content": "scripted answer e026eaee0c4e"}, "finish_reason": None}],
+ "obfuscation": "Q2x",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-sol",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}],
+ "obfuscation": "v37dpurTBq",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=2.2e-06, output_cost_per_token=1.1e-05)),
+)
+
+GPT_6_LUNA_TOOL_CALL: Final = CostTrackingTestCase(
+ name="gpt-6-luna-tool_call",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6-luna",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "29a8fbc85239 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather and a short forecast for a city.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": {"type": "string", "description": "City name"},
+ "days": {"type": "integer", "description": "Forecast horizon in days"},
+ "units": {"type": "string", "enum": ["metric", "imperial"]},
+ },
+ "required": ["city"],
+ },
+ },
+ }
+ ],
+ "tool_choice": "auto",
+ "reasoning_effort": "none",
+ "allowed_openai_params": ["tool_choice", "reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion",
+ "created": 1791855452,
+ "model": "gpt-6-luna",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": None,
+ "tool_calls": [
+ {
+ "id": "call_$REQUEST_ID",
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "arguments": '{"city":"Berlin","days":7,"units":"metric"}',
+ },
+ }
+ ],
+ "refusal": None,
+ "annotations": [],
+ },
+ "finish_reason": "tool_calls",
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 1840,
+ "completion_tokens": 412,
+ "total_tokens": 2252,
+ "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0, "audio_tokens": 0},
+ "completion_tokens_details": {
+ "reasoning_tokens": 0,
+ "audio_tokens": 0,
+ "accepted_prediction_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ },
+ "service_tier": "default",
+ "system_fingerprint": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00039, input_cost=0.000184, output_cost=0.000206, prompt_tokens=1840, completion_tokens=412
+ ),
+)
+
+GPT_6_LUNA_REASONING: Final = CostTrackingTestCase(
+ name="gpt-6-luna-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6-luna",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "ae40dff71266 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion",
+ "created": 1791855452,
+ "model": "gpt-6-luna",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "scripted answer ae40dff71266",
+ "refusal": None,
+ "annotations": [],
+ },
+ "finish_reason": "stop",
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 1240,
+ "completion_tokens": 4040,
+ "total_tokens": 5280,
+ "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0, "audio_tokens": 0},
+ "completion_tokens_details": {
+ "reasoning_tokens": 3480,
+ "audio_tokens": 0,
+ "accepted_prediction_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ },
+ "service_tier": "default",
+ "system_fingerprint": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.002144, input_cost=0.000124, output_cost=0.00202, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+GPT_6_LUNA_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="gpt-6-luna-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="gpt-6-luna",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "e8f84b81110b summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-luna",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [
+ {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None}
+ ],
+ "obfuscation": "5A3jk",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-luna",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {"content": "scripted answer e8f84b81110b"}, "finish_reason": None}],
+ "obfuscation": "Q2x",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-luna",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}],
+ "obfuscation": "v37dpurTBq",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=1e-07, output_cost_per_token=5e-07)),
+)
+
+GPT_6_ASTRA_REASONING: Final = CostTrackingTestCase(
+ name="gpt-6-astra-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6-astra",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "5ff48be12807 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion",
+ "created": 1791855452,
+ "model": "gpt-6-astra",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "scripted answer 5ff48be12807",
+ "refusal": None,
+ "annotations": [],
+ },
+ "finish_reason": "stop",
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 1240,
+ "completion_tokens": 4040,
+ "total_tokens": 5280,
+ "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0, "audio_tokens": 0},
+ "completion_tokens_details": {
+ "reasoning_tokens": 3480,
+ "audio_tokens": 0,
+ "accepted_prediction_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ },
+ "service_tier": "default",
+ "system_fingerprint": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.25728, input_cost=0.01488, output_cost=0.2424, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+GPT_6_ASTRA_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="gpt-6-astra-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="gpt-6-astra",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "8508ebd1992c summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-astra",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [
+ {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None}
+ ],
+ "obfuscation": "5A3jk",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-astra",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {"content": "scripted answer 8508ebd1992c"}, "finish_reason": None}],
+ "obfuscation": "Q2x",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6-astra",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}],
+ "obfuscation": "v37dpurTBq",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=1.2e-05, output_cost_per_token=6e-05)),
+)
+
+GPT_6_1_SOL_REASONING: Final = CostTrackingTestCase(
+ name="gpt-6.1-sol-reasoning",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6.1-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "6450817d8662 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "reasoning_effort": "medium",
+ "allowed_openai_params": ["reasoning_effort"],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion",
+ "created": 1791855452,
+ "model": "gpt-6.1-sol",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "scripted answer 6450817d8662",
+ "refusal": None,
+ "annotations": [],
+ },
+ "finish_reason": "stop",
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 1240,
+ "completion_tokens": 4040,
+ "total_tokens": 5280,
+ "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0, "audio_tokens": 0},
+ "completion_tokens_details": {
+ "reasoning_tokens": 3480,
+ "audio_tokens": 0,
+ "accepted_prediction_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ },
+ "service_tier": "default",
+ "system_fingerprint": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.04288, input_cost=0.00248, output_cost=0.0404, prompt_tokens=1240, completion_tokens=4040
+ ),
+)
+
+GPT_6_1_SOL_STREAM_NO_USAGE: Final = CostTrackingTestCase(
+ name="gpt-6.1-sol-stream_no_usage",
+ covers="quota_management.spend_tracking.scripted_wire.logs_cost",
+ model="gpt-6.1-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "8b76805f8920 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": True,
+ "allowed_openai_params": [],
+ },
+ response=SseResponse(
+ content_type="text/event-stream",
+ frames=sse_frames(
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6.1-sol",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [
+ {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None}
+ ],
+ "obfuscation": "5A3jk",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6.1-sol",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {"content": "scripted answer 8b76805f8920"}, "finish_reason": None}],
+ "obfuscation": "Q2x",
+ },
+ {
+ "id": "chatcmpl-$REQUEST_ID",
+ "object": "chat.completion.chunk",
+ "created": 1791855376,
+ "model": "gpt-6.1-sol",
+ "service_tier": "default",
+ "system_fingerprint": None,
+ "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}],
+ "obfuscation": "v37dpurTBq",
+ },
+ ),
+ ),
+ expected=RecountExpected(recount=RecountRates(input_cost_per_token=2e-06, output_cost_per_token=1e-05)),
+)
+
+GPT_6_SOL_UPSTREAM_404_ZERO_SPEND: Final = CostTrackingTestCase(
+ name="gpt-6-sol-upstream_404_zero_spend",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [{"role": "user", "content": "scripted upstream failure 404"}],
+ "stream": False,
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "error": {
+ "message": "The model `scripted-missing-model` does not exist or you do not have access to it.",
+ "type": "invalid_request_error",
+ "param": None,
+ "code": "model_not_found",
+ }
+ },
+ status=404,
+ ),
+ expected=FailureExpected(failure=FailureDetails(status=404)),
+)
+
+GPT_6_SOL_INPUT_TEXT_ROLLUPS: Final = CostTrackingTestCase(
+ name="gpt-6-sol-input_text_rollups",
+ covers="quota_management.spend_tracking.cost_matrix.logs_cost",
+ model="gpt-6-sol",
+ request={
+ "model": "$MODEL",
+ "messages": [
+ {
+ "role": "system",
+ "content": [
+ {
+ "type": "text",
+ "text": "You are a deterministic pricing-harness assistant. Keep answers to a single short line.",
+ }
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "0a5d8710e0d8 summarize the attached material in one line and name the city weather",
+ }
+ ],
+ },
+ ],
+ "stream": False,
+ "allowed_openai_params": [],
+ },
+ response=JsonResponse(
+ content_type="application/json",
+ body={
+ "id": "chatcmpl-$UNIQUE_ID",
+ "object": "chat.completion",
+ "created": 1791855452,
+ "model": "gpt-6-sol",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "scripted answer 0a5d8710e0d8",
+ "refusal": None,
+ "annotations": [],
+ },
+ "finish_reason": "stop",
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 1840,
+ "completion_tokens": 412,
+ "total_tokens": 2252,
+ "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0, "audio_tokens": 0},
+ "completion_tokens_details": {
+ "reasoning_tokens": 0,
+ "audio_tokens": 0,
+ "accepted_prediction_tokens": 0,
+ "rejected_prediction_tokens": 0,
+ },
+ },
+ "service_tier": "default",
+ "system_fingerprint": None,
+ },
+ ),
+ expected=ExactExpected(
+ spend=0.00858,
+ input_cost=0.004048,
+ output_cost=0.004532,
+ prompt_tokens=1840,
+ completion_tokens=412,
+ rollups=True,
+ ),
+)
+
+GPT_6_LUNA_MESSAGES_BRIDGED_JSON: Final = GPT_6_LUNA_RESPONSES_NATIVE_JSON.model_copy(
+ update={
+ "name": "gpt-6-luna-messages_bridged_json",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [{"role": "user", "content": "responses native fixture"}],
+ },
+ }
+)
+
+GPT_6_ASTRA_MESSAGES_BRIDGED_JSON: Final = GPT_6_ASTRA_RESPONSES_NATIVE_JSON.model_copy(
+ update={
+ "name": "gpt-6-astra-messages_bridged_json",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [{"role": "user", "content": "responses native fixture"}],
+ },
+ }
+)
+
+GPT_6_1_SOL_MESSAGES_BRIDGED_JSON: Final = GPT_6_1_SOL_RESPONSES_NATIVE_JSON.model_copy(
+ update={
+ "name": "gpt-6.1-sol-messages_bridged_json",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [{"role": "user", "content": "responses native fixture"}],
+ },
+ }
+)
+
+CASES: Final[tuple[CostTrackingTestCase, ...]] = (
+ GPT_5_3_CODEX_INPUT_TEXT,
+ GPT_5_3_CODEX_CACHE_READ,
+ GPT_5_3_CODEX_REASONING,
+ GPT_5_3_CODEX_SERVICE_TIER_FLEX,
+ GPT_5_3_CODEX_SERVICE_TIER_PRIORITY,
+ GPT_5_3_CODEX_WEB_SEARCH_MEDIUM,
+ GPT_5_3_CODEX_WEB_SEARCH_LOW,
+ GPT_5_3_CODEX_WEB_SEARCH_HIGH,
+ GPT_5_3_CODEX_FILE_SEARCH,
+ GPT_5_3_CODEX_STREAM,
+ GPT_5_3_CODEX_STREAM_NO_USAGE,
+ GPT_5_3_CODEX_STREAM_NO_USAGE_TOOL_CALL,
+ GPT_5_3_CODEX_STREAM_NO_USAGE_IMAGE_INPUT,
+ GPT_5_3_CODEX_STREAM_INCOMPLETE,
+ GPT_5_3_CODEX_STREAM_NO_USAGE_INCOMPLETE,
+ GPT_5_3_CODEX_STREAM_UNVALIDATED,
+ GPT_5_3_CODEX_STREAM_NO_USAGE_UNVALIDATED,
+ GPT_5_3_CODEX_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_3_CODEX_STREAM_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_3_CODEX_TOOL_CALL,
+ GPT_5_3_CODEX_STREAM_TOOL_CALL,
+ GPT_5_3_CODEX_STREAM_FULL_USAGE,
+ GPT_5_4_MINI_INPUT_TEXT,
+ GPT_5_4_MINI_CACHE_READ,
+ GPT_5_4_MINI_AUDIO_INPUT,
+ GPT_5_4_MINI_AUDIO_OUTPUT,
+ GPT_5_4_MINI_REASONING,
+ GPT_5_4_MINI_SERVICE_TIER_FLEX,
+ GPT_5_4_MINI_SERVICE_TIER_PRIORITY,
+ GPT_5_4_MINI_WEB_SEARCH_MEDIUM,
+ GPT_5_4_MINI_WEB_SEARCH_LOW,
+ GPT_5_4_MINI_WEB_SEARCH_HIGH,
+ GPT_5_4_MINI_STREAM,
+ GPT_5_4_MINI_STREAM_NO_USAGE,
+ GPT_5_4_MINI_STREAM_NO_USAGE_TOOL_CALL,
+ GPT_5_4_MINI_STREAM_NO_USAGE_IMAGE_INPUT,
+ GPT_5_4_MINI_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_4_MINI_STREAM_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_4_MINI_TOOL_CALL,
+ GPT_5_4_MINI_STREAM_TOOL_CALL,
+ GPT_5_4_MINI_STREAM_FULL_USAGE,
+ GPT_5_5_PRO_INPUT_TEXT,
+ GPT_5_5_PRO_CACHE_READ,
+ GPT_5_5_PRO_REASONING,
+ GPT_5_5_PRO_SERVICE_TIER_FLEX,
+ GPT_5_5_PRO_SERVICE_TIER_PRIORITY,
+ GPT_5_5_PRO_WEB_SEARCH_MEDIUM,
+ GPT_5_5_PRO_WEB_SEARCH_LOW,
+ GPT_5_5_PRO_WEB_SEARCH_HIGH,
+ GPT_5_5_PRO_FILE_SEARCH,
+ GPT_5_5_PRO_STREAM,
+ GPT_5_5_PRO_STREAM_NO_USAGE,
+ GPT_5_5_PRO_STREAM_NO_USAGE_TOOL_CALL,
+ GPT_5_5_PRO_STREAM_NO_USAGE_IMAGE_INPUT,
+ GPT_5_5_PRO_STREAM_INCOMPLETE,
+ GPT_5_5_PRO_STREAM_NO_USAGE_INCOMPLETE,
+ GPT_5_5_PRO_STREAM_UNVALIDATED,
+ GPT_5_5_PRO_STREAM_NO_USAGE_UNVALIDATED,
+ GPT_5_5_PRO_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_5_PRO_STREAM_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_5_PRO_TOOL_CALL,
+ GPT_5_5_PRO_STREAM_TOOL_CALL,
+ GPT_5_5_PRO_STREAM_FULL_USAGE,
+ GPT_5_6_INPUT_TEXT,
+ GPT_5_6_CACHE_READ,
+ GPT_5_6_AUDIO_INPUT,
+ GPT_5_6_AUDIO_OUTPUT,
+ GPT_5_6_REASONING,
+ GPT_5_6_SERVICE_TIER_FLEX,
+ GPT_5_6_SERVICE_TIER_PRIORITY,
+ GPT_5_6_WEB_SEARCH_MEDIUM,
+ GPT_5_6_WEB_SEARCH_LOW,
+ GPT_5_6_WEB_SEARCH_HIGH,
+ GPT_5_6_STREAM,
+ GPT_5_6_STREAM_NO_USAGE,
+ GPT_5_6_STREAM_NO_USAGE_TOOL_CALL,
+ GPT_5_6_STREAM_NO_USAGE_IMAGE_INPUT,
+ GPT_5_6_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_6_STREAM_RESPONSE_MODEL_OVERRIDE,
+ GPT_5_6_TOOL_CALL,
+ GPT_5_6_STREAM_TOOL_CALL,
+ GPT_5_6_STREAM_FULL_USAGE,
+ GPT_5_6_RESPONSES_NATIVE_JSON,
+ GPT_5_6_UPSTREAM_500_ZERO_SPEND,
+ GPT_5_6_UPSTREAM_429_ZERO_SPEND,
+ WHISPER_NEXT_TRANSCRIPTIONS_PER_SECOND,
+ WHISPER_VERBOSE_NEXT_TRANSCRIPTIONS_DURATION,
+ GPT_4O_TRANSCRIBE_NEXT_TRANSCRIPTIONS_TOKENS,
+ TTS_NEXT_SPEECH_PER_CHARACTER,
+ TTS_NEXT_HD_SPEECH_PER_CHARACTER,
+ DALL_E_3_NEXT_IMAGES_STANDARD,
+ DALL_E_3_NEXT_IMAGES_HD,
+ DALL_E_3_NEXT_IMAGES_WIDE,
+ DALL_E_3_NEXT_IMAGES_TWO,
+ GPT_IMAGE_NEXT_IMAGES_LOW,
+ GPT_IMAGE_NEXT_IMAGES_EDIT,
+ TEXT_EMBEDDINGS_4_SMALL_SINGLE,
+ TEXT_EMBEDDINGS_4_SMALL_BATCH,
+ TEXT_EMBEDDINGS_4_SMALL_TOKEN_ARRAY,
+ TEXT_EMBEDDINGS_3_LARGE_DIMENSIONS,
+ OMNI_MODERATIONS_NEXT_SINGLE,
+ OMNI_MODERATIONS_NEXT_LIST,
+ GPT_5_6_RESPONSES_CACHE_READ,
+ GPT_5_6_RESPONSES_REASONING,
+ GPT_5_6_RESPONSES_STREAM,
+ GPT_5_6_RESPONSES_STREAM_CACHE_READ,
+ GPT_5_6_RESPONSES_INCOMPLETE,
+ GPT_5_6_RESPONSES_PREVIOUS_RESPONSE_ID,
+ GPT_5_6_RESPONSES_WEB_SEARCH_MEDIUM,
+ GPT_5_6_RESPONSES_WEB_SEARCH_REPORTED_COUNT_MIXED_ACTIONS,
+ GPT_5_6_RESPONSES_WEB_SEARCH_REPORTED_COUNT_OPEN_PAGE_ONLY,
+ GPT_5_6_RESPONSES_WEB_SEARCH_REPORTED_COUNT_MIXED_ACTIONS_STREAM,
+ GPT_5_3_CODEX_RESPONSES_FILE_SEARCH,
+ GPT_5_6_RESPONSES_SERVICE_TIER_FLEX,
+ GPT_5_6_RESPONSES_SERVICE_TIER_PRIORITY,
+ OPENAI_DEPLOYMENT_PRICING_OVERRIDE,
+ OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER,
+ OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER_STREAM,
+ OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER_MESSAGES,
+ OPENAI_DEPLOYMENT_ZERO_PRICING_IGNORES_UPSTREAM_COST_HEADER_RESPONSES,
+ OPENAI_DEPLOYMENT_PRICING_IGNORES_UPSTREAM_COST_HEADER,
+ GPT_5_6_UPSTREAM_COST_HEADER_BILLS_HEADER_VALUE,
+ GPT_5_6_UPSTREAM_400_ZERO_SPEND,
+ GPT_5_6_UPSTREAM_401_ZERO_SPEND,
+ GPT_5_6_UPSTREAM_500_STREAM_REQUEST_ZERO_SPEND,
+ GPT_5_6_RESPONSES_UPSTREAM_500_ZERO_SPEND,
+ CLAUDE_SONNET_5_MESSAGES_UPSTREAM_500_ZERO_SPEND,
+ GPT_5_6_FALLBACK_BILLED_TO_ANSWERING_DEPLOYMENT,
+ GPT_5_6_N_2_CHOICES,
+ GPT_5_6_FINISH_REASON_LENGTH,
+ GPT_5_6_STREAM_USAGE_IN_EMPTY_CHOICES_CHUNK,
+ GPT_5_6_STREAM_USAGE_IN_LAST_DELTA_CHUNK,
+ GPT_5_6_UNKNOWN_MODEL_RESPONSE_MODEL_UNKNOWN,
+ GPT_5_6_UNKNOWN_MODEL_RESPONSE_MODEL_KNOWN,
+ GPT_5_6_CHAT_REQUEST_TO_EMBEDDING_ENTRY,
+ GPT_5_6_CLIENT_DISCONNECT_MID_STREAM,
+ GPT_6_1_SOL_INPUT_TEXT,
+ OPENAI_GPT_6_LUNA_DECISIONS,
+ OPENAI_GPT_6_LUNA_SYSTEMONE,
+ OPENAI_GPT_6_LUNA_DECISIONS_LONG_CONTEXT,
+ OPENAI_GPT_6_LUNA_SYSTEMONE_LONG_CONTEXT,
+ GPT_6_SOL_INPUT_TEXT,
+ GPT_6_SOL_STREAM,
+ GPT_6_SOL_SERVICE_TIER_FLEX,
+ GPT_6_SOL_SERVICE_TIER_PRIORITY,
+ GPT_6_SOL_RESPONSES_NATIVE_JSON,
+ GPT_6_LUNA_INPUT_TEXT,
+ GPT_6_LUNA_STREAM,
+ GPT_6_LUNA_SERVICE_TIER_FLEX,
+ GPT_6_LUNA_SERVICE_TIER_PRIORITY,
+ GPT_6_LUNA_RESPONSES_NATIVE_JSON,
+ GPT_6_ASTRA_INPUT_TEXT,
+ GPT_6_ASTRA_STREAM,
+ GPT_6_ASTRA_SERVICE_TIER_FLEX,
+ GPT_6_ASTRA_SERVICE_TIER_PRIORITY,
+ GPT_6_ASTRA_RESPONSES_NATIVE_JSON,
+ GPT_6_1_SOL_STREAM,
+ GPT_6_1_SOL_SERVICE_TIER_FLEX,
+ GPT_6_1_SOL_SERVICE_TIER_PRIORITY,
+ GPT_6_1_SOL_RESPONSES_NATIVE_JSON,
+ GPT_6_SOL_MESSAGES_BRIDGED_JSON,
+ GPT_6_SOL_TOOL_CALL,
+ GPT_6_SOL_REASONING,
+ GPT_6_SOL_STREAM_NO_USAGE,
+ GPT_6_LUNA_TOOL_CALL,
+ GPT_6_LUNA_REASONING,
+ GPT_6_LUNA_STREAM_NO_USAGE,
+ GPT_6_ASTRA_REASONING,
+ GPT_6_ASTRA_STREAM_NO_USAGE,
+ GPT_6_1_SOL_REASONING,
+ GPT_6_1_SOL_STREAM_NO_USAGE,
+ GPT_6_SOL_UPSTREAM_404_ZERO_SPEND,
+ GPT_6_SOL_INPUT_TEXT_ROLLUPS,
+)
+
+PARITY: Final[tuple[StreamParityTestCase, ...]] = (
StreamParityTestCase(plain=GPT_5_3_CODEX_INPUT_TEXT, streamed=GPT_5_3_CODEX_STREAM),
StreamParityTestCase(plain=GPT_5_3_CODEX_INPUT_TEXT, streamed=GPT_5_3_CODEX_STREAM_INCOMPLETE),
StreamParityTestCase(plain=GPT_5_3_CODEX_INPUT_TEXT, streamed=GPT_5_3_CODEX_STREAM_UNVALIDATED),
@@ -9833,3 +10747,10 @@ PARITY: Final[tuple[StreamParityTestCase, ...]] = (
StreamParityTestCase(plain=GPT_6_ASTRA_INPUT_TEXT, streamed=GPT_6_ASTRA_STREAM),
StreamParityTestCase(plain=GPT_6_1_SOL_INPUT_TEXT, streamed=GPT_6_1_SOL_STREAM),
)
+
+BRIDGE_COST_PARITY: Final[tuple[BridgeCostParityTestCase, ...]] = (
+ BridgeCostParityTestCase(native=GPT_6_SOL_RESPONSES_NATIVE_JSON, bridged=GPT_6_SOL_MESSAGES_BRIDGED_JSON),
+ BridgeCostParityTestCase(native=GPT_6_LUNA_RESPONSES_NATIVE_JSON, bridged=GPT_6_LUNA_MESSAGES_BRIDGED_JSON),
+ BridgeCostParityTestCase(native=GPT_6_ASTRA_RESPONSES_NATIVE_JSON, bridged=GPT_6_ASTRA_MESSAGES_BRIDGED_JSON),
+ BridgeCostParityTestCase(native=GPT_6_1_SOL_RESPONSES_NATIVE_JSON, bridged=GPT_6_1_SOL_MESSAGES_BRIDGED_JSON),
+)
diff --git a/tests/integration/cost_calculation/catalog.py b/tests/integration/cost_calculation/catalog.py
index 2710de5e5ea..e83ba186cb2 100644
--- a/tests/integration/cost_calculation/catalog.py
+++ b/tests/integration/cost_calculation/catalog.py
@@ -30,6 +30,7 @@ from integration.cost_calculation.cost_tracking_case import (
RecountExpected,
SseResponse,
)
+from integration.cost_calculation.bridge_cost_parity.case import BridgeCostParityTestCase
from integration.cost_calculation.stream_parity.case import StreamParityTestCase
_PROVIDER_MODULES: Final = (
@@ -50,7 +51,10 @@ PARITY_CASES: Final[tuple[StreamParityTestCase, ...]] = tuple(
)
BATCH_CASES: Final[tuple[BatchCostCase, ...]] = batch_realtime.BATCH_CASES
REALTIME_CASES: Final[tuple[RealtimeCostCase, ...]] = batch_realtime.REALTIME_CASES
-_PARITY_LEGS: Final = frozenset(leg.name for pair in PARITY_CASES for leg in (pair.plain, pair.streamed))
+BRIDGE_COST_PARITY_CASES: Final[tuple[BridgeCostParityTestCase, ...]] = openai.BRIDGE_COST_PARITY
+_PARITY_LEGS: Final = frozenset(leg.name for pair in PARITY_CASES for leg in (pair.plain, pair.streamed)) | frozenset(
+ leg.name for pair in BRIDGE_COST_PARITY_CASES for leg in (pair.native, pair.bridged)
+)
STANDALONE_CASES: Final[tuple[CostTrackingTestCase, ...]] = tuple(
case for case in CASES if case.name not in _PARITY_LEGS
)
diff --git a/tests/integration/cost_calculation/conftest.py b/tests/integration/cost_calculation/conftest.py
index 9bac5cbdcef..574d8aaf9af 100644
--- a/tests/integration/cost_calculation/conftest.py
+++ b/tests/integration/cost_calculation/conftest.py
@@ -86,10 +86,7 @@ def approx_equal(actual: float, expected: float) -> bool:
def assert_total_is_sum_of_components(row: CostRow, breakdown: CostBreakdown, context: str) -> None:
- total: Final = sum(
- cost or 0.0
- for cost in (breakdown.input_cost, breakdown.output_cost, breakdown.tool_usage_cost)
- )
+ total: Final = sum(cost or 0.0 for cost in (breakdown.input_cost, breakdown.output_cost, breakdown.tool_usage_cost))
assert breakdown.total_cost is not None and approx_equal(breakdown.total_cost, total), (
f"{context}: total_cost {breakdown.total_cost} != input_cost {breakdown.input_cost} "
f"+ output_cost {breakdown.output_cost} + tool_usage_cost {breakdown.tool_usage_cost} "
@@ -112,7 +109,7 @@ def poll_cost_row(key: str) -> CostRow:
def read() -> CostRow | None:
rows: Final = read_rows(
- 'SELECT spend, status, metadata, prompt_tokens, completion_tokens, model_id, call_type '
+ "SELECT spend, status, metadata, prompt_tokens, completion_tokens, model_id, call_type "
'FROM "LiteLLM_SpendLogs" WHERE api_key=%s',
(digest,),
)
@@ -126,7 +123,7 @@ def poll_cost_row(key: str) -> CostRow:
def read_rows_now(key: str) -> tuple[CostRow, ...]:
digest: Final = sha256(key.encode()).hexdigest()
rows: Final = read_rows(
- 'SELECT spend, status, metadata, prompt_tokens, completion_tokens, model_id, call_type '
+ "SELECT spend, status, metadata, prompt_tokens, completion_tokens, model_id, call_type "
'FROM "LiteLLM_SpendLogs" WHERE api_key=%s ORDER BY "startTime"',
(digest,),
)
@@ -178,12 +175,12 @@ def poll_rollups(
(end_user_id,),
)
daily_user_rows: Final = read_rows(
- 'SELECT spend, prompt_tokens, completion_tokens, api_requests '
+ "SELECT spend, prompt_tokens, completion_tokens, api_requests "
'FROM "LiteLLM_DailyUserSpend" WHERE user_id=%s AND api_key=%s AND date=CURRENT_DATE::text',
(user_id, digest),
)
daily_team_rows: Final = read_rows(
- 'SELECT spend, prompt_tokens, completion_tokens, api_requests '
+ "SELECT spend, prompt_tokens, completion_tokens, api_requests "
'FROM "LiteLLM_DailyTeamSpend" WHERE team_id=%s AND api_key=%s AND date=CURRENT_DATE::text',
(team_id, digest),
)
@@ -232,11 +229,7 @@ def poll_failure_row(key: str) -> FailureRow:
(digest,),
)
return next(
- (
- parsed
- for row in rows
- if (parsed := FailureRow.model_validate(row)).status == "failure"
- ),
+ (parsed for row in rows if (parsed := FailureRow.model_validate(row)).status == "failure"),
None,
)
@@ -247,11 +240,15 @@ def poll_failure_row(key: str) -> FailureRow:
@functools.cache
def _vertex_private_key_pem() -> str:
- return rsa.generate_private_key(public_exponent=65537, key_size=2048).private_bytes(
- serialization.Encoding.PEM,
- serialization.PrivateFormat.PKCS8,
- serialization.NoEncryption(),
- ).decode()
+ return (
+ rsa.generate_private_key(public_exponent=65537, key_size=2048)
+ .private_bytes(
+ serialization.Encoding.PEM,
+ serialization.PrivateFormat.PKCS8,
+ serialization.NoEncryption(),
+ )
+ .decode()
+ )
def _vertex_service_account_json(url: str) -> str:
@@ -329,15 +326,13 @@ def register_scenario_deployment(
}
created: Final = scenario.gateway.post(
"/model/new",
- JSON_OBJECT.validate_python({
- "model_name": registered_model_name,
- "litellm_params": parameters,
- "model_info": (
- {"base_model": case.base_model}
- if case.base_model is not None
- else {}
- ),
- }),
+ JSON_OBJECT.validate_python(
+ {
+ "model_name": registered_model_name,
+ "litellm_params": parameters,
+ "model_info": ({"base_model": case.base_model} if case.base_model is not None else {}),
+ }
+ ),
)
identity: Final = string_value(object_value(created["model_info"])["id"])
scenario.cleanups.callback(scenario.delete_model, identity)
diff --git a/tests/integration/cost_calculation/cost_map.py b/tests/integration/cost_calculation/cost_map.py
index 5e211d25a94..ac51f96a0ec 100644
--- a/tests/integration/cost_calculation/cost_map.py
+++ b/tests/integration/cost_calculation/cost_map.py
@@ -1011,6 +1011,7 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = {
"output_cost_per_token_flex": 5.75e-06,
"output_cost_per_token_priority": 2.3e-05,
"supports_function_calling": True,
+ "supports_none_reasoning_effort": True,
},
"azure/gpt-6-luna": {
"cache_read_input_token_cost": 1.3e-08,
@@ -1026,6 +1027,7 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = {
"output_cost_per_token_flex": 3.25e-07,
"output_cost_per_token_priority": 1.3e-06,
"supports_function_calling": True,
+ "supports_none_reasoning_effort": True,
},
"azure/gpt-6-astra": {
"cache_read_input_token_cost": 1.25e-06,
@@ -1041,6 +1043,7 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = {
"output_cost_per_token_flex": 3.125e-05,
"output_cost_per_token_priority": 0.000125,
"supports_function_calling": True,
+ "supports_none_reasoning_effort": True,
},
"azure/gpt-6.1-sol": {
"cache_read_input_token_cost": 2.4e-07,
@@ -1056,5 +1059,6 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = {
"output_cost_per_token_flex": 6e-06,
"output_cost_per_token_priority": 2.4e-05,
"supports_function_calling": True,
+ "supports_none_reasoning_effort": True,
},
}
diff --git a/tests/integration/cost_calculation/cost_tracking_case.py b/tests/integration/cost_calculation/cost_tracking_case.py
index 4990ef2a5e4..714c2bf3730 100644
--- a/tests/integration/cost_calculation/cost_tracking_case.py
+++ b/tests/integration/cost_calculation/cost_tracking_case.py
@@ -43,6 +43,7 @@ class CostMapEntry(BaseModel):
max_input_tokens: int | None = None
max_output_tokens: int | None = None
supports_function_calling: bool | None = None
+ supports_none_reasoning_effort: bool | None = None
input_cost_per_token: float | None = None
input_cost_per_token_decisions: float | None = None
input_cost_per_query: float | None = None
diff --git a/tests/integration/cost_calculation/stream_parity/runner.py b/tests/integration/cost_calculation/stream_parity/runner.py
index 17ce7058c14..044e082e6d0 100644
--- a/tests/integration/cost_calculation/stream_parity/runner.py
+++ b/tests/integration/cost_calculation/stream_parity/runner.py
@@ -1,16 +1,19 @@
from collections import Counter
+from collections.abc import Mapping
from hashlib import sha256
+from types import MappingProxyType
from typing import Final
from integration._support.client import Gateway, Scenario
from integration.cost_calculation.assertions import assert_exact
from integration.cost_calculation.conftest import (
+ CostRow,
poll_rows,
poll_rows_where,
read_rows_now,
register_scenario_deployment,
)
-from integration.cost_calculation.cost_tracking_case import ExactExpected
+from integration.cost_calculation.cost_tracking_case import CostTrackingTestCase, ExactExpected
from integration.cost_calculation.stream_parity.bases import openai_responses
from integration.cost_calculation.stream_parity.case import StreamParityTestCase
@@ -28,43 +31,49 @@ def flush_spend_logs(scenario: Scenario, gateway: Gateway, key: str) -> str:
return flush.identity
-def assert_stream_parity(case: StreamParityTestCase, gateway: Gateway) -> None:
- expected: Final = case.plain.expected
- assert isinstance(expected, ExactExpected), case.id
+def bill_legs(case_id: str, legs: tuple[CostTrackingTestCase, ...], gateway: Gateway) -> Mapping[str, CostRow]:
+ """Send every leg through one key, wait for exactly one SpendLogs row per leg, and check each row against its leg's
+ expected row."""
with gateway.scenario() as scenario:
key: Final = scenario.key()
deployments: Final = {
leg.name: register_scenario_deployment(scenario, leg, sha256(leg.name.encode()).hexdigest()[:12], key)
- for leg in (case.plain, case.streamed)
+ for leg in legs
}
responses: Final = {
leg.name: gateway.request(
"POST", leg.endpoint, {**leg.request, "model": deployments[leg.name].model_name}, key=key
)
- for leg in (case.plain, case.streamed)
+ for leg in legs
}
- for leg in (case.plain, case.streamed):
+ for leg in legs:
assert responses[leg.name].status_code == 200, (leg.name, responses[leg.name].text[:400])
- poll_rows(key, 2)
+ poll_rows(key, len(legs))
flush_identity: Final = flush_spend_logs(scenario, gateway, key)
rows: Final = read_rows_now(key)
rows_per_deployment: Final = Counter(row.model_id for row in rows)
- expected_rows: Final = {deployments[leg.name].identity: 1 for leg in (case.plain, case.streamed)}
+ expected_rows: Final = {deployments[leg.name].identity: 1 for leg in legs}
assert rows_per_deployment == {**expected_rows, flush_identity: 1}, (
- f"{case.id}: expected exactly one SpendLogs row per leg plus the flush row, got {dict(rows_per_deployment)}",
+ f"{case_id}: expected exactly one SpendLogs row per leg plus the flush row, got {dict(rows_per_deployment)}",
rows,
)
billed: Final = {
- leg.name: next(row for row in rows if row.model_id == deployments[leg.name].identity)
- for leg in (case.plain, case.streamed)
+ leg.name: next(row for row in rows if row.model_id == deployments[leg.name].identity) for leg in legs
}
- for leg in (case.plain, case.streamed):
+ for leg in legs:
+ expected: Final = leg.expected
+ assert isinstance(expected, ExactExpected), leg.name
assert_exact(leg.name, leg.response.content_type, expected, billed[leg.name], responses[leg.name])
- plain: Final = billed[case.plain.name]
- streamed: Final = billed[case.streamed.name]
- assert (streamed.spend, streamed.prompt_tokens, streamed.completion_tokens) == (
- plain.spend,
- plain.prompt_tokens,
- plain.completion_tokens,
- ), (plain, streamed)
+ return MappingProxyType(billed)
+
+
+def assert_stream_parity(case: StreamParityTestCase, gateway: Gateway) -> None:
+ billed: Final = bill_legs(case.id, (case.plain, case.streamed), gateway)
+ plain: Final = billed[case.plain.name]
+ streamed: Final = billed[case.streamed.name]
+ assert (streamed.spend, streamed.prompt_tokens, streamed.completion_tokens) == (
+ plain.spend,
+ plain.prompt_tokens,
+ plain.completion_tokens,
+ ), (plain, streamed)