Skip to content

providers/sdk: budget pricing cannot reach feed rows for native vendor-endpoint constructors (kimi/zai/minimax) — add a base-URL-authoritative pricing key #373

Description

@luizParreira

OpenAIProvider::kimi / ::zai / ::minimax differ only by base_url; provider() reports "openai" and the native model ids carry no vendor prefix (kimi-k2.5, glm-5, MiniMax-M2.5). Budget pricing candidates therefore never reach the feeds' vendor-keyed rows (("moonshotai","kimi-k2.5") etc.), and the static table files those models under slugs — so a feed-only native-endpoint model prices to None and can never trip max_cost_usd (documented fail-open; no wrong price is ever produced).

A model-id prefix map (kimi-* → moonshotai, …) was considered and rejected: a wrong vendor guess silently prices a run at another vendor's rate.

The localized, authoritative fix: the vendor IS known at construction from base_url (the BASE_URL_KIMI/BASE_URL_ZAI/BASE_URL_MINIMAX constants exist, and code already branches on base_url.contains("api.z.ai")). Add an additive, defaulted trait method on LlmProvider:

fn pricing_key(&self) -> Option<(String, String)> { None }

overridden by OpenAIProvider only when its base_url is one of those endpoints (e.g. ("moonshotai", "kimi-k2.5")), threaded into the budget the same way the cost estimator was (TurnContext + the contextless checks). Re-keys nothing in the static table; changes no audit/wire provenance.

Adjacent (same underlying gap — provenance does not name the serving backend): wrapper provenance for FallbackProvider/ModelRouter, documented as a residual on PR #368.

Refs: PR #368 (source-major pricing lookup), issue #356.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions