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]

13.2 KB
Raw Blame
from typing import Final
from unittest.mock import ANY

from integration.translation.case import TranslationTestCase
from integration.translation.responses.templates import RESPONSES_NATIVE_RESPONSE, RESPONSES_REQUEST
from integration.translation.templates.openai import OPENAI_RESPONSES_REQUEST, OPENAI_RESPONSES_RESPONSE

GPT_5_6_SOL_TEST_CASE: Final = TranslationTestCase(
    scenario="basic",
    litellm_endpoint="/v1/responses",
    litellm_request={
        "model": "openai/responses/gpt-5.6-sol",
        "max_output_tokens": 64,
        "instructions": "You are a terse assistant.",
        "input": "Say hello.",
        "cache": {"no-cache": True},
    },
    expected_provider_endpoint="/responses",
    expected_provider_headers={"authorization": "Bearer synthetic-openai-key", "content-type": "application/json"},
    expected_provider_request={
        "model": "gpt-5.6-sol",
        "input": "Say hello.",
        "instructions": "You are a terse assistant.",
        "max_output_tokens": 64,
    },
    mock_provider_response={
        "id": "resp_0691e5d81d357aec006ac3f045381487d0904424fd18d4adfb",
        "object": "response",
        "created_at": 1791225925,
        "status": "completed",
        "access_programs": {"cyber": "daybreak_blue"},
        "background": False,
        "billing": {"payer": "developer"},
        "completed_at": 1791225926,
        "error": None,
        "frequency_penalty": 0.0,
        "incomplete_details": None,
        "instructions": "You are a terse assistant.",
        "max_output_tokens": 64,
        "max_tool_calls": None,
        "model": "gpt-5.6-sol",
        "moderation": None,
        "output": [
            {
                "id": "msg_0691e5d81d357aec006ac3f04611ac87d081b8e4e32967101d",
                "type": "message",
                "status": "completed",
                "content": [{"type": "output_text", "annotations": [], "logprobs": [], "text": "Hello."}],
                "phase": "final_answer",
                "role": "assistant",
            }
        ],
        "parallel_tool_calls": True,
        "presence_penalty": 0.0,
        "previous_response_id": None,
        "prompt_cache_key": None,
        "prompt_cache_retention": "24h",
        "reasoning": {"context": "all_turns", "effort": "medium", "mode": "standard", "summary": None},
        "safety_identifier": None,
        "service_tier": "default",
        "store": True,
        "temperature": 1.0,
        "text": {"format": {"type": "text"}, "verbosity": "medium"},
        "tool_choice": "auto",
        "tool_usage": {
            "image_gen": {
                "input_tokens": 0,
                "input_tokens_details": {"image_tokens": 0, "text_tokens": 0},
                "output_tokens": 0,
                "output_tokens_details": {"image_tokens": 0, "text_tokens": 0},
                "total_tokens": 0,
            },
            "web_search": {"num_requests": 0},
        },
        "tools": [],
        "top_logprobs": 0,
        "top_p": 0.98,
        "truncation": "disabled",
        "usage": {
            "input_tokens": 19,
            "input_tokens_details": {"cache_write_tokens": 0, "cached_tokens": 0},
            "output_tokens": 6,
            "output_tokens_details": {"reasoning_tokens": 0},
            "total_tokens": 25,
        },
        "user": None,
        "metadata": {},
    },
    expected_litellm_response={
        "id": ANY,
        "created_at": 1791225925,
        "error": None,
        "incomplete_details": None,
        "instructions": "You are a terse assistant.",
        "metadata": {},
        "model": "openai/responses/gpt-5.6-sol",
        "object": "response",
        "output": [
            {
                "id": "msg_0691e5d81d357aec006ac3f04611ac87d081b8e4e32967101d",
                "content": [{"annotations": [], "text": "Hello.", "type": "output_text", "logprobs": []}],
                "role": "assistant",
                "status": "completed",
                "type": "message",
                "phase": "final_answer",
            }
        ],
        "parallel_tool_calls": True,
        "temperature": 1.0,
        "tool_choice": "auto",
        "tools": [],
        "top_p": 0.98,
        "max_output_tokens": 64,
        "previous_response_id": None,
        "reasoning": {"context": "all_turns", "effort": "medium", "mode": "standard", "summary": None},
        "status": "completed",
        "text": {"format": {"type": "text"}, "verbosity": "medium"},
        "truncation": "disabled",
        "usage": {
            "input_tokens": 19,
            "input_tokens_details": {
                "audio_tokens": None,
                "cached_tokens": 0,
                "cached_tokens_details": None,
                "image_tokens": None,
                "text_tokens": None,
                "video_tokens": None,
                "cache_write_tokens": 0,
            },
            "output_tokens": 6,
            "output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 0, "text_tokens": None},
            "total_tokens": 25,
            "cost": None,
        },
        "user": None,
        "store": True,
        "access_programs": {"cyber": "daybreak_blue"},
        "background": False,
        "billing": {"payer": "developer"},
        "completed_at": 1791225926,
        "frequency_penalty": 0.0,
        "max_tool_calls": None,
        "moderation": None,
        "presence_penalty": 0.0,
        "prompt_cache_key": None,
        "prompt_cache_retention": "24h",
        "safety_identifier": None,
        "service_tier": "default",
        "tool_usage": {
            "image_gen": {
                "input_tokens": 0,
                "input_tokens_details": {"image_tokens": 0, "text_tokens": 0},
                "output_tokens": 0,
                "output_tokens_details": {"image_tokens": 0, "text_tokens": 0},
                "total_tokens": 0,
            },
            "web_search": {"num_requests": 0},
        },
        "top_logprobs": 0,
    },
)

GPT_6_1_SOL_TEST_CASE: Final = TranslationTestCase(
    scenario="basic",
    litellm_endpoint="/v1/responses",
    litellm_request={**RESPONSES_REQUEST, "model": "openai/responses/gpt-6.1-sol"},
    expected_provider_endpoint="/responses",
    expected_provider_headers={
        "content-type": "application/json",
        "authorization": "Bearer synthetic-openai-key",
    },
    expected_provider_request={**OPENAI_RESPONSES_REQUEST, "model": "gpt-6.1-sol"},
    mock_provider_response={
        **OPENAI_RESPONSES_RESPONSE,
        "model": "gpt-6.1-sol",
    },
    expected_litellm_response={
        **RESPONSES_NATIVE_RESPONSE,
        "id": ANY,
        "created_at": 1792025514,
        "model": "openai/responses/gpt-6.1-sol",
        "output": [
            {
                "id": "rs_0207c20ae125feee006ad023abed4087d09d32a32ad2d3182c",
                "summary": [],
                "type": "reasoning",
                "content": [],
                "encrypted_content": "gAAAAABq0COvx3R_lOOaYJijiIokUKBq9tt_p3mhoPHnm4KR0Pj_t0wf1sP7WEDHfYSzylhHilYoKjU4guIz-TAqBV6HNUpIx5ggp3aukKEW6zks2ERT3a40sCFFdUdKHk6py5trFuwYn6lHLwifwDkd7rI7MKIP7C7pZSHnXh8cmfk0t96p4nBplQ93C4m917Kyx6PqvWSxPP78h5s_RMEdhkWRU20xMhminpIBNArOkPYT4xsm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a5XcotQGbAToTE8qaHfowZOdTyjIKrU3BjL_Hs5M41KXwrNkk_X5ttJxEPW1qCjyusFb9yeGa9wzHMsp_VO0ysdO8L2KSRAY4LHpGI175VxUmnSg66PtCPln0OYxWsX2FWE1A7B_la662tO4VoS3bcslVZreRWFDJ_7X8qKx2fStxd77B7JkG1ZElxlZYlBRN5_Lo_w1yM9SvqHzzewQYEprSA1gltjxAbIzy7xXReaT86PNI8ojSLfXOkXa6Cybu3hIxsIomkZwTtAEx85BoIDn2B8oTp744Lwkwn4ualAfV9TebiqOWCUYp47fX9rimte71X6Hnvf7tWEBZMMwSb0pTqY0boMOS0w3XKKyEVRNyCoGWMgyvhAxk9E5iao5N6i5W3aSel27QwsUaE4YDGKKMKSryH3BqP6X7d0kdUcAx-nd5yudVbePQyc-UC7EbISj5QXY8g6cTOy-IkwpBe68DvfcNGIhuaH6UscqrewXQjKZFJC_BJSl-ICOfMw-FCTumzCDXPqTeLBPHf1g5kd5lBd6HLPUldHtJfD48V12KCRtaoksZ4g2NibuClnmZRpnDMPDUr7r_D8-RfoLEiJeh8SbOSnLvMPVAJIB95F73B-UX5u0e0aWeyfG5QjBq-kB7vVGsRiMyHEVQW810xo2qULVIyVO03s7rAWwTxFY-EHmKkaAIbKU2b-qAasytni7f1Aq61OSIYqSCRdFhpUX6HpnQeCFC_s6_Q9P3CFx120ZaTB_HPeRJO6dhVSJ3nL3PiNi8sCnhRiNIXkJfm9l1TxRS8ok9s1NY8oi4Y98J4Ay52EkX6f9F9FtWHNu4GX_Z50jDNnVTVqQo3L3slpwxECsTAEU-0MsmIa-1RqJ00VqBLKtIDVbbnQ==",
            },
            {
                "id": "msg_0207c20ae125feee006ad023ade23487d093e272f84cb35723",
                "content": [
                    {
                        "annotations": [],
                        "text": "I’ll read `shop/validation.py` first to check how it handles "
                        "zero, negative, and non-integer quantities.",
                        "type": "output_text",
                        "logprobs": [],
                    }
                ],
                "role": "assistant",
                "status": "completed",
                "type": "message",
                "phase": "commentary",
            },
            {
                "arguments": '{"path":"shop/validation.py","start_line":1,"end_line":200}',
                "call_id": "call_S4WtfrQwa6ZLEUZf1BVtA8ON",
                "name": "read_file",
                "type": "function_call",
                "id": "fc_0207c20ae125feee006ad023ae893c87d08068561e36e665ad",
                "namespace": None,
                "status": "completed",
            },
        ],
        "parallel_tool_calls": True,
        "temperature": 1.0,
        "tools": [
            {
                "name": "search_files",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "query": {"type": "string"},
                        "paths": {"type": "array", "items": {"type": "string"}},
                    },
                    "required": ["query", "paths"],
                    "additionalProperties": False,
                },
                "strict": True,
                "type": "function",
                "defer_loading": None,
                "description": "Search source and test files for a literal term.",
                "output_schema": None,
            },
            {
                "name": "read_file",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "path": {"type": "string"},
                        "start_line": {"type": "integer", "minimum": 1},
                        "end_line": {"type": "integer", "minimum": 1},
                    },
                    "required": ["path", "start_line", "end_line"],
                    "additionalProperties": False,
                },
                "strict": True,
                "type": "function",
                "defer_loading": None,
                "description": "Read a range of lines from a project file.",
                "output_schema": None,
            },
        ],
        "top_p": 0.98,
        "reasoning": {"context": "all_turns", "effort": "high", "mode": "standard", "summary": None},
        "text": {"format": {"type": "text"}, "verbosity": "medium"},
        "truncation": "disabled",
        "usage": {
            "input_tokens": 309,
            "input_tokens_details": {
                "audio_tokens": None,
                "cached_tokens": 0,
                "cached_tokens_details": None,
                "image_tokens": None,
                "text_tokens": None,
                "video_tokens": None,
                "cache_write_tokens": 0,
            },
            "output_tokens": 118,
            "output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 53, "text_tokens": None},
            "total_tokens": 427,
            "cost": None,
        },
        "store": True,
        "access_programs": None,
        "background": False,
        "billing": {"payer": "developer"},
        "completed_at": 1792025519,
        "frequency_penalty": 0.0,
        "max_tool_calls": None,
        "moderation": None,
        "presence_penalty": 0.0,
        "prompt_cache_key": None,
        "prompt_cache_retention": "24h",
        "safety_identifier": None,
        "service_tier": "default",
        "tool_usage": {
            "image_gen": {
                "input_tokens": 0,
                "input_tokens_details": {"image_tokens": 0, "text_tokens": 0},
                "output_tokens": 0,
                "output_tokens_details": {"image_tokens": 0, "text_tokens": 0},
                "total_tokens": 0,
            },
            "web_search": {"num_requests": 0},
        },
        "top_logprobs": 0,
    },
)