diff --git a/tests/integration/cost_calculation/cases/anthropic.py b/tests/integration/cost_calculation/cases/anthropic.py index 3b70ee1e8c5..c0d10c274bb 100644 --- a/tests/integration/cost_calculation/cases/anthropic.py +++ b/tests/integration/cost_calculation/cases/anthropic.py @@ -4067,6 +4067,1762 @@ CLAUDE_OPUS_5_5_INPUT_TEXT: Final = CostTrackingTestCase( ) +CLAUDE_SONNET_5_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-sonnet-5-5-input_text", + 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": "d5078ef4d4ba 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-sonnet-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer d5078ef4d4ba"}], + "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.01287, input_cost=0.006072, output_cost=0.006798, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_SONNET_5_5_STREAM: Final = CostTrackingTestCase( + name="claude-sonnet-5-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "a648e59362e1 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "type": "message_start", + "message": { + "model": "claude-sonnet-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [], + "container": None, + "stop_reason": None, + "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": 1, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + }, + {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}, + {"type": "ping"}, + { + "type": "content_block_delta", + "index": 0, + "delta": {"type": "text_delta", "text": "scripted answer a648e59362e1"}, + }, + {"type": "content_block_stop", "index": 0}, + { + "type": "message_delta", + "delta": {"stop_reason": "end_turn", "stop_sequence": None, "stop_details": None, "container": None}, + "usage": { + "input_tokens": 1840, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 0, + "output_tokens": 412, + "output_tokens_details": {"thinking_tokens": 0}, + }, + }, + {"type": "message_stop"}, + ), + ), + expected=ExactExpected( + spend=0.01287, input_cost=0.006072, output_cost=0.006798, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_SONNET_5_5_CACHE_READ: Final = CostTrackingTestCase( + name="claude-sonnet-5-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "d07bcc773205 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-sonnet-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer d07bcc773205"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 640, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 12288, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 380, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.01243704, input_cost=0.00616704, output_cost=0.00627, prompt_tokens=12928, completion_tokens=380 + ), +) + +CLAUDE_SONNET_5_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="claude-sonnet-5-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "f163bea2f9c0 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-sonnet-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer f163bea2f9c0"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 9216, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.0454806, input_cost=0.0397056, output_cost=0.005775, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_SONNET_5_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="claude-sonnet-5-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "c42d91d3c8cb 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-sonnet-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer c42d91d3c8cb"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 9216}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.0682902, input_cost=0.0625152, output_cost=0.005775, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_SONNET_5_5_MESSAGES_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-sonnet-5-5-messages_input_text", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="claude-sonnet-5-5", + endpoint="/v1/messages", + request={ + "model": "$MODEL", + "max_tokens": 412, + "messages": [{"role": "user", "content": "summarize the attached material in one line"}], + }, + 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 response"}], + "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.01287, input_cost=0.006072, output_cost=0.006798, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_HAIKU_5_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-haiku-5-5-input_text", + 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": "10673f3a1db3 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-haiku-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 10673f3a1db3"}], + "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.00429, input_cost=0.002024, output_cost=0.002266, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_HAIKU_5_5_STREAM: Final = CostTrackingTestCase( + name="claude-haiku-5-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "2bf9bcba4444 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "type": "message_start", + "message": { + "model": "claude-haiku-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [], + "container": None, + "stop_reason": None, + "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": 1, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + }, + {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}, + {"type": "ping"}, + { + "type": "content_block_delta", + "index": 0, + "delta": {"type": "text_delta", "text": "scripted answer 2bf9bcba4444"}, + }, + {"type": "content_block_stop", "index": 0}, + { + "type": "message_delta", + "delta": {"stop_reason": "end_turn", "stop_sequence": None, "stop_details": None, "container": None}, + "usage": { + "input_tokens": 1840, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 0, + "output_tokens": 412, + "output_tokens_details": {"thinking_tokens": 0}, + }, + }, + {"type": "message_stop"}, + ), + ), + expected=ExactExpected( + spend=0.00429, input_cost=0.002024, output_cost=0.002266, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_HAIKU_5_5_CACHE_READ: Final = CostTrackingTestCase( + name="claude-haiku-5-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "65dcddea7db0 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-haiku-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 65dcddea7db0"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 640, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 12288, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 380, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.00414568, input_cost=0.00205568, output_cost=0.00209, prompt_tokens=12928, completion_tokens=380 + ), +) + +CLAUDE_HAIKU_5_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="claude-haiku-5-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "92ac58b8c6ad 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-haiku-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 92ac58b8c6ad"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 9216, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.0151602, input_cost=0.0132352, output_cost=0.001925, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_HAIKU_5_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="claude-haiku-5-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "3ae40172e262 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-haiku-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 3ae40172e262"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 9216}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.0227634, input_cost=0.0208384, output_cost=0.001925, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_HAIKU_5_5_MESSAGES_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-haiku-5-5-messages_input_text", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="claude-haiku-5-5", + endpoint="/v1/messages", + request={ + "model": "$MODEL", + "max_tokens": 412, + "messages": [{"role": "user", "content": "summarize the attached material in one line"}], + }, + response=JsonResponse( + content_type="application/json", + body={ + "model": "claude-haiku-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted response"}], + "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.00429, input_cost=0.002024, output_cost=0.002266, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_FABLE_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-fable-5-input_text", + 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": "5a2c19b20bee 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-fable-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 5a2c19b20bee"}], + "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.0585, input_cost=0.0276, output_cost=0.0309, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_FABLE_5_STREAM: Final = CostTrackingTestCase( + name="claude-fable-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "6c3adfe9ff6d summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "type": "message_start", + "message": { + "model": "claude-fable-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [], + "container": None, + "stop_reason": None, + "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": 1, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + }, + {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}, + {"type": "ping"}, + { + "type": "content_block_delta", + "index": 0, + "delta": {"type": "text_delta", "text": "scripted answer 6c3adfe9ff6d"}, + }, + {"type": "content_block_stop", "index": 0}, + { + "type": "message_delta", + "delta": {"stop_reason": "end_turn", "stop_sequence": None, "stop_details": None, "container": None}, + "usage": { + "input_tokens": 1840, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 0, + "output_tokens": 412, + "output_tokens_details": {"thinking_tokens": 0}, + }, + }, + {"type": "message_stop"}, + ), + ), + expected=ExactExpected( + spend=0.0585, input_cost=0.0276, output_cost=0.0309, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_FABLE_5_CACHE_READ: Final = CostTrackingTestCase( + name="claude-fable-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "b928021ea8bb 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-fable-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer b928021ea8bb"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 640, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 12288, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 380, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.056532, input_cost=0.028032, output_cost=0.0285, prompt_tokens=12928, completion_tokens=380 + ), +) + +CLAUDE_FABLE_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="claude-fable-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "fd1ed16af5ca 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-fable-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer fd1ed16af5ca"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 9216, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.20673, input_cost=0.18048, output_cost=0.02625, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_FABLE_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="claude-fable-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "c373b13470db 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-fable-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer c373b13470db"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 9216}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.31041, input_cost=0.28416, output_cost=0.02625, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_FABLE_5_MESSAGES_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-fable-5-messages_input_text", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="claude-fable-5", + endpoint="/v1/messages", + request={ + "model": "$MODEL", + "max_tokens": 412, + "messages": [{"role": "user", "content": "summarize the attached material in one line"}], + }, + response=JsonResponse( + content_type="application/json", + body={ + "model": "claude-fable-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted response"}], + "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.0585, input_cost=0.0276, output_cost=0.0309, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_FABLE_5_1_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-fable-5-1-input_text", + 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": "75b71184a26d 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-fable-5-1", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 75b71184a26d"}], + "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.0624, input_cost=0.02944, output_cost=0.03296, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_FABLE_5_1_STREAM: Final = CostTrackingTestCase( + name="claude-fable-5-1-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "3d584fa07ae1 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "type": "message_start", + "message": { + "model": "claude-fable-5-1", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [], + "container": None, + "stop_reason": None, + "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": 1, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + }, + {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}, + {"type": "ping"}, + { + "type": "content_block_delta", + "index": 0, + "delta": {"type": "text_delta", "text": "scripted answer 3d584fa07ae1"}, + }, + {"type": "content_block_stop", "index": 0}, + { + "type": "message_delta", + "delta": {"stop_reason": "end_turn", "stop_sequence": None, "stop_details": None, "container": None}, + "usage": { + "input_tokens": 1840, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 0, + "output_tokens": 412, + "output_tokens_details": {"thinking_tokens": 0}, + }, + }, + {"type": "message_stop"}, + ), + ), + expected=ExactExpected( + spend=0.0624, input_cost=0.02944, output_cost=0.03296, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_FABLE_5_1_CACHE_READ: Final = CostTrackingTestCase( + name="claude-fable-5-1-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "e2c093f0a554 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-fable-5-1", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer e2c093f0a554"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 640, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 12288, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 380, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.0603008, input_cost=0.0299008, output_cost=0.0304, prompt_tokens=12928, completion_tokens=380 + ), +) + +CLAUDE_FABLE_5_1_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="claude-fable-5-1-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "c074c3c72a7d 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-fable-5-1", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer c074c3c72a7d"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 9216, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.220512, input_cost=0.192512, output_cost=0.028, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_FABLE_5_1_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="claude-fable-5-1-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "feab5bd43ecd 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-fable-5-1", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer feab5bd43ecd"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 9216}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.331104, input_cost=0.303104, output_cost=0.028, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_FABLE_5_1_MESSAGES_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-fable-5-1-messages_input_text", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="claude-fable-5-1", + endpoint="/v1/messages", + request={ + "model": "$MODEL", + "max_tokens": 412, + "messages": [{"role": "user", "content": "summarize the attached material in one line"}], + }, + 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 response"}], + "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.0624, input_cost=0.02944, output_cost=0.03296, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_OPUS_5_5_STREAM: Final = CostTrackingTestCase( + name="claude-opus-5-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "9d9d47a4b07a summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "type": "message_start", + "message": { + "model": "claude-opus-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [], + "container": None, + "stop_reason": None, + "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": 1, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + }, + {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}, + {"type": "ping"}, + { + "type": "content_block_delta", + "index": 0, + "delta": {"type": "text_delta", "text": "scripted answer 9d9d47a4b07a"}, + }, + {"type": "content_block_stop", "index": 0}, + { + "type": "message_delta", + "delta": {"stop_reason": "end_turn", "stop_sequence": None, "stop_details": None, "container": None}, + "usage": { + "input_tokens": 1840, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 0, + "output_tokens": 412, + "output_tokens_details": {"thinking_tokens": 0}, + }, + }, + {"type": "message_stop"}, + ), + ), + expected=ExactExpected( + spend=0.0156, input_cost=0.00736, output_cost=0.00824, prompt_tokens=1840, completion_tokens=412 + ), +) + +CLAUDE_OPUS_5_5_CACHE_READ: Final = CostTrackingTestCase( + name="claude-opus-5-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "6c9f4bd8c5cb 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_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 6c9f4bd8c5cb"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 640, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 12288, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 380, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.0126176, input_cost=0.0050176, output_cost=0.0076, prompt_tokens=12928, completion_tokens=380 + ), +) + +CLAUDE_OPUS_5_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="claude-opus-5-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "e0df66e44e28 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_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer e0df66e44e28"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 9216, "ephemeral_1h_input_tokens": 0}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.055128, input_cost=0.048128, output_cost=0.007, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_OPUS_5_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="claude-opus-5-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "458ab0cbfb35 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_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted answer 458ab0cbfb35"}], + "container": None, + "stop_reason": "end_turn", + "stop_sequence": None, + "stop_details": None, + "usage": { + "input_tokens": 512, + "cache_creation_input_tokens": 9216, + "cache_read_input_tokens": 0, + "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 9216}, + "output_tokens": 350, + "output_tokens_details": {"thinking_tokens": 0}, + "service_tier": "standard", + "inference_geo": "global", + }, + "diagnostics": None, + }, + ), + expected=ExactExpected( + spend=0.082776, input_cost=0.075776, output_cost=0.007, prompt_tokens=9728, completion_tokens=350 + ), +) + +CLAUDE_OPUS_5_5_MESSAGES_INPUT_TEXT: Final = CostTrackingTestCase( + name="claude-opus-5-5-messages_input_text", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="claude-opus-5-5", + endpoint="/v1/messages", + request={ + "model": "$MODEL", + "max_tokens": 412, + "messages": [{"role": "user", "content": "summarize the attached material in one line"}], + }, + response=JsonResponse( + content_type="application/json", + body={ + "model": "claude-opus-5-5", + "id": "msg_$REQUEST_ID", + "type": "message", + "role": "assistant", + "content": [{"type": "text", "text": "scripted response"}], + "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 + ), +) + CASES: Final[tuple[CostTrackingTestCase, ...]] = ( CLAUDE_HAIKU_4_5_INPUT_TEXT, CLAUDE_HAIKU_4_5_CACHE_READ, @@ -4141,6 +5897,35 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = ( CLAUDE_SONNET_5_PASSTHROUGH_MESSAGES_CACHE_READ, CLAUDE_SONNET_5_CACHE_CREATION_1H_ABOVE_200K, CLAUDE_OPUS_5_5_INPUT_TEXT, + CLAUDE_SONNET_5_5_INPUT_TEXT, + CLAUDE_SONNET_5_5_STREAM, + CLAUDE_SONNET_5_5_CACHE_READ, + CLAUDE_SONNET_5_5_CACHE_WRITE_5M, + CLAUDE_SONNET_5_5_CACHE_WRITE_1H, + CLAUDE_SONNET_5_5_MESSAGES_INPUT_TEXT, + CLAUDE_HAIKU_5_5_INPUT_TEXT, + CLAUDE_HAIKU_5_5_STREAM, + CLAUDE_HAIKU_5_5_CACHE_READ, + CLAUDE_HAIKU_5_5_CACHE_WRITE_5M, + CLAUDE_HAIKU_5_5_CACHE_WRITE_1H, + CLAUDE_HAIKU_5_5_MESSAGES_INPUT_TEXT, + CLAUDE_FABLE_5_INPUT_TEXT, + CLAUDE_FABLE_5_STREAM, + CLAUDE_FABLE_5_CACHE_READ, + CLAUDE_FABLE_5_CACHE_WRITE_5M, + CLAUDE_FABLE_5_CACHE_WRITE_1H, + CLAUDE_FABLE_5_MESSAGES_INPUT_TEXT, + CLAUDE_FABLE_5_1_INPUT_TEXT, + CLAUDE_FABLE_5_1_STREAM, + CLAUDE_FABLE_5_1_CACHE_READ, + CLAUDE_FABLE_5_1_CACHE_WRITE_5M, + CLAUDE_FABLE_5_1_CACHE_WRITE_1H, + CLAUDE_FABLE_5_1_MESSAGES_INPUT_TEXT, + CLAUDE_OPUS_5_5_STREAM, + CLAUDE_OPUS_5_5_CACHE_READ, + CLAUDE_OPUS_5_5_CACHE_WRITE_5M, + CLAUDE_OPUS_5_5_CACHE_WRITE_1H, + CLAUDE_OPUS_5_5_MESSAGES_INPUT_TEXT, ) PARITY: Final[tuple[StreamParityTestCase, ...]] = ( @@ -4162,4 +5947,9 @@ PARITY: Final[tuple[StreamParityTestCase, ...]] = ( ), StreamParityTestCase(plain=CLAUDE_SONNET_5_TOOL_CALL, streamed=CLAUDE_SONNET_5_STREAM_TOOL_CALL), StreamParityTestCase(plain=CLAUDE_SONNET_5_MESSAGES_INPUT_TEXT, streamed=CLAUDE_SONNET_5_MESSAGES_STREAM), + StreamParityTestCase(plain=CLAUDE_SONNET_5_5_INPUT_TEXT, streamed=CLAUDE_SONNET_5_5_STREAM), + StreamParityTestCase(plain=CLAUDE_HAIKU_5_5_INPUT_TEXT, streamed=CLAUDE_HAIKU_5_5_STREAM), + StreamParityTestCase(plain=CLAUDE_FABLE_5_INPUT_TEXT, streamed=CLAUDE_FABLE_5_STREAM), + StreamParityTestCase(plain=CLAUDE_FABLE_5_1_INPUT_TEXT, streamed=CLAUDE_FABLE_5_1_STREAM), + StreamParityTestCase(plain=CLAUDE_OPUS_5_5_INPUT_TEXT, streamed=CLAUDE_OPUS_5_5_STREAM), ) diff --git a/tests/integration/cost_calculation/cases/azure.py b/tests/integration/cost_calculation/cases/azure.py index 1285dcf98da..6c3aaa0c673 100644 --- a/tests/integration/cost_calculation/cases/azure.py +++ b/tests/integration/cost_calculation/cases/azure.py @@ -2988,6 +2988,1543 @@ AZURE_TEXT_EMBEDDINGS_4_LARGE_DEPLOYMENT: Final = CostTrackingTestCase( ) +_GPT_6_CONTENT_FILTER_RESULTS: Final = { + "hate": {"filtered": False, "severity": "safe"}, + "protected_material_code": {"detected": False, "filtered": False}, + "protected_material_text": {"detected": False, "filtered": False}, + "self_harm": {"filtered": False, "severity": "safe"}, + "sexual": {"filtered": False, "severity": "safe"}, + "violence": {"filtered": False, "severity": "safe"}, +} +_GPT_6_PROMPT_FILTER_RESULTS: Final = [ + { + "prompt_index": 0, + "content_filter_results": { + "hate": {"filtered": False, "severity": "safe"}, + "jailbreak": {"detected": False, "filtered": False}, + "self_harm": {"filtered": False, "severity": "safe"}, + "sexual": {"filtered": False, "severity": "safe"}, + "violence": {"filtered": False, "severity": "safe"}, + }, + } +] + +AZURE_GPT_6_SOL_INPUT_TEXT: Final = CostTrackingTestCase( + name="azure-gpt-6-sol-input_text", + 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": "f77f71b0428a 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 f77f71b0428a", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "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_SOL_STREAM: Final = CostTrackingTestCase( + name="azure-gpt-6-sol-stream", + 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": "bf171da6c983 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": 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": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-sol-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + { + "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}}, + "delta": {"content": "scripted answer bf171da6c983"}, + "finish_reason": None, + "index": 0, + "logprobs": None, + } + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-sol-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None} + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-sol-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-sol-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r11-dp0-prefill"}, + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "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_SOL_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="azure-gpt-6-sol-service_tier_flex", + 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": "54651d96d231 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "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 54651d96d231", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-dp0-prefill"}, + "service_tier": "flex", + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.004485, input_cost=0.002116, output_cost=0.002369, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_SOL_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="azure-gpt-6-sol-service_tier_priority", + 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": "6add01b22373 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "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 6add01b22373", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-dp0-prefill"}, + "service_tier": "priority", + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.01794, input_cost=0.008464, output_cost=0.009476, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_LUNA_INPUT_TEXT: Final = CostTrackingTestCase( + name="azure-gpt-6-luna-input_text", + 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": "a6a8b0e9d64c 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 a6a8b0e9d64c", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "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 + ), +) + +AZURE_GPT_6_LUNA_STREAM: Final = CostTrackingTestCase( + name="azure-gpt-6-luna-stream", + 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": "b22d4ad4da33 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": 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": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-luna-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + { + "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}}, + "delta": {"content": "scripted answer b22d4ad4da33"}, + "finish_reason": None, + "index": 0, + "logprobs": None, + } + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-luna-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None} + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-luna-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-luna-2026-09-22", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r11-dp0-prefill"}, + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "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 + ), +) + +AZURE_GPT_6_LUNA_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="azure-gpt-6-luna-service_tier_flex", + 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": "895f84528ea4 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "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 895f84528ea4", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-dp0-prefill"}, + "service_tier": "flex", + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.0002535, input_cost=0.0001196, output_cost=0.0001339, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_LUNA_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="azure-gpt-6-luna-service_tier_priority", + 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": "705c026752fc summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "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 705c026752fc", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "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 + ), +) + +AZURE_GPT_6_ASTRA_INPUT_TEXT: Final = CostTrackingTestCase( + name="azure-gpt-6-astra-input_text", + 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": "41ccdf63f9d7 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 41ccdf63f9d7", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.04875, input_cost=0.023, output_cost=0.02575, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_ASTRA_STREAM: Final = CostTrackingTestCase( + name="azure-gpt-6-astra-stream", + 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": "480ff10f91fb summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": 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": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-astra-2026-09-03", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + { + "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}}, + "delta": {"content": "scripted answer 480ff10f91fb"}, + "finish_reason": None, + "index": 0, + "logprobs": None, + } + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-astra-2026-09-03", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None} + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-astra-2026-09-03", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6-astra-2026-09-03", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r11-dp0-prefill"}, + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + ), + expected=ExactExpected( + spend=0.04875, input_cost=0.023, output_cost=0.02575, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_ASTRA_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="azure-gpt-6-astra-service_tier_flex", + 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": "6ff9027e3f7f summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "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 6ff9027e3f7f", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-dp0-prefill"}, + "service_tier": "flex", + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.024375, input_cost=0.0115, output_cost=0.012875, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_ASTRA_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="azure-gpt-6-astra-service_tier_priority", + 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": "9a0c038a2ad8 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "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 9a0c038a2ad8", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.04875, input_cost=0.023, output_cost=0.02575, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_1_SOL_INPUT_TEXT: Final = CostTrackingTestCase( + name="azure-gpt-6.1-sol-input_text", + 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": "89ad6904966e 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 89ad6904966e", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.00936, input_cost=0.004416, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_1_SOL_STREAM: Final = CostTrackingTestCase( + name="azure-gpt-6.1-sol-stream", + 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": "493cd994b1de summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": 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": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6.1-sol-2026-09-29", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + { + "content_filter_results": {"protected_material_text": {"detected": False, "filtered": False}}, + "delta": {"content": "scripted answer 493cd994b1de"}, + "finish_reason": None, + "index": 0, + "logprobs": None, + } + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6.1-sol-2026-09-29", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [ + {"content_filter_results": {}, "delta": {}, "finish_reason": "stop", "index": 0, "logprobs": None} + ], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6.1-sol-2026-09-29", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "usage": None, + }, + { + "choices": [], + "created": 1791852023, + "id": "chatcmpl-$REQUEST_ID", + "model": "gpt-6.1-sol-2026-09-29", + "object": "chat.completion.chunk", + "service_tier": "default", + "system_fingerprint": None, + "routing": {"serving_pipereplica": "d20260925225746-6787865d-prefill-r11-dp0-prefill"}, + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + ), + expected=ExactExpected( + spend=0.00936, input_cost=0.004416, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_1_SOL_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="azure-gpt-6.1-sol-service_tier_flex", + 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": "960e0935140f summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "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 960e0935140f", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-dp0-prefill"}, + "service_tier": "flex", + "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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.00468, input_cost=0.002208, output_cost=0.002472, prompt_tokens=1840, completion_tokens=412 + ), +) + +AZURE_GPT_6_1_SOL_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="azure-gpt-6.1-sol-service_tier_priority", + 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": "6b36e2dc1f33 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "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 6b36e2dc1f33", + "refusal": None, + "role": "assistant", + }, + } + ], + "created": 1791852029, + "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": "d20260922011332-060efdec-prefill-r0-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": 4, + "engine_ttft_ms": 131, + "engine_ttlt_ms": 157, + "pre_inference_ms": 55, + "service_tbt_ms": 5, + "service_ttft_ms": 1034, + "service_ttlt_ms": 1058, + "user_visible_ttft_ms": 979, + }, + "prompt_tokens": 1840, + "prompt_tokens_details": {"audio_tokens": 0, "cache_write_tokens": 0, "cached_tokens": 0}, + "total_tokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.00936, input_cost=0.004416, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412 + ), +) + CASES: Final[tuple[CostTrackingTestCase, ...]] = ( AZURE_GPT_5_4_MINI_INPUT_TEXT, AZURE_GPT_5_4_MINI_CACHE_READ, @@ -3031,6 +4568,22 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = ( AZURE_TTS_NEXT_SPEECH_DEPLOYMENT, AZURE_TEXT_EMBEDDINGS_4_LARGE_DEPLOYMENT, AZURE_PINNED_GPT_5_4_MINI_STREAM, + AZURE_GPT_6_SOL_INPUT_TEXT, + AZURE_GPT_6_SOL_STREAM, + AZURE_GPT_6_SOL_SERVICE_TIER_FLEX, + AZURE_GPT_6_SOL_SERVICE_TIER_PRIORITY, + AZURE_GPT_6_LUNA_INPUT_TEXT, + AZURE_GPT_6_LUNA_STREAM, + AZURE_GPT_6_LUNA_SERVICE_TIER_FLEX, + AZURE_GPT_6_LUNA_SERVICE_TIER_PRIORITY, + AZURE_GPT_6_ASTRA_INPUT_TEXT, + AZURE_GPT_6_ASTRA_STREAM, + AZURE_GPT_6_ASTRA_SERVICE_TIER_FLEX, + AZURE_GPT_6_ASTRA_SERVICE_TIER_PRIORITY, + AZURE_GPT_6_1_SOL_INPUT_TEXT, + AZURE_GPT_6_1_SOL_STREAM, + AZURE_GPT_6_1_SOL_SERVICE_TIER_FLEX, + AZURE_GPT_6_1_SOL_SERVICE_TIER_PRIORITY, ) PARITY: Final[tuple[StreamParityTestCase, ...]] = ( @@ -3039,4 +4592,8 @@ PARITY: Final[tuple[StreamParityTestCase, ...]] = ( plain=AZURE_GPT_5_6_RESPONSE_MODEL_OVERRIDE, streamed=AZURE_GPT_5_6_STREAM_RESPONSE_MODEL_OVERRIDE ), StreamParityTestCase(plain=AZURE_GPT_5_6_TOOL_CALL, streamed=AZURE_GPT_5_6_STREAM_TOOL_CALL), + StreamParityTestCase(plain=AZURE_GPT_6_SOL_INPUT_TEXT, streamed=AZURE_GPT_6_SOL_STREAM), + StreamParityTestCase(plain=AZURE_GPT_6_LUNA_INPUT_TEXT, streamed=AZURE_GPT_6_LUNA_STREAM), + StreamParityTestCase(plain=AZURE_GPT_6_ASTRA_INPUT_TEXT, streamed=AZURE_GPT_6_ASTRA_STREAM), + StreamParityTestCase(plain=AZURE_GPT_6_1_SOL_INPUT_TEXT, streamed=AZURE_GPT_6_1_SOL_STREAM), ) diff --git a/tests/integration/cost_calculation/cases/bedrock_converse.py b/tests/integration/cost_calculation/cases/bedrock_converse.py index 7987ecfee76..11f55127653 100644 --- a/tests/integration/cost_calculation/cases/bedrock_converse.py +++ b/tests/integration/cost_calculation/cases/bedrock_converse.py @@ -2991,6 +2991,1760 @@ US_ANTHROPIC_CLAUDE_OPUS_5_5_INPUT_TEXT: Final = CostTrackingTestCase( ) +US_ANTHROPIC_CLAUDE_SONNET_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-input_text", + 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": "5517b299b268 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 5517b299b268"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "cacheReadInputTokenCount": 0, + "cacheReadInputTokens": 0, + "cacheWriteInputTokenCount": 0, + "cacheWriteInputTokens": 0, + "inputTokens": 1840, + "outputTokens": 412, + "serverToolUsage": {}, + "totalTokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.01404, input_cost=0.006624, output_cost=0.007416, prompt_tokens=1840, completion_tokens=412 + ), +) + +US_ANTHROPIC_CLAUDE_SONNET_5_STREAM: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "00121895862b summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=EventStreamResponse( + content_type="application/vnd.amazon.eventstream", + events=( + EventStreamEvent(event_type="messageStart", payload={"role": "assistant"}), + EventStreamEvent( + event_type="contentBlockDelta", + payload={"contentBlockIndex": 0, "delta": {"text": "scripted answer 00121895862b"}}, + ), + EventStreamEvent(event_type="contentBlockStop", payload={"contentBlockIndex": 0}), + EventStreamEvent(event_type="messageStop", payload={"stopReason": "end_turn"}), + EventStreamEvent( + event_type="metadata", + payload={ + "metrics": {"latencyMs": 883}, + "usage": {"inputTokens": 1840, "outputTokens": 412, "serverToolUsage": {}, "totalTokens": 2252}, + }, + ), + ), + ), + expected=ExactExpected( + spend=0.01404, input_cost=0.006624, output_cost=0.007416, prompt_tokens=1840, completion_tokens=412 + ), +) + +US_ANTHROPIC_CLAUDE_SONNET_5_CACHE_READ: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "c90a8b9a2eb4 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer c90a8b9a2eb4"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 640, + "outputTokens": 380, + "totalTokens": 13308, + "cacheReadInputTokens": 12288, + "cacheWriteInputTokens": 0, + }, + }, + ), + expected=ExactExpected( + spend=0.01356768, input_cost=0.00672768, output_cost=0.00684, prompt_tokens=12928, completion_tokens=380 + ), +) + +US_ANTHROPIC_CLAUDE_SONNET_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "ffd613a5af4a summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer ffd613a5af4a"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "5m", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0496152, input_cost=0.0433152, output_cost=0.0063, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_SONNET_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "402b2e3c8f52 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 402b2e3c8f52"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "1h", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0744984, input_cost=0.0681984, output_cost=0.0063, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_SONNET_5_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-5-input_text", + 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": "1a50e720f40a summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 1a50e720f40a"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "cacheReadInputTokenCount": 0, + "cacheReadInputTokens": 0, + "cacheWriteInputTokenCount": 0, + "cacheWriteInputTokens": 0, + "inputTokens": 1840, + "outputTokens": 412, + "serverToolUsage": {}, + "totalTokens": 2252, + }, + }, + ), + 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_STREAM: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "00d4a73ea61d summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=EventStreamResponse( + content_type="application/vnd.amazon.eventstream", + events=( + EventStreamEvent(event_type="messageStart", payload={"role": "assistant"}), + EventStreamEvent( + event_type="contentBlockDelta", + payload={"contentBlockIndex": 0, "delta": {"text": "scripted answer 00d4a73ea61d"}}, + ), + EventStreamEvent(event_type="contentBlockStop", payload={"contentBlockIndex": 0}), + EventStreamEvent(event_type="messageStop", payload={"stopReason": "end_turn"}), + EventStreamEvent( + event_type="metadata", + payload={ + "metrics": {"latencyMs": 883}, + "usage": {"inputTokens": 1840, "outputTokens": 412, "serverToolUsage": {}, "totalTokens": 2252}, + }, + ), + ), + ), + 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_CACHE_READ: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "5eff7f685f14 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 5eff7f685f14"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 640, + "outputTokens": 380, + "totalTokens": 13308, + "cacheReadInputTokens": 12288, + "cacheWriteInputTokens": 0, + }, + }, + ), + expected=ExactExpected( + spend=0.01394456, input_cost=0.00691456, output_cost=0.00703, prompt_tokens=12928, completion_tokens=380 + ), +) + +US_ANTHROPIC_CLAUDE_SONNET_5_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "eda648e63c9f summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer eda648e63c9f"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "5m", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0509934, input_cost=0.0445184, output_cost=0.006475, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_SONNET_5_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="us.anthropic.claude-sonnet-5-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "1799189351b9 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 1799189351b9"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "1h", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0765678, input_cost=0.0700928, output_cost=0.006475, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-input_text", + 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": "e9aaa98730fc summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer e9aaa98730fc"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "cacheReadInputTokenCount": 0, + "cacheReadInputTokens": 0, + "cacheWriteInputTokenCount": 0, + "cacheWriteInputTokens": 0, + "inputTokens": 1840, + "outputTokens": 412, + "serverToolUsage": {}, + "totalTokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.0234, input_cost=0.01104, output_cost=0.01236, prompt_tokens=1840, completion_tokens=412 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_STREAM: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "236c9ecadc46 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=EventStreamResponse( + content_type="application/vnd.amazon.eventstream", + events=( + EventStreamEvent(event_type="messageStart", payload={"role": "assistant"}), + EventStreamEvent( + event_type="contentBlockDelta", + payload={"contentBlockIndex": 0, "delta": {"text": "scripted answer 236c9ecadc46"}}, + ), + EventStreamEvent(event_type="contentBlockStop", payload={"contentBlockIndex": 0}), + EventStreamEvent(event_type="messageStop", payload={"stopReason": "end_turn"}), + EventStreamEvent( + event_type="metadata", + payload={ + "metrics": {"latencyMs": 883}, + "usage": {"inputTokens": 1840, "outputTokens": 412, "serverToolUsage": {}, "totalTokens": 2252}, + }, + ), + ), + ), + expected=ExactExpected( + spend=0.0234, input_cost=0.01104, output_cost=0.01236, prompt_tokens=1840, completion_tokens=412 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_CACHE_READ: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "58afbb027002 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 58afbb027002"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 640, + "outputTokens": 380, + "totalTokens": 13308, + "cacheReadInputTokens": 12288, + "cacheWriteInputTokens": 0, + }, + }, + ), + expected=ExactExpected( + spend=0.0226128, input_cost=0.0112128, output_cost=0.0114, prompt_tokens=12928, completion_tokens=380 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "16c6329484ca summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 16c6329484ca"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "5m", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.082692, input_cost=0.072192, output_cost=0.0105, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "78000b5822e0 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 78000b5822e0"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "1h", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.124164, input_cost=0.113664, output_cost=0.0105, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_5_STREAM: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "cd0638ad2925 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=EventStreamResponse( + content_type="application/vnd.amazon.eventstream", + events=( + EventStreamEvent(event_type="messageStart", payload={"role": "assistant"}), + EventStreamEvent( + event_type="contentBlockDelta", + payload={"contentBlockIndex": 0, "delta": {"text": "scripted answer cd0638ad2925"}}, + ), + EventStreamEvent(event_type="contentBlockStop", payload={"contentBlockIndex": 0}), + EventStreamEvent(event_type="messageStop", payload={"stopReason": "end_turn"}), + EventStreamEvent( + event_type="metadata", + payload={ + "metrics": {"latencyMs": 883}, + "usage": {"inputTokens": 1840, "outputTokens": 412, "serverToolUsage": {}, "totalTokens": 2252}, + }, + ), + ), + ), + 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_CACHE_READ: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "bbd4da2e326b summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer bbd4da2e326b"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 640, + "outputTokens": 380, + "totalTokens": 13308, + "cacheReadInputTokens": 12288, + "cacheWriteInputTokens": 0, + }, + }, + ), + expected=ExactExpected( + spend=0.01387936, input_cost=0.00551936, output_cost=0.00836, prompt_tokens=12928, completion_tokens=380 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "0bd639d53999 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 0bd639d53999"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "5m", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0606408, input_cost=0.0529408, output_cost=0.0077, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_OPUS_5_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="us.anthropic.claude-opus-5-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "74362dbc328e summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 74362dbc328e"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "1h", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0910536, input_cost=0.0833536, output_cost=0.0077, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_HAIKU_5_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="us.anthropic.claude-haiku-5-5-input_text", + 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": "8ff4d0ccb5a5 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 8ff4d0ccb5a5"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "cacheReadInputTokenCount": 0, + "cacheReadInputTokens": 0, + "cacheWriteInputTokenCount": 0, + "cacheWriteInputTokens": 0, + "inputTokens": 1840, + "outputTokens": 412, + "serverToolUsage": {}, + "totalTokens": 2252, + }, + }, + ), + 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_STREAM: Final = CostTrackingTestCase( + name="us.anthropic.claude-haiku-5-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "4f49296715c0 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=EventStreamResponse( + content_type="application/vnd.amazon.eventstream", + events=( + EventStreamEvent(event_type="messageStart", payload={"role": "assistant"}), + EventStreamEvent( + event_type="contentBlockDelta", + payload={"contentBlockIndex": 0, "delta": {"text": "scripted answer 4f49296715c0"}}, + ), + EventStreamEvent(event_type="contentBlockStop", payload={"contentBlockIndex": 0}), + EventStreamEvent(event_type="messageStop", payload={"stopReason": "end_turn"}), + EventStreamEvent( + event_type="metadata", + payload={ + "metrics": {"latencyMs": 883}, + "usage": {"inputTokens": 1840, "outputTokens": 412, "serverToolUsage": {}, "totalTokens": 2252}, + }, + ), + ), + ), + 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_CACHE_READ: Final = CostTrackingTestCase( + name="us.anthropic.claude-haiku-5-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "cf757e3e24df summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer cf757e3e24df"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 640, + "outputTokens": 380, + "totalTokens": 13308, + "cacheReadInputTokens": 12288, + "cacheWriteInputTokens": 0, + }, + }, + ), + expected=ExactExpected( + spend=0.00452256, input_cost=0.00224256, output_cost=0.00228, prompt_tokens=12928, completion_tokens=380 + ), +) + +US_ANTHROPIC_CLAUDE_HAIKU_5_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="us.anthropic.claude-haiku-5-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "3f2676ede7bd summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 3f2676ede7bd"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "5m", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0165384, input_cost=0.0144384, output_cost=0.0021, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_HAIKU_5_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="us.anthropic.claude-haiku-5-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "f88c14519a7a summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer f88c14519a7a"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "1h", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.0248328, input_cost=0.0227328, output_cost=0.0021, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_INPUT_TEXT: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-input_text", + 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": "8818a06860ae summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 8818a06860ae"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "cacheReadInputTokenCount": 0, + "cacheReadInputTokens": 0, + "cacheWriteInputTokenCount": 0, + "cacheWriteInputTokens": 0, + "inputTokens": 1840, + "outputTokens": 412, + "serverToolUsage": {}, + "totalTokens": 2252, + }, + }, + ), + expected=ExactExpected( + spend=0.0663, input_cost=0.03128, output_cost=0.03502, prompt_tokens=1840, completion_tokens=412 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_STREAM: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "5f82eb56d1a9 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=EventStreamResponse( + content_type="application/vnd.amazon.eventstream", + events=( + EventStreamEvent(event_type="messageStart", payload={"role": "assistant"}), + EventStreamEvent( + event_type="contentBlockDelta", + payload={"contentBlockIndex": 0, "delta": {"text": "scripted answer 5f82eb56d1a9"}}, + ), + EventStreamEvent(event_type="contentBlockStop", payload={"contentBlockIndex": 0}), + EventStreamEvent(event_type="messageStop", payload={"stopReason": "end_turn"}), + EventStreamEvent( + event_type="metadata", + payload={ + "metrics": {"latencyMs": 883}, + "usage": {"inputTokens": 1840, "outputTokens": 412, "serverToolUsage": {}, "totalTokens": 2252}, + }, + ), + ), + ), + expected=ExactExpected( + spend=0.0663, input_cost=0.03128, output_cost=0.03502, prompt_tokens=1840, completion_tokens=412 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_CACHE_READ: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "aa578bd8dff7 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer aa578bd8dff7"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 640, + "outputTokens": 380, + "totalTokens": 13308, + "cacheReadInputTokens": 12288, + "cacheWriteInputTokens": 0, + }, + }, + ), + expected=ExactExpected( + spend=0.0640696, input_cost=0.0317696, output_cost=0.0323, prompt_tokens=12928, completion_tokens=380 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "44d5ae527d01 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 44d5ae527d01"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "5m", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.234294, input_cost=0.204544, output_cost=0.02975, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "ab69d8f80811 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer ab69d8f80811"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "1h", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.351798, input_cost=0.322048, output_cost=0.02975, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_1_INPUT_TEXT: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-1-input_text", + 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": "a5b0ca93d2e1 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer a5b0ca93d2e1"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "cacheReadInputTokenCount": 0, + "cacheReadInputTokens": 0, + "cacheWriteInputTokenCount": 0, + "cacheWriteInputTokens": 0, + "inputTokens": 1840, + "outputTokens": 412, + "serverToolUsage": {}, + "totalTokens": 2252, + }, + }, + ), + 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_STREAM: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-1-stream", + covers="quota_management.spend_tracking.scripted_wire.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": "d62b383256ff summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=EventStreamResponse( + content_type="application/vnd.amazon.eventstream", + events=( + EventStreamEvent(event_type="messageStart", payload={"role": "assistant"}), + EventStreamEvent( + event_type="contentBlockDelta", + payload={"contentBlockIndex": 0, "delta": {"text": "scripted answer d62b383256ff"}}, + ), + EventStreamEvent(event_type="contentBlockStop", payload={"contentBlockIndex": 0}), + EventStreamEvent(event_type="messageStop", payload={"stopReason": "end_turn"}), + EventStreamEvent( + event_type="metadata", + payload={ + "metrics": {"latencyMs": 883}, + "usage": {"inputTokens": 1840, "outputTokens": 412, "serverToolUsage": {}, "totalTokens": 2252}, + }, + ), + ), + ), + 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_CACHE_READ: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-1-cache_read", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "1a5a397f1134 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 1a5a397f1134"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 640, + "outputTokens": 380, + "totalTokens": 13308, + "cacheReadInputTokens": 12288, + "cacheWriteInputTokens": 0, + }, + }, + ), + expected=ExactExpected( + spend=0.0678384, input_cost=0.0336384, output_cost=0.0342, prompt_tokens=12928, completion_tokens=380 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_1_CACHE_WRITE_5M: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-1-cache_write_5m", + 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.", + "cache_control": {"type": "ephemeral"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "3481bca67e1a summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 3481bca67e1a"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "5m", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.248076, input_cost=0.216576, output_cost=0.0315, prompt_tokens=9728, completion_tokens=350 + ), +) + +US_ANTHROPIC_CLAUDE_FABLE_5_1_CACHE_WRITE_1H: Final = CostTrackingTestCase( + name="us.anthropic.claude-fable-5-1-cache_write_1h", + 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.", + "cache_control": {"type": "ephemeral", "ttl": "1h"}, + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "text", + "text": "3f037d5317b0 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "metrics": {"latencyMs": 878}, + "output": {"message": {"content": [{"text": "scripted answer 3f037d5317b0"}], "role": "assistant"}}, + "stopReason": "end_turn", + "usage": { + "inputTokens": 512, + "outputTokens": 350, + "totalTokens": 10078, + "cacheReadInputTokens": 0, + "cacheWriteInputTokens": 9216, + "cacheDetails": [{"ttl": "1h", "inputTokens": 9216}], + }, + }, + ), + expected=ExactExpected( + spend=0.372492, input_cost=0.340992, output_cost=0.0315, prompt_tokens=9728, completion_tokens=350 + ), +) + CASES: Final[tuple[CostTrackingTestCase, ...]] = ( ANTHROPIC_CLAUDE_SONNET_5_V1_0_INPUT_TEXT, ANTHROPIC_CLAUDE_SONNET_5_V1_0_CACHE_READ, @@ -3047,6 +4801,40 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = ( BEDROCK_CONVERSE_NOVA_2_PRO, BEDROCK_CONVERSE_MISTRAL_LARGE_3_STREAM, US_ANTHROPIC_CLAUDE_OPUS_5_5_INPUT_TEXT, + US_ANTHROPIC_CLAUDE_SONNET_5_INPUT_TEXT, + US_ANTHROPIC_CLAUDE_SONNET_5_STREAM, + US_ANTHROPIC_CLAUDE_SONNET_5_CACHE_READ, + US_ANTHROPIC_CLAUDE_SONNET_5_CACHE_WRITE_5M, + US_ANTHROPIC_CLAUDE_SONNET_5_CACHE_WRITE_1H, + US_ANTHROPIC_CLAUDE_SONNET_5_5_INPUT_TEXT, + US_ANTHROPIC_CLAUDE_SONNET_5_5_STREAM, + US_ANTHROPIC_CLAUDE_SONNET_5_5_CACHE_READ, + US_ANTHROPIC_CLAUDE_SONNET_5_5_CACHE_WRITE_5M, + US_ANTHROPIC_CLAUDE_SONNET_5_5_CACHE_WRITE_1H, + US_ANTHROPIC_CLAUDE_OPUS_5_INPUT_TEXT, + US_ANTHROPIC_CLAUDE_OPUS_5_STREAM, + US_ANTHROPIC_CLAUDE_OPUS_5_CACHE_READ, + US_ANTHROPIC_CLAUDE_OPUS_5_CACHE_WRITE_5M, + US_ANTHROPIC_CLAUDE_OPUS_5_CACHE_WRITE_1H, + US_ANTHROPIC_CLAUDE_OPUS_5_5_STREAM, + US_ANTHROPIC_CLAUDE_OPUS_5_5_CACHE_READ, + US_ANTHROPIC_CLAUDE_OPUS_5_5_CACHE_WRITE_5M, + US_ANTHROPIC_CLAUDE_OPUS_5_5_CACHE_WRITE_1H, + US_ANTHROPIC_CLAUDE_HAIKU_5_5_INPUT_TEXT, + US_ANTHROPIC_CLAUDE_HAIKU_5_5_STREAM, + US_ANTHROPIC_CLAUDE_HAIKU_5_5_CACHE_READ, + US_ANTHROPIC_CLAUDE_HAIKU_5_5_CACHE_WRITE_5M, + US_ANTHROPIC_CLAUDE_HAIKU_5_5_CACHE_WRITE_1H, + US_ANTHROPIC_CLAUDE_FABLE_5_INPUT_TEXT, + US_ANTHROPIC_CLAUDE_FABLE_5_STREAM, + US_ANTHROPIC_CLAUDE_FABLE_5_CACHE_READ, + US_ANTHROPIC_CLAUDE_FABLE_5_CACHE_WRITE_5M, + US_ANTHROPIC_CLAUDE_FABLE_5_CACHE_WRITE_1H, + US_ANTHROPIC_CLAUDE_FABLE_5_1_INPUT_TEXT, + US_ANTHROPIC_CLAUDE_FABLE_5_1_STREAM, + 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, ) PARITY: Final[tuple[StreamParityTestCase, ...]] = ( @@ -3060,4 +4848,13 @@ PARITY: Final[tuple[StreamParityTestCase, ...]] = ( StreamParityTestCase( plain=US_ANTHROPIC_CLAUDE_OPUS_5_V1_0_TOOL_CALL, streamed=US_ANTHROPIC_CLAUDE_OPUS_5_V1_0_STREAM_TOOL_CALL ), + StreamParityTestCase(plain=US_ANTHROPIC_CLAUDE_SONNET_5_INPUT_TEXT, streamed=US_ANTHROPIC_CLAUDE_SONNET_5_STREAM), + StreamParityTestCase( + plain=US_ANTHROPIC_CLAUDE_SONNET_5_5_INPUT_TEXT, streamed=US_ANTHROPIC_CLAUDE_SONNET_5_5_STREAM + ), + StreamParityTestCase(plain=US_ANTHROPIC_CLAUDE_OPUS_5_INPUT_TEXT, streamed=US_ANTHROPIC_CLAUDE_OPUS_5_STREAM), + StreamParityTestCase(plain=US_ANTHROPIC_CLAUDE_OPUS_5_5_INPUT_TEXT, streamed=US_ANTHROPIC_CLAUDE_OPUS_5_5_STREAM), + StreamParityTestCase(plain=US_ANTHROPIC_CLAUDE_HAIKU_5_5_INPUT_TEXT, streamed=US_ANTHROPIC_CLAUDE_HAIKU_5_5_STREAM), + StreamParityTestCase(plain=US_ANTHROPIC_CLAUDE_FABLE_5_INPUT_TEXT, streamed=US_ANTHROPIC_CLAUDE_FABLE_5_STREAM), + StreamParityTestCase(plain=US_ANTHROPIC_CLAUDE_FABLE_5_1_INPUT_TEXT, streamed=US_ANTHROPIC_CLAUDE_FABLE_5_1_STREAM), ) diff --git a/tests/integration/cost_calculation/cases/openai.py b/tests/integration/cost_calculation/cases/openai.py index ea004937ccd..64753827ac1 100644 --- a/tests/integration/cost_calculation/cases/openai.py +++ b/tests/integration/cost_calculation/cases/openai.py @@ -8212,6 +8212,1437 @@ OPENAI_GPT_6_LUNA_SYSTEMONE_LONG_CONTEXT: Final = CostTrackingTestCase( ) +GPT_6_SOL_INPUT_TEXT: Final = CostTrackingTestCase( + name="gpt-6-sol-input_text", + 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": "d36c648eb5c2 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-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-sol", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer d36c648eb5c2", + "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 + ), +) + +GPT_6_SOL_STREAM: Final = CostTrackingTestCase( + name="gpt-6-sol-stream", + 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": "b807c011e149 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [ + {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None} + ], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {"content": "scripted answer b807c011e149"}, "finish_reason": None}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [], + "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, + }, + }, + }, + ), + ), + expected=ExactExpected( + spend=0.00858, input_cost=0.004048, output_cost=0.004532, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_SOL_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="gpt-6-sol-service_tier_flex", + 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": "42b013573e14 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-sol", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer 42b013573e14", + "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": "flex", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.00429, input_cost=0.002024, output_cost=0.002266, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_SOL_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="gpt-6-sol-service_tier_priority", + 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": "f4ef2ca58612 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-sol", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer f4ef2ca58612", + "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": "fast", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.01716, input_cost=0.008096, output_cost=0.009064, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_SOL_RESPONSES_NATIVE_JSON: Final = CostTrackingTestCase( + name="gpt-6-sol-responses_native_json", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="gpt-6-sol", + endpoint="/v1/responses", + request={"model": "$MODEL", "input": "responses native fixture", "stream": False}, + response=JsonResponse( + content_type="application/json", + body={ + "id": "resp_$REQUEST_ID", + "object": "response", + "created_at": 1791851574, + "status": "completed", + "background": False, + "billing": {"payer": "developer"}, + "completed_at": 1791851574, + "error": None, + "incomplete_details": None, + "instructions": None, + "max_output_tokens": 412, + "model": "gpt-6-sol", + "output": [ + { + "id": "msg_$REQUEST_ID", + "type": "message", + "status": "completed", + "content": [ + {"type": "output_text", "annotations": [], "logprobs": [], "text": "scripted response"} + ], + "phase": "final_answer", + "role": "assistant", + } + ], + "parallel_tool_calls": True, + "previous_response_id": None, + "prompt_cache_key": None, + "prompt_cache_retention": "24h", + "reasoning": {"context": "all_turns", "effort": "medium", "mode": "standard", "summary": None}, + "service_tier": "default", + "store": True, + "temperature": 1.0, + "text": {"format": {"type": "text"}, "verbosity": "medium"}, + "tool_choice": "auto", + "tool_usage": { + "image_gen": { + "input_tokens": 0, + "input_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "output_tokens": 0, + "output_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "total_tokens": 0, + }, + "web_search": {"num_requests": 0}, + }, + "tools": [], + "top_logprobs": 0, + "top_p": 0.98, + "truncation": "disabled", + "usage": { + "input_tokens": 1840, + "input_tokens_details": {"cache_write_tokens": 0, "cached_tokens": 0}, + "output_tokens": 412, + "output_tokens_details": {"reasoning_tokens": 0}, + "total_tokens": 2252, + }, + "user": None, + "metadata": {}, + }, + ), + expected=ExactExpected( + spend=0.00858, input_cost=0.004048, output_cost=0.004532, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_LUNA_INPUT_TEXT: Final = CostTrackingTestCase( + name="gpt-6-luna-input_text", + 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": "694ee3f43b69 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-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-luna", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer 694ee3f43b69", + "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.00039, input_cost=0.000184, output_cost=0.000206, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_LUNA_STREAM: Final = CostTrackingTestCase( + name="gpt-6-luna-stream", + 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": "f3f11b8d2818 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-luna", + "service_tier": "default", + "system_fingerprint": None, + "choices": [ + {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None} + ], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-luna", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {"content": "scripted answer f3f11b8d2818"}, "finish_reason": None}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-luna", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-luna", + "service_tier": "default", + "system_fingerprint": None, + "choices": [], + "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, + }, + }, + }, + ), + ), + expected=ExactExpected( + spend=0.00039, input_cost=0.000184, output_cost=0.000206, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_LUNA_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="gpt-6-luna-service_tier_flex", + 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": "dd297fa791f8 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-luna", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer dd297fa791f8", + "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": "flex", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.000195, input_cost=0.000092, output_cost=0.000103, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_LUNA_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="gpt-6-luna-service_tier_priority", + 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": "c6908010aebc summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-luna", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer c6908010aebc", + "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": "fast", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.00078, input_cost=0.000368, output_cost=0.000412, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_LUNA_RESPONSES_NATIVE_JSON: Final = CostTrackingTestCase( + name="gpt-6-luna-responses_native_json", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="gpt-6-luna", + endpoint="/v1/responses", + request={"model": "$MODEL", "input": "responses native fixture", "stream": False}, + response=JsonResponse( + content_type="application/json", + body={ + "id": "resp_$REQUEST_ID", + "object": "response", + "created_at": 1791851574, + "status": "completed", + "background": False, + "billing": {"payer": "developer"}, + "completed_at": 1791851574, + "error": None, + "incomplete_details": None, + "instructions": None, + "max_output_tokens": 412, + "model": "gpt-6-luna", + "output": [ + { + "id": "msg_$REQUEST_ID", + "type": "message", + "status": "completed", + "content": [ + {"type": "output_text", "annotations": [], "logprobs": [], "text": "scripted response"} + ], + "phase": "final_answer", + "role": "assistant", + } + ], + "parallel_tool_calls": True, + "previous_response_id": None, + "prompt_cache_key": None, + "prompt_cache_retention": "24h", + "reasoning": {"context": "all_turns", "effort": "medium", "mode": "standard", "summary": None}, + "service_tier": "default", + "store": True, + "temperature": 1.0, + "text": {"format": {"type": "text"}, "verbosity": "medium"}, + "tool_choice": "auto", + "tool_usage": { + "image_gen": { + "input_tokens": 0, + "input_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "output_tokens": 0, + "output_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "total_tokens": 0, + }, + "web_search": {"num_requests": 0}, + }, + "tools": [], + "top_logprobs": 0, + "top_p": 0.98, + "truncation": "disabled", + "usage": { + "input_tokens": 1840, + "input_tokens_details": {"cache_write_tokens": 0, "cached_tokens": 0}, + "output_tokens": 412, + "output_tokens_details": {"reasoning_tokens": 0}, + "total_tokens": 2252, + }, + "user": None, + "metadata": {}, + }, + ), + expected=ExactExpected( + spend=0.00039, input_cost=0.000184, output_cost=0.000206, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_ASTRA_INPUT_TEXT: Final = CostTrackingTestCase( + name="gpt-6-astra-input_text", + 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": "682dbc7dce00 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-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-astra", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer 682dbc7dce00", + "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.0468, input_cost=0.02208, output_cost=0.02472, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_ASTRA_STREAM: Final = CostTrackingTestCase( + name="gpt-6-astra-stream", + 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": "867507e67c53 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-astra", + "service_tier": "default", + "system_fingerprint": None, + "choices": [ + {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None} + ], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-astra", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {"content": "scripted answer 867507e67c53"}, "finish_reason": None}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-astra", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6-astra", + "service_tier": "default", + "system_fingerprint": None, + "choices": [], + "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, + }, + }, + }, + ), + ), + expected=ExactExpected( + spend=0.0468, input_cost=0.02208, output_cost=0.02472, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_ASTRA_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="gpt-6-astra-service_tier_flex", + 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": "72512aa3c14a summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-astra", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer 72512aa3c14a", + "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": "flex", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.0234, input_cost=0.01104, output_cost=0.01236, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_ASTRA_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="gpt-6-astra-service_tier_priority", + 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": "53b84772ae29 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6-astra", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer 53b84772ae29", + "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": "fast", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.0936, input_cost=0.04416, output_cost=0.04944, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_ASTRA_RESPONSES_NATIVE_JSON: Final = CostTrackingTestCase( + name="gpt-6-astra-responses_native_json", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="gpt-6-astra", + endpoint="/v1/responses", + request={"model": "$MODEL", "input": "responses native fixture", "stream": False}, + response=JsonResponse( + content_type="application/json", + body={ + "id": "resp_$REQUEST_ID", + "object": "response", + "created_at": 1791851574, + "status": "completed", + "background": False, + "billing": {"payer": "developer"}, + "completed_at": 1791851574, + "error": None, + "incomplete_details": None, + "instructions": None, + "max_output_tokens": 412, + "model": "gpt-6-astra", + "output": [ + { + "id": "msg_$REQUEST_ID", + "type": "message", + "status": "completed", + "content": [ + {"type": "output_text", "annotations": [], "logprobs": [], "text": "scripted response"} + ], + "phase": "final_answer", + "role": "assistant", + } + ], + "parallel_tool_calls": True, + "previous_response_id": None, + "prompt_cache_key": None, + "prompt_cache_retention": "24h", + "reasoning": {"context": "all_turns", "effort": "medium", "mode": "standard", "summary": None}, + "service_tier": "default", + "store": True, + "temperature": 1.0, + "text": {"format": {"type": "text"}, "verbosity": "medium"}, + "tool_choice": "auto", + "tool_usage": { + "image_gen": { + "input_tokens": 0, + "input_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "output_tokens": 0, + "output_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "total_tokens": 0, + }, + "web_search": {"num_requests": 0}, + }, + "tools": [], + "top_logprobs": 0, + "top_p": 0.98, + "truncation": "disabled", + "usage": { + "input_tokens": 1840, + "input_tokens_details": {"cache_write_tokens": 0, "cached_tokens": 0}, + "output_tokens": 412, + "output_tokens_details": {"reasoning_tokens": 0}, + "total_tokens": 2252, + }, + "user": None, + "metadata": {}, + }, + ), + expected=ExactExpected( + spend=0.0468, input_cost=0.02208, output_cost=0.02472, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_1_SOL_STREAM: Final = CostTrackingTestCase( + name="gpt-6.1-sol-stream", + 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": "fe2e0078a155 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": True, + "stream_options": {"include_usage": True}, + "allowed_openai_params": [], + }, + response=SseResponse( + content_type="text/event-stream", + frames=sse_frames( + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6.1-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [ + {"index": 0, "delta": {"role": "assistant", "content": "", "refusal": None}, "finish_reason": None} + ], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6.1-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {"content": "scripted answer fe2e0078a155"}, "finish_reason": None}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6.1-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}], + "usage": None, + }, + { + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion.chunk", + "created": 1791851658, + "model": "gpt-6.1-sol", + "service_tier": "default", + "system_fingerprint": None, + "choices": [], + "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, + }, + }, + }, + ), + ), + expected=ExactExpected( + spend=0.0078, input_cost=0.00368, output_cost=0.00412, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_1_SOL_SERVICE_TIER_FLEX: Final = CostTrackingTestCase( + name="gpt-6.1-sol-service_tier_flex", + 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": "28201777a291 summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "flex", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6.1-sol", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer 28201777a291", + "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": "flex", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.0039, input_cost=0.00184, output_cost=0.00206, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_1_SOL_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase( + name="gpt-6.1-sol-service_tier_priority", + 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": "27c98f26478e summarize the attached material in one line and name the city weather", + } + ], + }, + ], + "stream": False, + "service_tier": "priority", + "allowed_openai_params": [], + }, + response=JsonResponse( + content_type="application/json", + body={ + "id": "chatcmpl-$REQUEST_ID", + "object": "chat.completion", + "created": 1791851507, + "model": "gpt-6.1-sol", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "scripted answer 27c98f26478e", + "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": "fast", + "system_fingerprint": None, + }, + ), + expected=ExactExpected( + spend=0.0156, input_cost=0.00736, output_cost=0.00824, prompt_tokens=1840, completion_tokens=412 + ), +) + +GPT_6_1_SOL_RESPONSES_NATIVE_JSON: Final = CostTrackingTestCase( + name="gpt-6.1-sol-responses_native_json", + covers="quota_management.spend_tracking.cost_matrix.logs_cost", + model="gpt-6.1-sol", + endpoint="/v1/responses", + request={"model": "$MODEL", "input": "responses native fixture", "stream": False}, + response=JsonResponse( + content_type="application/json", + body={ + "id": "resp_$REQUEST_ID", + "object": "response", + "created_at": 1791851574, + "status": "completed", + "background": False, + "billing": {"payer": "developer"}, + "completed_at": 1791851574, + "error": None, + "incomplete_details": None, + "instructions": None, + "max_output_tokens": 412, + "model": "gpt-6.1-sol", + "output": [ + { + "id": "msg_$REQUEST_ID", + "type": "message", + "status": "completed", + "content": [ + {"type": "output_text", "annotations": [], "logprobs": [], "text": "scripted response"} + ], + "phase": "final_answer", + "role": "assistant", + } + ], + "parallel_tool_calls": True, + "previous_response_id": None, + "prompt_cache_key": None, + "prompt_cache_retention": "24h", + "reasoning": {"context": "all_turns", "effort": "medium", "mode": "standard", "summary": None}, + "service_tier": "default", + "store": True, + "temperature": 1.0, + "text": {"format": {"type": "text"}, "verbosity": "medium"}, + "tool_choice": "auto", + "tool_usage": { + "image_gen": { + "input_tokens": 0, + "input_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "output_tokens": 0, + "output_tokens_details": {"image_tokens": 0, "text_tokens": 0}, + "total_tokens": 0, + }, + "web_search": {"num_requests": 0}, + }, + "tools": [], + "top_logprobs": 0, + "top_p": 0.98, + "truncation": "disabled", + "usage": { + "input_tokens": 1840, + "input_tokens_details": {"cache_write_tokens": 0, "cached_tokens": 0}, + "output_tokens": 412, + "output_tokens_details": {"reasoning_tokens": 0}, + "total_tokens": 2252, + }, + "user": None, + "metadata": {}, + }, + ), + expected=ExactExpected( + spend=0.0078, input_cost=0.00368, output_cost=0.00412, prompt_tokens=1840, completion_tokens=412 + ), +) + CASES: Final[tuple[CostTrackingTestCase, ...]] = ( GPT_5_3_CODEX_INPUT_TEXT, GPT_5_3_CODEX_CACHE_READ, @@ -8354,6 +9785,25 @@ CASES: Final[tuple[CostTrackingTestCase, ...]] = ( 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, ) PARITY: Final[tuple[StreamParityTestCase, ...]] = ( @@ -8378,4 +9828,8 @@ PARITY: Final[tuple[StreamParityTestCase, ...]] = ( StreamParityTestCase(plain=GPT_5_5_PRO_TOOL_CALL, streamed=GPT_5_5_PRO_STREAM_TOOL_CALL), StreamParityTestCase(plain=GPT_5_6_RESPONSE_MODEL_OVERRIDE, streamed=GPT_5_6_STREAM_RESPONSE_MODEL_OVERRIDE), StreamParityTestCase(plain=GPT_5_6_TOOL_CALL, streamed=GPT_5_6_STREAM_TOOL_CALL), + StreamParityTestCase(plain=GPT_6_SOL_INPUT_TEXT, streamed=GPT_6_SOL_STREAM), + StreamParityTestCase(plain=GPT_6_LUNA_INPUT_TEXT, streamed=GPT_6_LUNA_STREAM), + 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), ) diff --git a/tests/integration/cost_calculation/cost_map.py b/tests/integration/cost_calculation/cost_map.py index 4cf217a6701..f8db4eb1a04 100644 --- a/tests/integration/cost_calculation/cost_map.py +++ b/tests/integration/cost_calculation/cost_map.py @@ -33,6 +33,10 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = { "output_cost_per_token": 1.6e-05, }, "gpt-6-luna": { + "output_cost_per_token_priority": 1e-06, + "input_cost_per_token_priority": 2e-07, + "output_cost_per_token_flex": 2.5e-07, + "input_cost_per_token_flex": 5e-08, "cache_creation_input_token_cost": 1.25e-07, "cache_creation_input_token_cost_decisions": 1e-07, "cache_creation_input_token_cost_above_272k_tokens": 2.5e-07, @@ -787,6 +791,7 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = { "supports_function_calling": True, }, "us.anthropic.claude-opus-5-5": { + "cache_creation_input_token_cost_above_1hr": 8.8e-06, "litellm_provider": "bedrock_converse", "mode": "chat", "input_cost_per_token": 4.4e-06, @@ -799,6 +804,7 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = { "supports_function_calling": True, }, "claude-opus-5-5": { + "cache_creation_input_token_cost_above_1hr": 8e-06, "litellm_provider": "anthropic", "mode": "chat", "input_cost_per_token": 4e-06, @@ -811,6 +817,10 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = { "supports_function_calling": True, }, "gpt-6.1-sol": { + "output_cost_per_token_priority": 2e-05, + "input_cost_per_token_priority": 4e-06, + "output_cost_per_token_flex": 5e-06, + "input_cost_per_token_flex": 1e-06, "litellm_provider": "openai", "mode": "chat", "input_cost_per_token": 2e-06, @@ -821,4 +831,224 @@ COST_MAP_ENTRIES: Final[dict[str, dict[str, JsonValue]]] = { "max_output_tokens": 128000, "supports_function_calling": True, }, + "claude-sonnet-5-5": { + "cache_creation_input_token_cost": 4.125e-06, + "cache_creation_input_token_cost_above_1hr": 6.6e-06, + "cache_read_input_token_cost": 3.3e-07, + "input_cost_per_token": 3.3e-06, + "litellm_provider": "anthropic", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.65e-05, + "supports_function_calling": True, + }, + "claude-haiku-5-5": { + "cache_creation_input_token_cost": 1.375e-06, + "cache_creation_input_token_cost_above_1hr": 2.2e-06, + "cache_read_input_token_cost": 1.1e-07, + "input_cost_per_token": 1.1e-06, + "litellm_provider": "anthropic", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 5.5e-06, + "supports_function_calling": True, + }, + "claude-fable-5": { + "cache_creation_input_token_cost": 1.875e-05, + "cache_creation_input_token_cost_above_1hr": 3e-05, + "cache_read_input_token_cost": 1.5e-06, + "input_cost_per_token": 1.5e-05, + "litellm_provider": "anthropic", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 7.5e-05, + "supports_function_calling": True, + }, + "claude-fable-5-1": { + "cache_creation_input_token_cost": 2e-05, + "cache_creation_input_token_cost_above_1hr": 3.2e-05, + "cache_read_input_token_cost": 1.6e-06, + "input_cost_per_token": 1.6e-05, + "litellm_provider": "anthropic", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 8e-05, + "supports_function_calling": True, + }, + "us.anthropic.claude-sonnet-5": { + "cache_creation_input_token_cost": 4.5e-06, + "cache_creation_input_token_cost_above_1hr": 7.2e-06, + "cache_read_input_token_cost": 3.6e-07, + "input_cost_per_token": 3.6e-06, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.8e-05, + "supports_function_calling": True, + }, + "us.anthropic.claude-sonnet-5-5": { + "cache_creation_input_token_cost": 4.625e-06, + "cache_creation_input_token_cost_above_1hr": 7.4e-06, + "cache_read_input_token_cost": 3.7e-07, + "input_cost_per_token": 3.7e-06, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.85e-05, + "supports_function_calling": True, + }, + "us.anthropic.claude-opus-5": { + "cache_creation_input_token_cost": 7.5e-06, + "cache_creation_input_token_cost_above_1hr": 1.2e-05, + "cache_read_input_token_cost": 6e-07, + "input_cost_per_token": 6e-06, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 3e-05, + "supports_function_calling": True, + }, + "us.anthropic.claude-haiku-5-5": { + "cache_creation_input_token_cost": 1.5e-06, + "cache_creation_input_token_cost_above_1hr": 2.4e-06, + "cache_read_input_token_cost": 1.2e-07, + "input_cost_per_token": 1.2e-06, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "supports_function_calling": True, + }, + "us.anthropic.claude-fable-5": { + "cache_creation_input_token_cost": 2.125e-05, + "cache_creation_input_token_cost_above_1hr": 3.4e-05, + "cache_read_input_token_cost": 1.7e-06, + "input_cost_per_token": 1.7e-05, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 8.5e-05, + "supports_function_calling": True, + }, + "us.anthropic.claude-fable-5-1": { + "cache_creation_input_token_cost": 2.25e-05, + "cache_creation_input_token_cost_above_1hr": 3.6e-05, + "cache_read_input_token_cost": 1.8e-06, + "input_cost_per_token": 1.8e-05, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 9e-05, + "supports_function_calling": True, + }, + "gpt-6-sol": { + "cache_read_input_token_cost": 2.2e-07, + "input_cost_per_token": 2.2e-06, + "input_cost_per_token_flex": 1.1e-06, + "input_cost_per_token_priority": 4.4e-06, + "litellm_provider": "openai", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.1e-05, + "output_cost_per_token_flex": 5.5e-06, + "output_cost_per_token_priority": 2.2e-05, + "supports_function_calling": True, + }, + "gpt-6-astra": { + "cache_read_input_token_cost": 1.2e-06, + "input_cost_per_token": 1.2e-05, + "input_cost_per_token_flex": 6e-06, + "input_cost_per_token_priority": 2.4e-05, + "litellm_provider": "openai", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6e-05, + "output_cost_per_token_flex": 3e-05, + "output_cost_per_token_priority": 0.00012, + "supports_function_calling": True, + }, + "azure/gpt-6-sol": { + "cache_read_input_token_cost": 2.3e-07, + "input_cost_per_token": 2.3e-06, + "input_cost_per_token_flex": 1.15e-06, + "input_cost_per_token_priority": 4.6e-06, + "litellm_provider": "azure", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.15e-05, + "output_cost_per_token_flex": 5.75e-06, + "output_cost_per_token_priority": 2.3e-05, + "supports_function_calling": True, + }, + "azure/gpt-6-luna": { + "cache_read_input_token_cost": 1.3e-08, + "input_cost_per_token": 1.3e-07, + "input_cost_per_token_flex": 6.5e-08, + "input_cost_per_token_priority": 2.6e-07, + "litellm_provider": "azure", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6.5e-07, + "output_cost_per_token_flex": 3.25e-07, + "output_cost_per_token_priority": 1.3e-06, + "supports_function_calling": True, + }, + "azure/gpt-6-astra": { + "cache_read_input_token_cost": 1.25e-06, + "input_cost_per_token": 1.25e-05, + "input_cost_per_token_flex": 6.25e-06, + "input_cost_per_token_priority": 2.5e-05, + "litellm_provider": "azure", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6.25e-05, + "output_cost_per_token_flex": 3.125e-05, + "output_cost_per_token_priority": 0.000125, + "supports_function_calling": True, + }, + "azure/gpt-6.1-sol": { + "cache_read_input_token_cost": 2.4e-07, + "input_cost_per_token": 2.4e-06, + "input_cost_per_token_flex": 1.2e-06, + "input_cost_per_token_priority": 4.8e-06, + "litellm_provider": "azure", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.2e-05, + "output_cost_per_token_flex": 6e-06, + "output_cost_per_token_priority": 2.4e-05, + "supports_function_calling": True, + }, }