Skip to content

[BUG] [v0.0.7] CORTEX_PRICING env cannot target provider/model names #11201

@EnthusiasticTech

Description

@EnthusiasticTech

Project

cortex

Description

Custom pricing via CORTEX_PRICING_<MODEL> cannot target provider/model names that include a slash (e.g., openai/gpt-4o). The env key is converted by replacing underscores with hyphens, producing openai-gpt-4o, which never matches openai/gpt-4o in session metadata. As a result, custom pricing is silently ignored for the most common model format.

Reference: cortex-cli/src/stats_cmd.rs load_custom_pricing().

Error Message

No error. The custom pricing is silently ignored.

Debug Logs

N/A

System Information

Bounty Version: 0.1.0
OS: Ubuntu 24.04 LTS
CPU: AMD EPYC-Genoa Processor (8 cores)
RAM: 15 GB

Screenshots

No response

Steps to Reproduce

  1. Create a minimal session file at ~/.cortex/sessions/custom.json:
    {
      "model": "openai/gpt-4o",
      "usage": {"input_tokens": 1000000, "output_tokens": 1000000},
      "messages": []
    }
  2. Set custom pricing:
    export CORTEX_PRICING_OPENAI_GPT_4O=1.0,1.0
  3. Run: cortex stats --json
  4. Observe that the estimated cost still reflects the default pricing, not the custom 1.0/1.0 override.

Expected Behavior

Custom pricing should apply to openai/gpt-4o when set via env var, or the docs/implementation should provide a reliable mapping for model names that include /.

Actual Behavior

The env key is converted to openai-gpt-4o, which never matches openai/gpt-4o, so custom pricing is ignored.

Additional Context

This affects all provider/model identifiers that include /, which is the primary naming format in Cortex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cortexIssues related to CortexLM/cortex repositoryvalidValid issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions