fix(openinfer): set catalog rates from vendor per-million prices

Zero rates skipped LiteLLM spend limits. Convert the vendor's $/1M token
prices to per-token catalog entries and add Qwen3.5-27B plus Gemma4-31B.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
AJ-ing 2026-09-09 12:01:55 +10:00
parent 3bc50c5bdd
commit 1e6086aea3
3 changed files with 83 additions and 8 deletions

View file

@ -63842,8 +63842,8 @@
"max_tokens": 8192,
"max_input_tokens": 128000,
"max_output_tokens": 8192,
"input_cost_per_token": 0.0,
"output_cost_per_token": 0.0,
"input_cost_per_token": 2e-08,
"output_cost_per_token": 2e-08,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,
@ -63853,8 +63853,30 @@
"max_tokens": 8192,
"max_input_tokens": 262144,
"max_output_tokens": 8192,
"input_cost_per_token": 0.0,
"output_cost_per_token": 0.0,
"input_cost_per_token": 1.5e-07,
"output_cost_per_token": 1.8e-07,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,
"source": "https://api.openinfer.ai/v1/models"
},
"openinfer/@oi/Qwen3.5-27B": {
"max_tokens": 8192,
"max_input_tokens": 262144,
"max_output_tokens": 8192,
"input_cost_per_token": 7.2e-07,
"output_cost_per_token": 7.2e-07,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,
"source": "https://api.openinfer.ai/v1/models"
},
"openinfer/@oi/Gemma4-31B": {
"max_tokens": 8192,
"max_input_tokens": 262144,
"max_output_tokens": 8192,
"input_cost_per_token": 5.2e-07,
"output_cost_per_token": 7.5e-07,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,

View file

@ -63842,8 +63842,8 @@
"max_tokens": 8192,
"max_input_tokens": 128000,
"max_output_tokens": 8192,
"input_cost_per_token": 0.0,
"output_cost_per_token": 0.0,
"input_cost_per_token": 2e-08,
"output_cost_per_token": 2e-08,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,
@ -63853,8 +63853,30 @@
"max_tokens": 8192,
"max_input_tokens": 262144,
"max_output_tokens": 8192,
"input_cost_per_token": 0.0,
"output_cost_per_token": 0.0,
"input_cost_per_token": 1.5e-07,
"output_cost_per_token": 1.8e-07,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,
"source": "https://api.openinfer.ai/v1/models"
},
"openinfer/@oi/Qwen3.5-27B": {
"max_tokens": 8192,
"max_input_tokens": 262144,
"max_output_tokens": 8192,
"input_cost_per_token": 7.2e-07,
"output_cost_per_token": 7.2e-07,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,
"source": "https://api.openinfer.ai/v1/models"
},
"openinfer/@oi/Gemma4-31B": {
"max_tokens": 8192,
"max_input_tokens": 262144,
"max_output_tokens": 8192,
"input_cost_per_token": 5.2e-07,
"output_cost_per_token": 7.5e-07,
"litellm_provider": "openinfer",
"mode": "chat",
"supports_function_calling": true,

View file

@ -2,8 +2,19 @@
Tests for the OpenInfer LLM provider configuration and integration.
"""
import json
from pathlib import Path
import pytest
import litellm
_REPO_ROOT = Path(__file__).resolve().parents[4]
_PRICE_FILES = (
_REPO_ROOT / "model_prices_and_context_window.json",
_REPO_ROOT / "litellm" / "model_prices_and_context_window_backup.json",
)
class TestOpenInferProviderConfig:
def test_openinfer_in_provider_list(self):
@ -89,3 +100,23 @@ class TestOpenInferProviderConfig:
)
== "https://api.openinfer.ai/v1/chat/completions"
)
@pytest.mark.parametrize(
("model", "input_cost_per_token", "output_cost_per_token"),
(
("openinfer/@oi/Llama-3.2-1B-Instruct", 2e-08, 2e-08),
("openinfer/@oi/Qwen3.5-9B", 1.5e-07, 1.8e-07),
("openinfer/@oi/Qwen3.5-27B", 7.2e-07, 7.2e-07),
("openinfer/@oi/Gemma4-31B", 5.2e-07, 7.5e-07),
),
)
def test_catalog_token_rates_match_vendor_per_million_prices(
self, model: str, input_cost_per_token: float, output_cost_per_token: float
):
for path in _PRICE_FILES:
catalog = json.loads(path.read_text())
row = catalog[model]
assert row["input_cost_per_token"] == input_cost_per_token
assert row["output_cost_per_token"] == output_cost_per_token
assert row["input_cost_per_token"] > 0
assert row["output_cost_per_token"] > 0