diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 931d4bdeabf..ddcfb8bb034 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -61618,13 +61618,16 @@ }, "tokenlab/gemini-3.1-pro-preview": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 1e-06, + "input_cost_per_token_above_200k_tokens": 2e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1048576, "max_output_tokens": 65536, "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 6e-06, + "output_cost_per_token_above_200k_tokens": 9e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62332,13 +62335,16 @@ }, "tokenlab/gpt-5.4": { "cache_read_input_token_cost": 1.75e-07, + "cache_read_input_token_cost_above_272k_tokens": 3.5e-07, "input_cost_per_token": 1.75e-06, + "input_cost_per_token_above_272k_tokens": 3.5e-06, "litellm_provider": "tokenlab", "max_input_tokens": 400000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.05e-05, + "output_cost_per_token_above_272k_tokens": 1.575e-05, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62446,13 +62452,16 @@ }, "tokenlab/gpt-5.5": { "cache_read_input_token_cost": 1.5e-07, + "cache_read_input_token_cost_above_272k_tokens": 3e-07, "input_cost_per_token": 1.5e-06, + "input_cost_per_token_above_272k_tokens": 3e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 9e-06, + "output_cost_per_token_above_272k_tokens": 1.35e-05, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62476,12 +62485,14 @@ }, "tokenlab/gpt-5.5-pro": { "input_cost_per_token": 3e-05, + "input_cost_per_token_above_272k_tokens": 6e-05, "litellm_provider": "tokenlab", "max_input_tokens": 1050000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 0.00018, + "output_cost_per_token_above_272k_tokens": 0.00027, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62781,13 +62792,16 @@ }, "tokenlab/grok-4.20": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62811,13 +62825,16 @@ }, "tokenlab/grok-4.20-multi-agent": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62841,13 +62858,16 @@ }, "tokenlab/grok-4.20-non-reasoning": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62870,13 +62890,16 @@ }, "tokenlab/grok-4.3": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62998,13 +63021,16 @@ }, "tokenlab/grok-build-0.1": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 5e-07, + "input_cost_per_token_above_200k_tokens": 1e-06, "litellm_provider": "tokenlab", "max_input_tokens": 256000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1e-06, + "output_cost_per_token_above_200k_tokens": 2e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 931d4bdeabf..ddcfb8bb034 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -61618,13 +61618,16 @@ }, "tokenlab/gemini-3.1-pro-preview": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 1e-06, + "input_cost_per_token_above_200k_tokens": 2e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1048576, "max_output_tokens": 65536, "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 6e-06, + "output_cost_per_token_above_200k_tokens": 9e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62332,13 +62335,16 @@ }, "tokenlab/gpt-5.4": { "cache_read_input_token_cost": 1.75e-07, + "cache_read_input_token_cost_above_272k_tokens": 3.5e-07, "input_cost_per_token": 1.75e-06, + "input_cost_per_token_above_272k_tokens": 3.5e-06, "litellm_provider": "tokenlab", "max_input_tokens": 400000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.05e-05, + "output_cost_per_token_above_272k_tokens": 1.575e-05, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62446,13 +62452,16 @@ }, "tokenlab/gpt-5.5": { "cache_read_input_token_cost": 1.5e-07, + "cache_read_input_token_cost_above_272k_tokens": 3e-07, "input_cost_per_token": 1.5e-06, + "input_cost_per_token_above_272k_tokens": 3e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 9e-06, + "output_cost_per_token_above_272k_tokens": 1.35e-05, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62476,12 +62485,14 @@ }, "tokenlab/gpt-5.5-pro": { "input_cost_per_token": 3e-05, + "input_cost_per_token_above_272k_tokens": 6e-05, "litellm_provider": "tokenlab", "max_input_tokens": 1050000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 0.00018, + "output_cost_per_token_above_272k_tokens": 0.00027, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62781,13 +62792,16 @@ }, "tokenlab/grok-4.20": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62811,13 +62825,16 @@ }, "tokenlab/grok-4.20-multi-agent": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62841,13 +62858,16 @@ }, "tokenlab/grok-4.20-non-reasoning": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62870,13 +62890,16 @@ }, "tokenlab/grok-4.3": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 6.25e-07, + "input_cost_per_token_above_200k_tokens": 1.25e-06, "litellm_provider": "tokenlab", "max_input_tokens": 1000000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1.25e-06, + "output_cost_per_token_above_200k_tokens": 2.5e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", @@ -62998,13 +63021,16 @@ }, "tokenlab/grok-build-0.1": { "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_200k_tokens": 2e-07, "input_cost_per_token": 5e-07, + "input_cost_per_token_above_200k_tokens": 1e-06, "litellm_provider": "tokenlab", "max_input_tokens": 256000, "max_output_tokens": 131072, "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 1e-06, + "output_cost_per_token_above_200k_tokens": 2e-06, "source": "https://api.tokenlab.sh/v1/models", "supported_endpoints": [ "/v1/chat/completions", diff --git a/tests/unit/llms/openai_like/test_tokenlab_provider.py b/tests/unit/llms/openai_like/test_tokenlab_provider.py index 55348399306..2f5cb7bc3da 100644 --- a/tests/unit/llms/openai_like/test_tokenlab_provider.py +++ b/tests/unit/llms/openai_like/test_tokenlab_provider.py @@ -160,15 +160,33 @@ class TestTokenLabCostMap: def test_chat_cost_is_wired(self): prompt_cost, completion_cost = litellm.cost_per_token( model="tokenlab/gpt-5.5", - prompt_tokens=1_000_000, - completion_tokens=1_000_000, + prompt_tokens=100_000, + completion_tokens=100_000, ) - assert prompt_cost == pytest.approx(litellm.model_cost["tokenlab/gpt-5.5"]["input_cost_per_token"] * 1_000_000) + assert prompt_cost == pytest.approx(litellm.model_cost["tokenlab/gpt-5.5"]["input_cost_per_token"] * 100_000) assert completion_cost == pytest.approx( - litellm.model_cost["tokenlab/gpt-5.5"]["output_cost_per_token"] * 1_000_000 + litellm.model_cost["tokenlab/gpt-5.5"]["output_cost_per_token"] * 100_000 ) assert prompt_cost > 0 and completion_cost > 0 + def test_chat_cost_uses_the_long_context_tier(self): + assert ( + litellm.model_cost["tokenlab/gpt-5.5"]["input_cost_per_token_above_272k_tokens"] + > litellm.model_cost["tokenlab/gpt-5.5"]["input_cost_per_token"] + ) + + prompt_cost, completion_cost = litellm.cost_per_token( + model="tokenlab/gpt-5.5", + prompt_tokens=300_000, + completion_tokens=100_000, + ) + assert prompt_cost == pytest.approx( + litellm.model_cost["tokenlab/gpt-5.5"]["input_cost_per_token_above_272k_tokens"] * 300_000 + ) + assert completion_cost == pytest.approx( + litellm.model_cost["tokenlab/gpt-5.5"]["output_cost_per_token_above_272k_tokens"] * 100_000 + ) + def test_embedding_cost_is_wired(self): prompt_cost, completion_cost = litellm.cost_per_token( model="tokenlab/text-embedding-3-small",