fix(tokenlab): add the context-tier prices to the existing entries

Nine TokenLab entries charged the base price at every prompt length,
but the catalog prices long prompts higher. They now carry the
long-context prices from the catalog (registry revision 456), with the
same fields LiteLLM uses for OpenAI, xAI and Gemini:

- gpt-5.4, gpt-5.5, gpt-5.5-pro: *_above_272k_tokens
- grok-4.20, grok-4.20-multi-agent, grok-4.20-non-reasoning, grok-4.3,
  grok-build-0.1, gemini-3.1-pro-preview: *_above_200k_tokens

test_chat_cost_is_wired used a 1M-token prompt, which is now in the
long-context tier. It now uses a 100K-token prompt, and a new test
checks that a 300K-token prompt uses the *_above_272k_tokens prices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hedging8563 2026-10-06 23:44:45 +08:00
parent e6d9654f81
commit f729fd8939
3 changed files with 74 additions and 4 deletions

View file

@ -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",

View file

@ -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",

View file

@ -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",