Skip to content

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

142 KB
Raw Blame
"""gemini cost tracking cases, one CostTrackingTestCase literal per request shape (moved from cost_tracking_cases.json).

PARITY pairs the streamed case with its plain twin where both bill the same row."""

import json
from typing import Final, cast

from pydantic import JsonValue
from integration.cost_calculation.bridge_cost_parity.case import BridgeCostParityTestCase, bridge_pairs
from integration.cost_calculation.cost_tracking_case import (
    CostTrackingTestCase,
    ExactExpected,
    JsonResponse,
    RecountExpected,
    RecountRates,
    RoutedResponse,
    SseResponse,
)
from integration.cost_calculation.stream_parity.case import StreamParityTestCase, sse_frames


def _gemini_case_response(
    response: JsonResponse | SseResponse,
    model_version: str,
    usage_fields: dict[str, JsonValue] | None = None,
) -> JsonResponse | SseResponse:
    match response:
        case JsonResponse():
            usage: Final = response.body.get("usageMetadata")
            body: Final = {**response.body, "modelVersion": model_version}
            return response.model_copy(
                update={
                    "body": {
                        **body,
                        **(
                            {
                                "usageMetadata": {
                                    **cast(dict[str, JsonValue], usage),
                                    **usage_fields,
                                }
                            }
                            if usage_fields is not None and isinstance(usage, dict)
                            else {}
                        ),
                    }
                }
            )
        case SseResponse():
            return response.model_copy(
                update={
                    "frames": tuple(
                        _gemini_case_frame(frame, model_version, usage_fields) for frame in response.frames
                    )
                }
            )


def _gemini_case_frame(
    frame: str, model_version: str, usage_fields: dict[str, JsonValue] | None
) -> str:
    replaced: Final = frame.replace("gemini-3.8-flash", model_version)
    if usage_fields is None:
        return replaced
    prefix, separator, payload = replaced.partition("data: ")
    if not separator or payload == "[DONE]":
        return replaced
    event: Final = cast(dict[str, JsonValue], json.loads(payload))
    usage: Final = event.get("usageMetadata")
    if not isinstance(usage, dict):
        return replaced
    return f"{prefix}data: {json.dumps({**event, 'usageMetadata': {**usage, **usage_fields}})}"


def _gemini_case(
    sibling: CostTrackingTestCase,
    name: str,
    model: str,
    model_version: str,
    expected: ExactExpected,
    *,
    usage_fields: dict[str, JsonValue] | None = None,
) -> CostTrackingTestCase:
    return sibling.model_copy(
        update={
            "name": name,
            "model": model,
            "response": _gemini_case_response(
                cast(JsonResponse | SseResponse, sibling.response), model_version, usage_fields
            ),
            "expected": expected,
        }
    )


# gemini/gemini-3.1-pro
GEMINI_GEMINI_3_1_PRO_INPUT_TEXT: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-input_text",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "15e6a9747fd2 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 15e6a9747fd2"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                "serviceTier": "standard",
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.008624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_CACHE_READ: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-cache_read",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "722017e8e394 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 722017e8e394"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 12928,
                "candidatesTokenCount": 380,
                "totalTokenCount": 13308,
                "cachedContentTokenCount": 12288,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 12928}],
                "serviceTier": "standard",
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.0082976, input_cost=0.0037376, output_cost=0.00456, prompt_tokens=12928, completion_tokens=380
    ),
)

GEMINI_GEMINI_3_1_PRO_AUDIO_INPUT: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-audio_input",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "f03ad3a1bb53 summarize the attached material in one line and name the city weather",
                    },
                    {
                        "type": "input_audio",
                        "input_audio": {
                            "data": "UklGRmQGAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YUAGAAAAAA8I4A85F+EdpCNYKNkrCy7eLkwuWSwTKZUk/x59GEERgQl4AWb5hPER6kbjVd1t2LLUQdIu0X/RM9M81oTa6t9E5mPtD/UP/SQFEw2fFI0bqSHEJrgqZi27LqouNi1pKlkmJSH0GvUTXgxpBFP8WPS27KflYt8U2ujV/dJp0TjRbNL71NPY1d3b47nqOPIh+jUCOQrwER0Zj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i7mLZUr9ycpI04dlRYvD1UHRP8492/vJOiP4eLbSdfm09PRINHT0ebTSdfi24/hJOhv7zj3RP9VBy8PlRZOHSkj9yeVK+Yt2i5oLpQsbSkJJYwfHRnwETkKNQIh+jjyuerb49Xd09j71GzSONFp0f3S6NUU2mLfp+W27Fj0U/xpBF4M9RP0GiUhWSZpKjYtqi67LmYtuCrEJqkhjRufFBMNJAUP/Q/1Y+1E5urfhNo81jPTf9Eu0UHSstRt2FXdRuMR6oTxZvl4AYEJQRF9GP8elSQTKVksTC7eLgsu2StYKKQj4R05F+APDwgAAPH3IPDH6B/iXNyo1yfU9dEi0bTRp9Pt1mvbAeGD57/uf/aI/poGfA7vFbocqyKTJ04rvy3SLoEuzSzEKXwlFiC8GZ0S8QrxAtz67fJh63PkV9482UjVmtJF0VbRytKX1afZ294M5QvsovOX+60DqAtKE1kaniDsJRgqAy2XLsgulC0FKy0nKyIlHEcVyA3fBcv9x/UQ7uPmdOD32pPWbNOY0SbRGtJr1AnY19yy4mvp0fCr+LwAyAiRENwXcR4eJLcoGiwtLuAuLS4aLLcoHiRxHtwXkRDICLwAq/jR8GvpsuLX3AnYa9Qa0ibRmNFs05PW99p04OPmEO7H9cv93wXIDUcVJRwrIi0nBSuULcguly4DLRgq7CWeIFkaShOoC60Dl/ui8wvsDOXb3qfZl9XK0lbRRdGa0kjVPNlX3nPkYevt8tz68QLxCp0SvBkWIHwlxCnNLIEu0i6/LU4rkyerIroc7xV8DpoGiP5/9r/ug+cB4Wvb7dan07TRItH10SfUqNdc3B/ix+gg8PH3",
                            "format": "wav",
                        },
                    },
                ],
            },
        ],
        "stream": False,
        "modalities": ["text"],
        "allowed_openai_params": ["modalities"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer f03ad3a1bb53"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1546,
                "candidatesTokenCount": 210,
                "totalTokenCount": 1756,
                "promptTokensDetails": [
                    {"modality": "TEXT", "tokenCount": 96},
                    {"modality": "AUDIO", "tokenCount": 1450},
                ],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.006482, input_cost=0.003962, output_cost=0.00252, prompt_tokens=1546, completion_tokens=210
    ),
)

GEMINI_GEMINI_3_1_PRO_IMAGE_INPUT: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-image_input",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "0c05c06c97fa summarize the attached material in one line and name the city weather",
                    },
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAMK0lEQVR4nAEgDN/zAM0HLNi+b59irEwJwoIG5+NVlKprNC9dCjpeSEL6tCj3YubiguXBZXx4w6lns2cR6zkGp8hgPXHUCeelTYe9wfcEQgJ6rx+pW3+GWJV430PkExZ66Nnc6zd2KDOBGnGnIwBzhiZIL2HGI3lifMEk1EYYPG5NnqGlpcz3LiFAwwS9/Goh5egSF1aINdSX+yErhrSeZWrPBkEWmgtZ9OYpQ58l2dRlT+yNSBn7QNa6ssjgEhxEGuYUp7jZKpIZrx7Oh1QAV1jeeB7zT4/0jccZhxGSWqLiJW9VRPJQuRZjnL/J8qO8F7vpSKdYNMGDc/cEMXKNBlAdehNaVHGe84Tdmm53hcOfr0ICjvEPuk0WzuaDIOumjneMSZ1+6qg8mAM8quAXAOyQPrjRNxDXsUwZZhYr07VMCinT0OP4yIEWDKvlaxGgReVKAJ1JpZx/Hlt+evT70yo3G94iWEhVavFwPnqJ87rKl0B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pZwHLa6PI2w+uFmJZbBsaruCVPW+FL+zSfvPO560ABJLD6nKsReNBwoxShnNi1XPSmX+C7Ij/ik2nfzubk6IFlomrI0bs386ztTMDifWKNO0ZnC+Oau6ZgwE4PwF8AqKtGFd5yqG0aMFq9rvwPb8DZCXmUHN5Uc40cNG5HWNSAK1yFAkCcG2GPV/7JYEi3t9ZA8NBeh9Dmvsjv8jiaeknPCij14x6BmGOFzyVNqRcS8x517fM39S0cC6bzu8wbnh96fwQ9z/JzCEsqxV9KjuES+xv3rYkX+r3JxcK7p78EACPip85gRBoIU7cZgrwLepMArrpA9YvR8Icag3YILzWcgXVoVRTs6Xc2PsiKasZ98y5CBkmP9Ri3lwZ9acgvPJ1fw729yDzDl/0qEeBOf7ZYZ7dreaPeaGHIymfgKAwmwhnjvAGaqLWhgAAAABJRU5ErkJggg==",
                            "detail": "high",
                        },
                    },
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 0c05c06c97fa"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 2116,
                "candidatesTokenCount": 240,
                "totalTokenCount": 2356,
                "promptTokensDetails": [
                    {"modality": "TEXT", "tokenCount": 310},
                    {"modality": "IMAGE", "tokenCount": 1806},
                ],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.0074732, input_cost=0.0045932, output_cost=0.00288, prompt_tokens=2116, completion_tokens=240
    ),
)

GEMINI_GEMINI_3_1_PRO_VIDEO_INPUT: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-video_input",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "7c49c7c888f4 summarize the attached material in one line and name the city weather",
                    },
                    {
                        "type": "file",
                        "file": {
                            "file_data": "data:video/mp4;base64,AAAAGGZ0eXBpc29tAAACAGlzb21pc282AAACCG1kYXQNFBsiKTA3PkVMU1phaG92fYSLkpmgp661vMPK0djf5u30+wIJEBceJSwzOkFIT1ZdZGtyeYCHjpWco6qxuL/GzdTb4unw9/4FDBMaISgvNj1ES1JZYGdudXyDipGYn6attLvCydDX3uXs8/oBCA8WHSQrMjlAR05VXGNqcXh/ho2Um6KpsLe+xczT2uHo7/b9BAsSGSAnLjU8Q0pRWF9mbXR7gomQl56lrLO6wcjP1t3k6/L5AAcOFRwjKjE4P0ZNVFtiaXB3foWMk5qhqK+2vcTL0tng5+71/AMKERgfJi00O0JJUFdeZWxzeoGIj5adpKuyucDHztXc4+rx+P8GDRQbIikwNz5FTFNaYWhvdn2Ei5KZoKeutbzDytHY3+bt9PsCCRAXHiUsMzpBSE9WXWRrcnmAh46VnKOqsbi/xs3U2+Lp8Pf+BQwTGiEoLzY9REtSWWBnbnV8g4qRmJ+mrbS7wsnQ197l7PP6AQgPFh0kKzI5QEdOVVxjanF4f4aNlJuiqbC3vsXM09rh6O/2/QQLEhkgJy41PENKUVhfZm10e4KJkJeepayzusHIz9bd5Ovy+QAHDhUcIyoxOD9GTVRbYmlwd36FjJOaoaivtr3Ey9LZ4Ofu9fwDChEYHyYtNDtCSVBXXmVsc3qBiI+WnaSrsrnAx87V3OPq8fj/Bg==",
                            "format": "mp4",
                        },
                    },
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 7c49c7c888f4"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 8060,
                "candidatesTokenCount": 300,
                "totalTokenCount": 8360,
                "promptTokensDetails": [
                    {"modality": "TEXT", "tokenCount": 140},
                    {"modality": "VIDEO", "tokenCount": 7920},
                ],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.022888, input_cost=0.019288, output_cost=0.0036, prompt_tokens=8060, completion_tokens=300
    ),
)

GEMINI_GEMINI_3_1_PRO_REASONING: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-reasoning",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "000113942d5d summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "reasoning_effort": "medium",
        "allowed_openai_params": ["reasoning_effort"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 000113942d5d"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1240,
                "candidatesTokenCount": 560,
                "thoughtsTokenCount": 3480,
                "totalTokenCount": 5280,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1240}],
                "serviceTier": "standard",
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.05444, input_cost=0.00248, output_cost=0.05196, prompt_tokens=1240, completion_tokens=4040
    ),
)

GEMINI_GEMINI_3_1_PRO_TIERED_INPUT_ABOVE_200K: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-tiered_input_above_200k",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "1dc16abc4658 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 1dc16abc4658"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 204800,
                "candidatesTokenCount": 620,
                "totalTokenCount": 205420,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 204800}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.83036, input_cost=0.8192, output_cost=0.01116, prompt_tokens=204800, completion_tokens=620
    ),
)

GEMINI_GEMINI_3_1_PRO_TIERED_CACHE_READ_ABOVE_200K: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-tiered_cache_read_above_200k",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "e0ceec272f4b summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer e0ceec272f4b"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 205824,
                "candidatesTokenCount": 480,
                "totalTokenCount": 206304,
                "cachedContentTokenCount": 201728,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 205824}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.1057152, input_cost=0.0970752, output_cost=0.00864, prompt_tokens=205824, completion_tokens=480
    ),
)

GEMINI_GEMINI_3_1_PRO_SERVICE_TIER_FLEX: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-service_tier_flex",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "888d93f4c060 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 888d93f4c060"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                "trafficType": "ON_DEMAND_FLEX",
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.004312, input_cost=0.00184, output_cost=0.002472, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-service_tier_priority",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "68dfafa41eed summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 68dfafa41eed"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                "trafficType": "ON_DEMAND_PRIORITY",
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.01078, input_cost=0.0046, output_cost=0.00618, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_WEB_SEARCH_MEDIUM: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-web_search_medium",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "3d8a4ab5a9b2 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [{"googleSearch": {}}],
        "allowed_openai_params": ["web_search_options"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 3d8a4ab5a9b2"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                    "groundingMetadata": {"webSearchQueries": ["query 0", "query 1", "query 2"]},
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.113624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_GOOGLE_MAPS_GROUNDING: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-google_maps_grounding",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "982de823fd3b summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [{"googleMaps": {}}],
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 982de823fd3b"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                    "groundingMetadata": {
                        "webSearchQueries": ["maps query 0"],
                        "groundingChunks": [{"maps": {"uri": "https://maps.google.com/?cid=0"}}],
                        "googleMapsWidgetContextToken": "token_$REQUEST_ID",
                    },
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.033624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_STREAM: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "93682132cbf8 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer 93682132cbf8"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 412,
                    "totalTokenCount": 2252,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.1-pro",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.008624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_STREAM_NO_USAGE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream_no_usage",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "661f87e3dcf5 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer 661f87e3dcf5"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            }
        ),
    ),
    expected=RecountExpected(recount=RecountRates(input_cost_per_token=2e-06, output_cost_per_token=1.2e-05)),
)

GEMINI_GEMINI_3_1_PRO_STREAM_NO_USAGE_TOOL_CALL: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream_no_usage_tool_call",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "9fc58c44c867 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": True,
        "stream_options": {"include_usage": True},
        "tools": [
            {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "description": "Get the current weather and a short forecast for a city.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "city": {"type": "string", "description": "City name"},
                            "days": {"type": "integer", "description": "Forecast horizon in days"},
                            "units": {"type": "string", "enum": ["metric", "imperial"]},
                        },
                        "required": ["city"],
                    },
                },
            }
        ],
        "tool_choice": "auto",
        "allowed_openai_params": ["tool_choice"],
    },
    response=SseResponse(
        content_type="text/event-stream",
        frames=sse_frames(
            {
                "candidates": [
                    {
                        "content": {
                            "parts": [
                                {
                                    "functionCall": {
                                        "name": "get_weather",
                                        "args": {
                                            "city": "Berlin",
                                            "days": 7,
                                            "units": "metric",
                                            "notes": "filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler ",
                                        },
                                    }
                                }
                            ],
                            "role": "model",
                        },
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            }
        ),
    ),
    expected=RecountExpected(recount=RecountRates(input_cost_per_token=2e-06, output_cost_per_token=1.2e-05)),
)

GEMINI_GEMINI_3_1_PRO_STREAM_NO_USAGE_IMAGE_INPUT: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream_no_usage_image_input",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "5aced106bb93 summarize the attached material in one line and name the city weather",
                    },
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAMK0lEQVR4nAEgDN/zAM0HLNi+b59irEwJwoIG5+NVlKprNC9dCjpeSEL6tCj3YubiguXBZXx4w6lns2cR6zkGp8hgPXHUCeelTYe9wfcEQgJ6rx+pW3+GWJV430PkExZ66Nnc6zd2KDOBGnGnIwBzhiZIL2HGI3lifMEk1EYYPG5NnqGlpcz3LiFAwwS9/Goh5egSF1aINdSX+yErhrSeZWrPBkEWmgtZ9OYpQ58l2dRlT+yNSBn7QNa6ssjgEhxEGuYUp7jZKpIZrx7Oh1QAV1jeeB7zT4/0jccZhxGSWqLiJW9VRPJQuRZjnL/J8qO8F7vpSKdYNMGDc/cEMXKNBlAdehNaVHGe84Tdmm53hcOfr0ICjvEPuk0WzuaDIOumjneMSZ1+6qg8mAM8quAXAOyQPrjRNxDXsUwZZhYr07VMCinT0OP4yIEWDKvlaxGgReVKAJ1JpZx/Hlt+evT70yo3G94iWEhVavFwPnqJ87rKl0BT6+ohtOgz197MvB8QzMXpME/BwepPYkiRLpbBOAD37hU9bAWozdK3sPczg3okfSudzcFjAYtEIq5yw+1ZF9EYmBSexEP+IhnvUWC4BeDWZQiCjhF7/4syzu4C5kF9ETfrG+udK0232R+NA+uESn014bRJmPMfahYljDojL1UAbuaA0PuOGOzBBlCKXAkFNHIfvvZHQafMkl9qmqdFF4x3Em6WDuijSQXN6nFtM3UXbUGmmCF4Rcyl4YhifPspUXLdXZMIvPo9zAhTSlQFEi8m83sw5KxL0rWBzS9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3rYkX+r3JxcK7p78EACPip85gRBoIU7cZgrwLepMArrpA9YvR8Icag3YILzWcgXVoVRTs6Xc2PsiKasZ98y5CBkmP9Ri3lwZ9acgvPJ1fw729yDzDl/0qEeBOf7ZYZ7dreaPeaGHIymfgKAwmwhnjvAGaqLWhgAAAABJRU5ErkJggg==",
                            "detail": "high",
                        },
                    },
                ],
            },
        ],
        "stream": True,
        "stream_options": {"include_usage": True},
        "allowed_openai_params": [],
    },
    response=SseResponse(
        content_type="text/event-stream",
        frames=sse_frames(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer 5aced106bb93"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            }
        ),
    ),
    expected=RecountExpected(recount=RecountRates(input_cost_per_token=2e-06, output_cost_per_token=1.2e-05)),
)

GEMINI_GEMINI_3_1_PRO_PROMPT_BLOCKED: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-prompt_blocked",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "0b401759be94 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "promptFeedback": {
                "blockReason": "SAFETY",
                "safetyRatings": [{"category": "HARM_CATEGORY_HARASSMENT", "probability": "HIGH", "blocked": True}],
            },
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 0,
                "totalTokenCount": 1840,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(spend=0.00368, input_cost=0.00368, output_cost=0.0, prompt_tokens=1840, completion_tokens=0),
)

GEMINI_GEMINI_3_1_PRO_STREAM_PROMPT_BLOCKED: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream_prompt_blocked",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "46376a43606c 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(
            {
                "promptFeedback": {
                    "blockReason": "SAFETY",
                    "safetyRatings": [{"category": "HARM_CATEGORY_HARASSMENT", "probability": "HIGH", "blocked": True}],
                },
                "modelVersion": "gemini-3.1-pro",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 0,
                    "totalTokenCount": 1840,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.1-pro",
            },
        ),
    ),
    expected=ExactExpected(spend=0.00368, input_cost=0.00368, output_cost=0.0, prompt_tokens=1840, completion_tokens=0),
)

GEMINI_GEMINI_3_1_PRO_RESPONSE_MODEL_OVERRIDE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-response_model_override",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "da151058cfb9 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer da151058cfb9"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.002156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_STREAM_RESPONSE_MODEL_OVERRIDE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream_response_model_override",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "d2aaa2ca1279 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer d2aaa2ca1279"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.8-flash",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 412,
                    "totalTokenCount": 2252,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.8-flash",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.002156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_TOOL_CALL: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-tool_call",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "4fe80308a236 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [
            {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "description": "Get the current weather and a short forecast for a city.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "city": {"type": "string", "description": "City name"},
                            "days": {"type": "integer", "description": "Forecast horizon in days"},
                            "units": {"type": "string", "enum": ["metric", "imperial"]},
                        },
                        "required": ["city"],
                    },
                },
            }
        ],
        "tool_choice": "auto",
        "allowed_openai_params": ["tool_choice"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {
                        "parts": [
                            {
                                "functionCall": {
                                    "name": "get_weather",
                                    "args": {
                                        "city": "Berlin",
                                        "days": 7,
                                        "units": "metric",
                                        "notes": "filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler ",
                                    },
                                }
                            }
                        ],
                        "role": "model",
                    },
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.008624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_STREAM_TOOL_CALL: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream_tool_call",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "f0ddadf59ebc summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": True,
        "stream_options": {"include_usage": True},
        "tools": [
            {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "description": "Get the current weather and a short forecast for a city.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "city": {"type": "string", "description": "City name"},
                            "days": {"type": "integer", "description": "Forecast horizon in days"},
                            "units": {"type": "string", "enum": ["metric", "imperial"]},
                        },
                        "required": ["city"],
                    },
                },
            }
        ],
        "tool_choice": "auto",
        "allowed_openai_params": ["tool_choice"],
    },
    response=SseResponse(
        content_type="text/event-stream",
        frames=sse_frames(
            {
                "candidates": [
                    {
                        "content": {
                            "parts": [
                                {
                                    "functionCall": {
                                        "name": "get_weather",
                                        "args": {
                                            "city": "Berlin",
                                            "days": 7,
                                            "units": "metric",
                                            "notes": "filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler ",
                                        },
                                    }
                                }
                            ],
                            "role": "model",
                        },
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 412,
                    "totalTokenCount": 2252,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.1-pro",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.008624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_1_PRO_STREAM_FULL_USAGE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-stream_full_usage",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    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": "47de5dc94825 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer 47de5dc94825"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 8314,
                    "candidatesTokenCount": 412,
                    "thoughtsTokenCount": 900,
                    "totalTokenCount": 9626,
                    "cachedContentTokenCount": 6144,
                    "promptTokensDetails": [
                        {"modality": "TEXT", "tokenCount": 7984},
                        {"modality": "AUDIO", "tokenCount": 330},
                    ],
                },
                "modelVersion": "gemini-3.1-pro",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.0224108, input_cost=0.0057668, output_cost=0.016644, prompt_tokens=8314, completion_tokens=1312
    ),
)

GEMINI_3_1_PRO_PASSTHROUGH_GENERATE_CONTENT_PRICED_VIA_GEMINI_KEY: Final = CostTrackingTestCase(
    name="gemini-3.1-pro-passthrough-generate_content_priced_via_gemini_key",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    endpoint="/gemini/v1beta/models/$MODEL:generateContent",
    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": "5fdf6b7dd9b9 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 5fdf6b7dd9b9"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.008624,
        input_cost=0.00368,
        output_cost=0.004944,
        prompt_tokens=1840,
        completion_tokens=412,
        breakdown_persisted=False,
        cost_header=False,
    ),
)

GEMINI_3_1_PRO_PASSTHROUGH_STREAM_GENERATE_CONTENT_PRICED_VIA_GEMINI_KEY: Final = CostTrackingTestCase(
    name="gemini-3.1-pro-passthrough-stream_generate_content_priced_via_gemini_key",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.1-pro",
    endpoint="/gemini/v1beta/models/$MODEL:streamGenerateContent?alt=sse",
    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": "52b6a80ff038 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer 52b6a80ff038"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 412,
                    "totalTokenCount": 2252,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.1-pro",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.008624,
        input_cost=0.00368,
        output_cost=0.004944,
        prompt_tokens=1840,
        completion_tokens=412,
        breakdown_persisted=False,
        cost_header=False,
    ),
)


# gemini/gemini-3.8-flash
GEMINI_GEMINI_3_8_FLASH_INPUT_TEXT: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-input_text",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "3944829b75e5 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 3944829b75e5"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                "serviceTier": "standard",
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.002156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_CACHE_READ: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-cache_read",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "24a568396212 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 24a568396212"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 12928,
                "candidatesTokenCount": 380,
                "totalTokenCount": 13308,
                "cachedContentTokenCount": 12288,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 12928}],
                "serviceTier": "standard",
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.0020744, input_cost=0.0009344, output_cost=0.00114, prompt_tokens=12928, completion_tokens=380
    ),
)





GEMINI_GEMINI_3_8_FLASH_REASONING: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-reasoning",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "518ba3ee4c33 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "reasoning_effort": "medium",
        "allowed_openai_params": ["reasoning_effort"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 518ba3ee4c33"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1240,
                "candidatesTokenCount": 560,
                "thoughtsTokenCount": 3480,
                "totalTokenCount": 5280,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1240}],
                "serviceTier": "standard",
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.01448, input_cost=0.00062, output_cost=0.01386, prompt_tokens=1240, completion_tokens=4040
    ),
)

GEMINI_GEMINI_3_8_FLASH_SERVICE_TIER_FLEX: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-service_tier_flex",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "ed5fc114b878 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer ed5fc114b878"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                "trafficType": "ON_DEMAND_FLEX",
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.001078, input_cost=0.00046, output_cost=0.000618, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_SERVICE_TIER_PRIORITY: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-service_tier_priority",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "c8b02e840d2c summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer c8b02e840d2c"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                "trafficType": "ON_DEMAND_PRIORITY",
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.002695, input_cost=0.00115, output_cost=0.001545, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_WEB_SEARCH_PER_PROMPT: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-web_search_per_prompt",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "4c0023a5b762 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [{"googleSearch": {}}],
        "allowed_openai_params": ["web_search_options"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 4c0023a5b762"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                    "groundingMetadata": {"webSearchQueries": ["query 0", "query 1", "query 2"]},
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.037156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_GOOGLE_MAPS_GROUNDING: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-google_maps_grounding",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "b8da7a958abf summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [{"googleMaps": {}}],
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer b8da7a958abf"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                    "groundingMetadata": {
                        "webSearchQueries": ["maps query 0"],
                        "groundingChunks": [{"maps": {"uri": "https://maps.google.com/?cid=0"}}],
                        "googleMapsWidgetContextToken": "token_$REQUEST_ID",
                    },
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.027156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_STREAM: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-stream",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "eacbb9f405ad 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer eacbb9f405ad"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.8-flash",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 412,
                    "totalTokenCount": 2252,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                    "serviceTier": "standard",
                },
                "modelVersion": "gemini-3.8-flash",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.002156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_STREAM_NO_USAGE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-stream_no_usage",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "837d58c93751 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer 837d58c93751"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.8-flash",
            }
        ),
    ),
    expected=RecountExpected(recount=RecountRates(input_cost_per_token=5e-07, output_cost_per_token=3e-06)),
)

GEMINI_GEMINI_3_8_FLASH_STREAM_NO_USAGE_TOOL_CALL: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-stream_no_usage_tool_call",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "5d097120da02 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": True,
        "stream_options": {"include_usage": True},
        "tools": [
            {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "description": "Get the current weather and a short forecast for a city.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "city": {"type": "string", "description": "City name"},
                            "days": {"type": "integer", "description": "Forecast horizon in days"},
                            "units": {"type": "string", "enum": ["metric", "imperial"]},
                        },
                        "required": ["city"],
                    },
                },
            }
        ],
        "tool_choice": "auto",
        "allowed_openai_params": ["tool_choice"],
    },
    response=SseResponse(
        content_type="text/event-stream",
        frames=sse_frames(
            {
                "candidates": [
                    {
                        "content": {
                            "parts": [
                                {
                                    "functionCall": {
                                        "name": "get_weather",
                                        "args": {
                                            "city": "Berlin",
                                            "days": 7,
                                            "units": "metric",
                                            "notes": "filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler ",
                                        },
                                    }
                                }
                            ],
                            "role": "model",
                        },
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.8-flash",
            }
        ),
    ),
    expected=RecountExpected(recount=RecountRates(input_cost_per_token=5e-07, output_cost_per_token=3e-06)),
)


GEMINI_GEMINI_3_8_FLASH_PROMPT_BLOCKED: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-prompt_blocked",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "7dc69adaf49c summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "promptFeedback": {
                "blockReason": "SAFETY",
                "safetyRatings": [{"category": "HARM_CATEGORY_HARASSMENT", "probability": "HIGH", "blocked": True}],
            },
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 0,
                "totalTokenCount": 1840,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(spend=0.00092, input_cost=0.00092, output_cost=0.0, prompt_tokens=1840, completion_tokens=0),
)

GEMINI_GEMINI_3_8_FLASH_STREAM_PROMPT_BLOCKED: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-stream_prompt_blocked",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "23065669b96e 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(
            {
                "promptFeedback": {
                    "blockReason": "SAFETY",
                    "safetyRatings": [{"category": "HARM_CATEGORY_HARASSMENT", "probability": "HIGH", "blocked": True}],
                },
                "modelVersion": "gemini-3.8-flash",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 0,
                    "totalTokenCount": 1840,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.8-flash",
            },
        ),
    ),
    expected=ExactExpected(spend=0.00092, input_cost=0.00092, output_cost=0.0, prompt_tokens=1840, completion_tokens=0),
)

GEMINI_GEMINI_3_8_FLASH_RESPONSE_MODEL_OVERRIDE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-response_model_override",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "290ca0555ee8 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 290ca0555ee8"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.1-pro",
        },
    ),
    expected=ExactExpected(
        spend=0.008624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_STREAM_RESPONSE_MODEL_OVERRIDE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-stream_response_model_override",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "ec61060b88e9 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer ec61060b88e9"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.1-pro",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 412,
                    "totalTokenCount": 2252,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.1-pro",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.008624, input_cost=0.00368, output_cost=0.004944, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_TOOL_CALL: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-tool_call",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "670f41936a6d summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [
            {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "description": "Get the current weather and a short forecast for a city.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "city": {"type": "string", "description": "City name"},
                            "days": {"type": "integer", "description": "Forecast horizon in days"},
                            "units": {"type": "string", "enum": ["metric", "imperial"]},
                        },
                        "required": ["city"],
                    },
                },
            }
        ],
        "tool_choice": "auto",
        "allowed_openai_params": ["tool_choice"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {
                        "parts": [
                            {
                                "functionCall": {
                                    "name": "get_weather",
                                    "args": {
                                        "city": "Berlin",
                                        "days": 7,
                                        "units": "metric",
                                        "notes": "filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler ",
                                    },
                                }
                            }
                        ],
                        "role": "model",
                    },
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1840,
                "candidatesTokenCount": 412,
                "totalTokenCount": 2252,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
            },
            "modelVersion": "gemini-3.8-flash",
        },
    ),
    expected=ExactExpected(
        spend=0.002156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_STREAM_TOOL_CALL: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-stream_tool_call",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "8cdfceec775e summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": True,
        "stream_options": {"include_usage": True},
        "tools": [
            {
                "type": "function",
                "function": {
                    "name": "get_weather",
                    "description": "Get the current weather and a short forecast for a city.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "city": {"type": "string", "description": "City name"},
                            "days": {"type": "integer", "description": "Forecast horizon in days"},
                            "units": {"type": "string", "enum": ["metric", "imperial"]},
                        },
                        "required": ["city"],
                    },
                },
            }
        ],
        "tool_choice": "auto",
        "allowed_openai_params": ["tool_choice"],
    },
    response=SseResponse(
        content_type="text/event-stream",
        frames=sse_frames(
            {
                "candidates": [
                    {
                        "content": {
                            "parts": [
                                {
                                    "functionCall": {
                                        "name": "get_weather",
                                        "args": {
                                            "city": "Berlin",
                                            "days": 7,
                                            "units": "metric",
                                            "notes": "filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler filler ",
                                        },
                                    }
                                }
                            ],
                            "role": "model",
                        },
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.8-flash",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 1840,
                    "candidatesTokenCount": 412,
                    "totalTokenCount": 2252,
                    "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1840}],
                },
                "modelVersion": "gemini-3.8-flash",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.002156, input_cost=0.00092, output_cost=0.001236, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_STREAM_FULL_USAGE: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-stream_full_usage",
    covers="quota_management.spend_tracking.scripted_wire.logs_cost",
    model="gemini/gemini-3.8-flash",
    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": "0b11ac8b4a63 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(
            {
                "candidates": [
                    {
                        "content": {"parts": [{"text": "scripted answer 0b11ac8b4a63"}], "role": "model"},
                        "finishReason": "STOP",
                        "index": 0,
                    }
                ],
                "modelVersion": "gemini-3.8-flash",
            },
            {
                "candidates": [],
                "usageMetadata": {
                    "promptTokenCount": 8314,
                    "candidatesTokenCount": 692,
                    "thoughtsTokenCount": 900,
                    "totalTokenCount": 9906,
                    "cachedContentTokenCount": 6144,
                    "promptTokensDetails": [
                        {"modality": "TEXT", "tokenCount": 7984},
                        {"modality": "AUDIO", "tokenCount": 330},
                    ],
                    "candidatesTokensDetails": [
                        {"modality": "TEXT", "tokenCount": 412},
                        {"modality": "AUDIO", "tokenCount": 280},
                    ],
                },
                "modelVersion": "gemini-3.8-flash",
            },
        ),
    ),
    expected=ExactExpected(
        spend=0.0066182, input_cost=0.0013922, output_cost=0.005226, prompt_tokens=8314, completion_tokens=1592
    ),
)


# gemini/gemini-embedding-002
GEMINI_EMBEDDINGS_002: Final = CostTrackingTestCase(
    name="gemini-embeddings-002",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-embedding-002",
    endpoint="/v1/embeddings",
    request={"model": "$MODEL", "input": "gemini embedding"},
    response=JsonResponse(
        content_type="application/json",
        body={
            "embeddings": [{"values": [0.1, 0.2, 0.3]}],
            "usageMetadata": {"promptTokenCount": 7, "totalTokenCount": 7},
        },
    ),
    expected=ExactExpected(spend=3.24e-06, input_cost=3.24e-06, output_cost=0.0, prompt_tokens=3, completion_tokens=0),
)


# gemini/gemini-3.8-flash-lite
GEMINI_GEMINI_3_8_FLASH_LITE_INPUT_BELOW_128K: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-lite-input_below_128k",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash-lite",
    request={
        "model": "$MODEL",
        "messages": [{"role": "user", "content": "base pricing"}],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {"content": {"parts": [{"text": "ok"}], "role": "model"}, "finishReason": "STOP", "index": 0}
            ],
            "usageMetadata": {"promptTokenCount": 1840, "candidatesTokenCount": 412, "totalTokenCount": 2252},
            "modelVersion": "gemini-3.8-flash-lite",
        },
    ),
    expected=ExactExpected(
        spend=0.00038368, input_cost=0.0002024, output_cost=0.00018128, prompt_tokens=1840, completion_tokens=412
    ),
)

GEMINI_GEMINI_3_8_FLASH_LITE_INPUT_ABOVE_128K: Final = CostTrackingTestCase(
    name="gemini-gemini-3.8-flash-lite-input_above_128k",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.8-flash-lite",
    request={
        "model": "$MODEL",
        "messages": [{"role": "user", "content": "above threshold"}],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {"content": {"parts": [{"text": "ok"}], "role": "model"}, "finishReason": "STOP", "index": 0}
            ],
            "usageMetadata": {"promptTokenCount": 130000, "candidatesTokenCount": 412, "totalTokenCount": 130412},
            "modelVersion": "gemini-3.8-flash-lite",
        },
    ),
    expected=ExactExpected(
        spend=0.02896256, input_cost=0.0286, output_cost=0.00036256, prompt_tokens=130000, completion_tokens=412
    ),
)


# gemini/gemini-nano-banana-2.1
GEMINI_NANO_BANANA_2_1_INPUT_TEXT: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-input_text",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "8e41cbb0a701 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 8e41cbb0a701"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 2000,
                "candidatesTokenCount": 100,
                "totalTokenCount": 2100,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 2000}],
                "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.00375, input_cost=0.003, output_cost=0.00075, prompt_tokens=2000, completion_tokens=100
    ),
)

GEMINI_NANO_BANANA_2_1_IMAGE_INPUT: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-image_input",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "3f6c2d91a40e summarize the attached material in one line and name the city weather",
                    },
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+yVWQAAAAASUVORK5CYII=",
                            "detail": "high",
                        },
                    },
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer 3f6c2d91a40e"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 1680,
                "candidatesTokenCount": 100,
                "totalTokenCount": 1780,
                "promptTokensDetails": [
                    {"modality": "TEXT", "tokenCount": 560},
                    {"modality": "IMAGE", "tokenCount": 1120},
                ],
                "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.00327, input_cost=0.00252, output_cost=0.00075, prompt_tokens=1680, completion_tokens=100
    ),
)

GEMINI_NANO_BANANA_2_1_OUTPUT_TEXT: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-output_text",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "d05a38c7e219 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer d05a38c7e219"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 4000,
                "totalTokenCount": 4100,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 4000}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.03015, input_cost=0.00015, output_cost=0.03, prompt_tokens=100, completion_tokens=4000
    ),
)

GEMINI_NANO_BANANA_2_1_REASONING: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-reasoning",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "c71e4f0092ba summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "reasoning_effort": "medium",
        "allowed_openai_params": ["reasoning_effort"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer c71e4f0092ba"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 200,
                "thoughtsTokenCount": 1800,
                "totalTokenCount": 2100,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 200}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.01515, input_cost=0.00015, output_cost=0.015, prompt_tokens=100, completion_tokens=2000
    ),
)

GEMINI_NANO_BANANA_2_1_IMAGE_OUTPUT_1K: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-image_output_1k",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "6a9f2c13b847 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {
                        "parts": [{"inlineData": {"mimeType": "image/png", "data": "aGVsbG8="}}],
                        "role": "model",
                    },
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 1120,
                "totalTokenCount": 1220,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [{"modality": "IMAGE", "tokenCount": 1120}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.03375, input_cost=0.00015, output_cost=0.0336, prompt_tokens=100, completion_tokens=1120
    ),
)

GEMINI_NANO_BANANA_2_1_IMAGE_OUTPUT_2K: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-image_output_2k",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "24df708bc351 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {
                        "parts": [{"inlineData": {"mimeType": "image/png", "data": "aGVsbG8="}}],
                        "role": "model",
                    },
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 1680,
                "totalTokenCount": 1780,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [{"modality": "IMAGE", "tokenCount": 1680}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.05055, input_cost=0.00015, output_cost=0.0504, prompt_tokens=100, completion_tokens=1680
    ),
)

GEMINI_NANO_BANANA_2_1_IMAGE_OUTPUT_4K: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-image_output_4k",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "b8a315e4706c summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {
                        "parts": [{"inlineData": {"mimeType": "image/png", "data": "aGVsbG8="}}],
                        "role": "model",
                    },
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 2520,
                "totalTokenCount": 2620,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [{"modality": "IMAGE", "tokenCount": 2520}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.07575, input_cost=0.00015, output_cost=0.0756, prompt_tokens=100, completion_tokens=2520
    ),
)

GEMINI_NANO_BANANA_2_1_MIXED_TEXT_IMAGE_OUTPUT: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-mixed_text_image_output",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "91ce62a50d3b summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {
                        "parts": [
                            {"text": "scripted answer 91ce62a50d3b"},
                            {"inlineData": {"mimeType": "image/png", "data": "aGVsbG8="}},
                        ],
                        "role": "model",
                    },
                    "finishReason": "STOP",
                    "index": 0,
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 1220,
                "thoughtsTokenCount": 300,
                "totalTokenCount": 1620,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [
                    {"modality": "TEXT", "tokenCount": 100},
                    {"modality": "IMAGE", "tokenCount": 1120},
                ],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.03675, input_cost=0.00015, output_cost=0.0366, prompt_tokens=100, completion_tokens=1520
    ),
)

GEMINI_NANO_BANANA_2_1_WEB_SEARCH_SINGLE_QUERY: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-web_search_single_query",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "f407b19d8e26 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [{"googleSearch": {}}],
        "allowed_openai_params": ["web_search_options"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer f407b19d8e26"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                    "groundingMetadata": {"webSearchQueries": ["query 0"]},
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 100,
                "totalTokenCount": 200,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.0149,
        input_cost=0.00015,
        output_cost=0.00075,
        tool_usage_cost=0.014,
        prompt_tokens=100,
        completion_tokens=100,
    ),
)

GEMINI_NANO_BANANA_2_1_WEB_SEARCH_MULTIPLE_QUERIES: Final = CostTrackingTestCase(
    name="gemini-nano-banana-2.1-web_search_multiple_queries",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-nano-banana-2.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": "a36d5f80c297 summarize the attached material in one line and name the city weather",
                    }
                ],
            },
        ],
        "stream": False,
        "tools": [{"googleSearch": {}}],
        "allowed_openai_params": ["web_search_options"],
    },
    response=JsonResponse(
        content_type="application/json",
        body={
            "candidates": [
                {
                    "content": {"parts": [{"text": "scripted answer a36d5f80c297"}], "role": "model"},
                    "finishReason": "STOP",
                    "index": 0,
                    "groundingMetadata": {"webSearchQueries": ["query 0", "query 1", "query 2", "query 3"]},
                }
            ],
            "usageMetadata": {
                "promptTokenCount": 100,
                "candidatesTokenCount": 100,
                "totalTokenCount": 200,
                "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
                "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 100}],
            },
            "modelVersion": "gemini-nano-banana-2.1",
        },
    ),
    expected=ExactExpected(
        spend=0.0569,
        input_cost=0.00015,
        output_cost=0.00075,
        tool_usage_cost=0.056,
        prompt_tokens=100,
        completion_tokens=100,
    ),
)


GEMINI_GEMINI_3_1_PRO_CACHE_CREATION: Final = CostTrackingTestCase(
    name="gemini-gemini-3.1-pro-cache_creation",
    covers="quota_management.spend_tracking.cost_matrix.logs_cost",
    model="gemini/gemini-3.1-pro",
    request={
        "model": "$MODEL",
        "messages": [
            {
                "role": "system",
                "content": [
                    {
                        "type": "text",
                        "text": "cacheable pricing-harness prefix " * 1000,
                        "cache_control": {"type": "ephemeral"},
                    }
                ],
            },
            {
                "role": "user",
                "content": [{"type": "text", "text": "9c1d4e7a2b60 answer from the cached prefix in one line"}],
            },
        ],
        "stream": False,
        "allowed_openai_params": [],
    },
    response=RoutedResponse(
        content_type="application/x-routed",
        routes={
            "GET /models/gemini-3.1-pro:cachedContents": JsonResponse(
                content_type="application/json", body={"cachedContents": []}
            ),
            "POST /models/gemini-3.1-pro:cachedContents": JsonResponse(
                content_type="application/json",
                body={
                    "name": "cachedContents/$REQUEST_ID",
                    "model": "models/gemini-3.1-pro",
                    "createTime": "2026-10-13T00:00:00Z",
                    "expireTime": "2026-10-13T01:00:00Z",
                    "usageMetadata": {"totalTokenCount": 1280},
                },
            ),
            "POST /models/gemini-3.1-pro:generateContent": JsonResponse(
                content_type="application/json",
                body={
                    "candidates": [
                        {
                            "content": {"parts": [{"text": "scripted answer 9c1d4e7a2b60"}], "role": "model"},
                            "finishReason": "STOP",
                            "index": 0,
                        }
                    ],
                    "usageMetadata": {
                        "promptTokenCount": 1536,
                        "candidatesTokenCount": 40,
                        "totalTokenCount": 1576,
                        "cachedContentTokenCount": 1280,
                        "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 1536}],
                    },
                    "modelVersion": "gemini-3.1-pro",
                },
            ),
        },
    ),
    expected=ExactExpected(
        spend=0.003808,
        input_cost=0.003328,
        output_cost=0.00048,
        cache_read_cost=0.000256,
        cache_creation_cost=0.00256,
        prompt_tokens=2816,
        completion_tokens=40,
    ),
)

GEMINI_GEMINI_4_ARGON_INPUT_TEXT: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_INPUT_TEXT, "gemini-gemini-4-argon-input_text", "gemini/gemini-4-argon",
    "gemini-4-argon", ExactExpected(spend=0.00858, input_cost=0.004048, output_cost=0.004532, prompt_tokens=1840, completion_tokens=412),
    usage_fields={"candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 412}]},
)
GEMINI_GEMINI_4_ARGON_STREAM: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_STREAM, "gemini-gemini-4-argon-stream", "gemini/gemini-4-argon",
    "gemini-4-argon", ExactExpected(spend=0.00858, input_cost=0.004048, output_cost=0.004532, prompt_tokens=1840, completion_tokens=412),
    usage_fields={"candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 412}]},
)
GEMINI_GEMINI_4_ARGON_CACHE_READ: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_CACHE_READ, "gemini-gemini-4-argon-cache_read", "gemini/gemini-4-argon",
    "gemini-4-argon", ExactExpected(spend=0.00693968, input_cost=0.00275968, output_cost=0.00418, prompt_tokens=12928, completion_tokens=380),
    usage_fields={"candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 380}]},
)
GEMINI_GEMINI_4_ARGON_REASONING: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_REASONING, "gemini-gemini-4-argon-reasoning", "gemini/gemini-4-argon",
    "gemini-4-argon", ExactExpected(spend=0.047168, input_cost=0.002728, output_cost=0.04444, prompt_tokens=1240, completion_tokens=4040),
    usage_fields={"candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 560}]},
)
GEMINI_GEMINI_4_ARGON_SERVICE_TIER_FLEX: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_SERVICE_TIER_FLEX,
    "gemini-gemini-4-argon-service_tier_flex",
    "gemini/gemini-4-argon",
    "gemini-4-argon",
    ExactExpected(spend=0.00429, input_cost=0.002024, output_cost=0.002266, prompt_tokens=1840, completion_tokens=412),
)
GEMINI_GEMINI_4_ARGON_SERVICE_TIER_PRIORITY: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_SERVICE_TIER_PRIORITY,
    "gemini-gemini-4-argon-service_tier_priority",
    "gemini/gemini-4-argon",
    "gemini-4-argon",
    ExactExpected(spend=0.015444, input_cost=0.0072864, output_cost=0.0081576, prompt_tokens=1840, completion_tokens=412),
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_SERVICE_TIER_PRIORITY: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_SERVICE_TIER_PRIORITY,
    "gemini-gemini-3.1-pro-preview-service_tier_priority",
    "gemini/gemini-3.1-pro-preview",
    "gemini-3.1-pro-preview",
    ExactExpected(
        spend=0.02018016, input_cost=0.0086112, output_cost=0.01156896, prompt_tokens=1840, completion_tokens=412
    ),
)
GEMINI_GEMINI_4_ARGON_TOOL_CALL: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_TOOL_CALL, "gemini-gemini-4-argon-tool_call", "gemini/gemini-4-argon",
    "gemini-4-argon", ExactExpected(spend=0.00858, input_cost=0.004048, output_cost=0.004532, prompt_tokens=1840, completion_tokens=412)
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_INPUT_TEXT: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_INPUT_TEXT, "gemini-gemini-3.1-pro-preview-input_text",
    "gemini/gemini-3.1-pro-preview", "gemini-3.1-pro-preview",
    ExactExpected(spend=0.0112112, input_cost=0.004784, output_cost=0.0064272, prompt_tokens=1840, completion_tokens=412),
    usage_fields={"serviceTier": "standard"},
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_STREAM: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_STREAM, "gemini-gemini-3.1-pro-preview-stream",
    "gemini/gemini-3.1-pro-preview", "gemini-3.1-pro-preview",
    ExactExpected(spend=0.0112112, input_cost=0.004784, output_cost=0.0064272, prompt_tokens=1840, completion_tokens=412),
    usage_fields={"serviceTier": "standard"},
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_CACHE_READ: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_CACHE_READ, "gemini-gemini-3.1-pro-preview-cache_read",
    "gemini/gemini-3.1-pro-preview", "gemini-3.1-pro-preview",
    ExactExpected(spend=0.01078688, input_cost=0.00485888, output_cost=0.005928, prompt_tokens=12928, completion_tokens=380),
    usage_fields={"serviceTier": "standard"},
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_REASONING: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_REASONING, "gemini-gemini-3.1-pro-preview-reasoning",
    "gemini/gemini-3.1-pro-preview", "gemini-3.1-pro-preview",
    ExactExpected(spend=0.066248, input_cost=0.003224, output_cost=0.063024, prompt_tokens=1240, completion_tokens=4040),
    usage_fields={"serviceTier": "standard"},
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_TOOL_CALL: Final = _gemini_case(
    GEMINI_GEMINI_3_8_FLASH_TOOL_CALL, "gemini-gemini-3.1-pro-preview-tool_call",
    "gemini/gemini-3.1-pro-preview", "gemini-3.1-pro-preview",
    ExactExpected(spend=0.0112112, input_cost=0.004784, output_cost=0.0064272, prompt_tokens=1840, completion_tokens=412)
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_TIERED_INPUT_ABOVE_200K: Final = _gemini_case(
    GEMINI_GEMINI_3_1_PRO_TIERED_INPUT_ABOVE_200K,
    "gemini-gemini-3.1-pro-preview-tiered_input_above_200k",
    "gemini/gemini-3.1-pro-preview",
    "gemini-3.1-pro-preview",
    ExactExpected(
        spend=1.079468, input_cost=1.06496, output_cost=0.014508, prompt_tokens=204800, completion_tokens=620
    ),
    usage_fields={"serviceTier": "standard"},
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_TIERED_CACHE_READ_ABOVE_200K: Final = _gemini_case(
    GEMINI_GEMINI_3_1_PRO_TIERED_CACHE_READ_ABOVE_200K,
    "gemini-gemini-3.1-pro-preview-tiered_cache_read_above_200k",
    "gemini/gemini-3.1-pro-preview",
    "gemini-3.1-pro-preview",
    ExactExpected(
        spend=0.13742976, input_cost=0.12619776, output_cost=0.011232, prompt_tokens=205824, completion_tokens=480
    ),
    usage_fields={"serviceTier": "standard"},
)
GEMINI_GEMINI_4_ARGON_ROUTE_BRIDGES: Final = bridge_pairs(
    (GEMINI_GEMINI_4_ARGON_INPUT_TEXT, GEMINI_GEMINI_4_ARGON_STREAM),
    ("/v1/responses", "/v1/messages"),
)
GEMINI_GEMINI_3_8_FLASH_ROUTE_BRIDGES: Final = bridge_pairs(
    (GEMINI_GEMINI_3_8_FLASH_INPUT_TEXT, GEMINI_GEMINI_3_8_FLASH_STREAM),
    ("/v1/responses", "/v1/messages"),
)
GEMINI_GEMINI_3_1_PRO_PREVIEW_ROUTE_BRIDGES: Final = bridge_pairs(
    (GEMINI_GEMINI_3_1_PRO_PREVIEW_INPUT_TEXT, GEMINI_GEMINI_3_1_PRO_PREVIEW_STREAM),
    ("/v1/responses", "/v1/messages"),
)

CASES: Final[tuple[CostTrackingTestCase, ...]] = (
    GEMINI_GEMINI_3_1_PRO_INPUT_TEXT,
    GEMINI_GEMINI_3_1_PRO_CACHE_READ,
    GEMINI_GEMINI_3_1_PRO_AUDIO_INPUT,
    GEMINI_GEMINI_3_1_PRO_IMAGE_INPUT,
    GEMINI_GEMINI_3_1_PRO_VIDEO_INPUT,
    GEMINI_GEMINI_3_1_PRO_REASONING,
    GEMINI_GEMINI_3_1_PRO_TIERED_INPUT_ABOVE_200K,
    GEMINI_GEMINI_3_1_PRO_TIERED_CACHE_READ_ABOVE_200K,
    GEMINI_GEMINI_3_1_PRO_SERVICE_TIER_FLEX,
    GEMINI_GEMINI_3_1_PRO_SERVICE_TIER_PRIORITY,
    GEMINI_GEMINI_3_1_PRO_WEB_SEARCH_MEDIUM,
    GEMINI_GEMINI_3_1_PRO_GOOGLE_MAPS_GROUNDING,
    GEMINI_GEMINI_3_1_PRO_STREAM,
    GEMINI_GEMINI_3_1_PRO_STREAM_NO_USAGE,
    GEMINI_GEMINI_3_1_PRO_STREAM_NO_USAGE_TOOL_CALL,
    GEMINI_GEMINI_3_1_PRO_STREAM_NO_USAGE_IMAGE_INPUT,
    GEMINI_GEMINI_3_1_PRO_PROMPT_BLOCKED,
    GEMINI_GEMINI_3_1_PRO_STREAM_PROMPT_BLOCKED,
    GEMINI_GEMINI_3_1_PRO_RESPONSE_MODEL_OVERRIDE,
    GEMINI_GEMINI_3_1_PRO_STREAM_RESPONSE_MODEL_OVERRIDE,
    GEMINI_GEMINI_3_1_PRO_TOOL_CALL,
    GEMINI_GEMINI_3_1_PRO_STREAM_TOOL_CALL,
    GEMINI_GEMINI_3_1_PRO_STREAM_FULL_USAGE,
    GEMINI_GEMINI_3_8_FLASH_INPUT_TEXT,
    GEMINI_GEMINI_3_8_FLASH_CACHE_READ,
    GEMINI_GEMINI_3_8_FLASH_REASONING,
    GEMINI_GEMINI_3_8_FLASH_SERVICE_TIER_FLEX,
    GEMINI_GEMINI_3_8_FLASH_SERVICE_TIER_PRIORITY,
    GEMINI_GEMINI_3_8_FLASH_WEB_SEARCH_PER_PROMPT,
    GEMINI_GEMINI_3_8_FLASH_GOOGLE_MAPS_GROUNDING,
    GEMINI_GEMINI_3_8_FLASH_STREAM,
    GEMINI_GEMINI_3_8_FLASH_STREAM_NO_USAGE,
    GEMINI_GEMINI_3_8_FLASH_STREAM_NO_USAGE_TOOL_CALL,
    GEMINI_GEMINI_3_8_FLASH_PROMPT_BLOCKED,
    GEMINI_GEMINI_3_8_FLASH_STREAM_PROMPT_BLOCKED,
    GEMINI_GEMINI_3_8_FLASH_RESPONSE_MODEL_OVERRIDE,
    GEMINI_GEMINI_3_8_FLASH_STREAM_RESPONSE_MODEL_OVERRIDE,
    GEMINI_GEMINI_3_8_FLASH_TOOL_CALL,
    GEMINI_GEMINI_3_8_FLASH_STREAM_TOOL_CALL,
    GEMINI_GEMINI_3_8_FLASH_STREAM_FULL_USAGE,
    GEMINI_EMBEDDINGS_002,
    GEMINI_3_1_PRO_PASSTHROUGH_GENERATE_CONTENT_PRICED_VIA_GEMINI_KEY,
    GEMINI_3_1_PRO_PASSTHROUGH_STREAM_GENERATE_CONTENT_PRICED_VIA_GEMINI_KEY,
    GEMINI_GEMINI_3_8_FLASH_LITE_INPUT_BELOW_128K,
    GEMINI_GEMINI_3_8_FLASH_LITE_INPUT_ABOVE_128K,
    GEMINI_NANO_BANANA_2_1_INPUT_TEXT,
    GEMINI_NANO_BANANA_2_1_IMAGE_INPUT,
    GEMINI_NANO_BANANA_2_1_OUTPUT_TEXT,
    GEMINI_NANO_BANANA_2_1_REASONING,
    GEMINI_NANO_BANANA_2_1_IMAGE_OUTPUT_1K,
    GEMINI_NANO_BANANA_2_1_IMAGE_OUTPUT_2K,
    GEMINI_NANO_BANANA_2_1_IMAGE_OUTPUT_4K,
    GEMINI_NANO_BANANA_2_1_MIXED_TEXT_IMAGE_OUTPUT,
    GEMINI_NANO_BANANA_2_1_WEB_SEARCH_SINGLE_QUERY,
    GEMINI_NANO_BANANA_2_1_WEB_SEARCH_MULTIPLE_QUERIES,
    GEMINI_GEMINI_3_1_PRO_CACHE_CREATION,
    GEMINI_GEMINI_4_ARGON_INPUT_TEXT,
    GEMINI_GEMINI_4_ARGON_STREAM,
    GEMINI_GEMINI_4_ARGON_CACHE_READ,
    GEMINI_GEMINI_4_ARGON_REASONING,
    GEMINI_GEMINI_4_ARGON_SERVICE_TIER_FLEX,
    GEMINI_GEMINI_4_ARGON_SERVICE_TIER_PRIORITY,
    GEMINI_GEMINI_4_ARGON_TOOL_CALL,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_INPUT_TEXT,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_STREAM,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_CACHE_READ,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_TIERED_INPUT_ABOVE_200K,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_TIERED_CACHE_READ_ABOVE_200K,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_REASONING,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_TOOL_CALL,
    GEMINI_GEMINI_3_1_PRO_PREVIEW_SERVICE_TIER_PRIORITY,
    *(pair.bridged for pair in GEMINI_GEMINI_4_ARGON_ROUTE_BRIDGES),
    *(pair.bridged for pair in GEMINI_GEMINI_3_8_FLASH_ROUTE_BRIDGES),
    *(pair.bridged for pair in GEMINI_GEMINI_3_1_PRO_PREVIEW_ROUTE_BRIDGES),
)

PARITY: Final[tuple[StreamParityTestCase, ...]] = (
    StreamParityTestCase(plain=GEMINI_GEMINI_3_1_PRO_INPUT_TEXT, streamed=GEMINI_GEMINI_3_1_PRO_STREAM),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_1_PRO_PROMPT_BLOCKED, streamed=GEMINI_GEMINI_3_1_PRO_STREAM_PROMPT_BLOCKED
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_1_PRO_RESPONSE_MODEL_OVERRIDE,
        streamed=GEMINI_GEMINI_3_1_PRO_STREAM_RESPONSE_MODEL_OVERRIDE,
    ),
    StreamParityTestCase(plain=GEMINI_GEMINI_3_1_PRO_TOOL_CALL, streamed=GEMINI_GEMINI_3_1_PRO_STREAM_TOOL_CALL),
    StreamParityTestCase(plain=GEMINI_GEMINI_3_8_FLASH_INPUT_TEXT, streamed=GEMINI_GEMINI_3_8_FLASH_STREAM),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_8_FLASH_PROMPT_BLOCKED, streamed=GEMINI_GEMINI_3_8_FLASH_STREAM_PROMPT_BLOCKED
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_8_FLASH_RESPONSE_MODEL_OVERRIDE,
        streamed=GEMINI_GEMINI_3_8_FLASH_STREAM_RESPONSE_MODEL_OVERRIDE,
    ),
    StreamParityTestCase(plain=GEMINI_GEMINI_3_8_FLASH_TOOL_CALL, streamed=GEMINI_GEMINI_3_8_FLASH_STREAM_TOOL_CALL),
    StreamParityTestCase(plain=GEMINI_GEMINI_4_ARGON_INPUT_TEXT, streamed=GEMINI_GEMINI_4_ARGON_STREAM),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_1_PRO_PREVIEW_INPUT_TEXT, streamed=GEMINI_GEMINI_3_1_PRO_PREVIEW_STREAM
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_4_ARGON_ROUTE_BRIDGES[0].bridged,
        streamed=GEMINI_GEMINI_4_ARGON_ROUTE_BRIDGES[2].bridged,
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_4_ARGON_ROUTE_BRIDGES[1].bridged,
        streamed=GEMINI_GEMINI_4_ARGON_ROUTE_BRIDGES[3].bridged,
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_8_FLASH_ROUTE_BRIDGES[0].bridged,
        streamed=GEMINI_GEMINI_3_8_FLASH_ROUTE_BRIDGES[2].bridged,
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_8_FLASH_ROUTE_BRIDGES[1].bridged,
        streamed=GEMINI_GEMINI_3_8_FLASH_ROUTE_BRIDGES[3].bridged,
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_1_PRO_PREVIEW_ROUTE_BRIDGES[0].bridged,
        streamed=GEMINI_GEMINI_3_1_PRO_PREVIEW_ROUTE_BRIDGES[2].bridged,
    ),
    StreamParityTestCase(
        plain=GEMINI_GEMINI_3_1_PRO_PREVIEW_ROUTE_BRIDGES[1].bridged,
        streamed=GEMINI_GEMINI_3_1_PRO_PREVIEW_ROUTE_BRIDGES[3].bridged,
    ),
)

BRIDGE_COST_PARITY: Final[tuple[BridgeCostParityTestCase, ...]] = (
    *bridge_pairs(
        (GEMINI_GEMINI_3_8_FLASH_CACHE_READ, GEMINI_GEMINI_3_8_FLASH_REASONING),
        ("/v1/responses", "/v1/messages"),
    ),
    *GEMINI_GEMINI_3_8_FLASH_ROUTE_BRIDGES,
    *GEMINI_GEMINI_4_ARGON_ROUTE_BRIDGES,
    *GEMINI_GEMINI_3_1_PRO_PREVIEW_ROUTE_BRIDGES,
)