KimiModel.__init__ raises TypeError float(None) whenever the selected model has no registry pricing
Describe the bug
KimiModel.__init__ raises TypeError for any model whose registry entry has no pricing (and no explicit cost override), so the model cannot be constructed at all.
This happens on two reachable paths:
- a shipped registry entry with
input_price=None/output_price=None—kimi-k2-base; - any model id that is not in
KIMI_MODELS_DATA(e.g. a newer Moonshot id such asmoonshot-v1-256k), which falls back to the default unpriced model data.
In both cases require_costs() returns (None, None) and the following float(None) blows up inside the constructor. No API call is involved; the crash is synchronous in __init__.
Environment
- deepeval 4.2.3 (
deepeval/models/llms/kimi_model.pyanddeepeval/models/utils.pyare byte-identical to commitb1f3f205c30cd3de43e23221b97bdddf92f7aa1c) - Python 3.12
- macOS (Darwin 25.6.0)
- No API key required to trigger: the failure occurs before any request is made
Minimal reproduction
from deepeval.models import KimiModel
KimiModel(model="kimi-k2-base") # registered, but input_price/output_price are None
KimiModel(model="moonshot-v1-256k") # not in KIMI_MODELS_DATA -> default unpriced dataActual output
registry kimi-k2-base: None None
registry unknown-model default: None None
kimi-k2-base -> TypeError : float() argument must be a string or a real number, not 'NoneType'
moonshot-v1-256k -> TypeError : float() argument must be a string or a real number, not 'NoneType'
(no-key, documented path) no-key -> TypeError : float() argument must be a string or a real number, not 'NoneType'
DeepSeekModel deepseek-chat-x -> OK cost= None
OpenAIModel gpt-9-unknown -> OK cost= NoneThe last two lines are the same scenario (an unpriced / unregistered model id) on sibling providers, where construction succeeds with cost = None.
Expected behavior
The model should construct successfully with an unknown cost (None) instead of raising. require_costs documents None as its return when pricing is unknown, and every sibling adapter writes that value straight through. The concrete basis:
deepeval/models/utils.py:115-136—require_costsis typed-> Tuple[Optional[float], Optional[float]]and returnsNone, Nonewhen pricing is unknown.deepeval/models/llms/deepseek_model.py:88-89anddeepeval/models/llms/openai_model.py:122-123assign therequire_costs()result directly, with nofloat()coercion.deepeval/models/llms/amazon_bedrock_model.py:152shows the guarded variant:float(cost_per_input_token or 0.0).docs/content/integrations/models/moonshot.mdxdocumentscost_per_input_tokenas optional and defaulting to the registry value "elseNone".typescript/src/models/registry/models.jsonalso shipskimi-k2-basewith noinputPrice/outputPrice, i.e. "pricing unknown" is a supported registry state; the TS KimiModel returns an unknown cost rather than throwing.
Root cause
deepeval/models/llms/kimi_model.py:88-89:
self.model_data.input_price = float(cost_per_input_token)
self.model_data.output_price = float(cost_per_output_token)require_costs(...) returns (None, None) when neither the registry entry nor the constructor/env cost is set, and float(None) raises TypeError. Unlike the sibling adapters, KimiModel coerces the value with float() (and without a fallback) before storing it.
Fix
Assign the require_costs() values directly (drop the float() coercion) the way the other providers do, or guard it — float(x) if x is not None else None. Downstream calculate_cost already treats a falsy model_data.input_price as "unknown". I can open a PR with this change and a regression test — happy to be assigned if you'd rather triage first.
Related
- #2752 — AmazonBedrockModel drops user-supplied costs for unregistered model ids (same "unpriced / unregistered model" theme)
- #2884 — unregistered models silently mis-handled elsewhere
- PR #2722 — GeminiModel always reporting $0 cost (prior fix in the cost path)
No existing issue or PR covers this KimiModel constructor crash.
Source: confident-ai/deepeval