Add MiniMax-M3 model pricing to the cost registry - #217
Conversation
📝 WalkthroughWalkthroughAdds the built-in ChangesMiniMax M3 registration
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/models.rs`:
- Around line 1714-1725: The MiniMax M3 registration currently uses flat pricing
instead of the required token-tiered rates. Update the “minimax-m3” entry to use
PricingStructure::Tiered with a 512_000 threshold, lower-tier
input/output/cached-input rates of 0.30/1.20/0.06, and retain 0.60/2.40/0.12 for
the upper tier; also update the 1M-token assertions in src/models.rs:3494-3496
to reflect the upper-tier pricing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| // Source: https://platform.minimax.io/docs/api-reference/anthropic-api-compatible-cache | ||
| add_model!( | ||
| "minimax-m3", | ||
| PricingStructure::Flat { | ||
| input_per_1m: 0.60, | ||
| output_per_1m: 2.40 | ||
| }, | ||
| CachingSupport::OpenAI { | ||
| cached_input_per_1m: 0.12 | ||
| }, | ||
| false | ||
| ); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)src/models\.rs$|Cargo\.toml$' || true
echo "== relevant model registration context =="
if [ -f src/models.rs ]; then
sed -n '1660,1750p' src/models.rs
fi
echo "== relevant tests context =="
if [ -f src/models.rs ]; then
sed -n '3450,3530p' src/models.rs
fi
echo "== pricing structs/usages =="
rg -n "PricingStructure|struct PricingStructure|Flat|Tiered|minimax-m3|add_model" src/models.rs | head -200Repository: Piebald-AI/splitrail
Length of output: 12301
🌐 Web query:
MiniMax M3 API pricing 512K 1M tokens flat pricing
💡 Result:
MiniMax M3 pricing is not flat; it is tiered based on the input token count per request [1][2]. Under the "Pay as You Go" API billing model, MiniMax-M3 pricing is structured as follows (with current permanent 50% discounts applied): [1][2] Standard Tier Pricing (per 1 million tokens): - Input (≤ 512K tokens): $0.30 [1][3][2] - Input (> 512K tokens): $0.60 [1][2] - Output (≤ 512K tokens): $1.20 [1][3][2] - Output (> 512K tokens): $2.40 [1][2] - Prompt Caching Read (≤ 512K tokens): $0.06 [1][2] - Prompt Caching Read (> 512K tokens): $0.12 [1][2] For "Priority" tier service, which provides faster response times and improved reliability, rates are 1.5x the standard tier pricing [1][2]. Note that MiniMax M3 supports a 1M token context window [4][5], but requests exceeding the 512K input token threshold trigger the higher rate for the entire request [6]. MiniMax also offers "Token Plan" subscription options for individuals and teams, which provide monthly usage quotas rather than standard per-token billing [7][8][9].
Citations:
- 1: https://platform.minimax.io/docs/guides/pricing-paygo.md
- 2: https://platform.minimax.io/docs/guides/pricing-paygo
- 3: https://benchr.org/pricing/minimax-m3
- 4: https://www.minimax.io/models/text/m3
- 5: https://www.orcarouter.ai/models/minimax/minimax-m3
- 6: https://tokencost.app/blog/minimax-m3-pricing
- 7: https://platform.minimax.io/docs/pricing/overview
- 8: https://platform.minimax.io/docs/guides/pricing-token-plan
- 9: https://platform.minimax.io/subscribe/token-plan
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== pricing structs =="
sed -n '1,80p' src/models.rs
echo "== validation and calculate_* implementations =="
sed -n '150,240p' src/models.rs
sed -n '240,420p' src/models.rs
echo "== tier examples in model registration =="
sed -n '660,700p' src/models.rs
sed -n '730,770p' src/models.rs
sed -n '1230,1255p' src/models.rs
echo "== deterministic price calculation probe for MiniMax M3 current shape =="
python3 - <<'PY'
# Read relevant model/calculation definitions from src/models.rs without executing repo code.
with open('src/models.rs') as f:
s = f.read()
checks = {
"minimax_m3_flat_registration": 'add_model!(\n "minimax-m3",\n PricingStructure::Flat' in s,
"tiered_pricing_struct_exists": "pub struct TieredPricing" in s,
"tiered_variants_and_threshold_fields": all(x in s for x in ["pub struct TieredPricing", "threshold_1: usize", "rate_1_per_1m", "rate_2_per_1m", "rate_3_per_1m"]),
"calculate_input_cost_tier_branch": 'PricingStructure::Tiered(tiered)' in s and 'threshold_1' in s.split('fn calculate_input_cost')[1].rsplit('\n}',1)[0] if 'fn calculate_input_cost' in s else False,
}
for k,v in checks.items():
print(f"{k}={v}")
start = s.index('pub enum PricingStructure')
end = s.find('\n}', start) + 2
print("\n-- PricingStructure enum --")
print(s[start:end])
PYRepository: Piebald-AI/splitrail
Length of output: 15472
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate calculate functions =="
rg -n "fn calculate_(input|output|cache)_cost|fn calculate.*with.*tier" src/models.rs
echo "== calculate function body slices =="
# Capture from each function definition to the next function/impl boundary.
while IFS=: read -r -n 1 line char; do
line=${line%$'\r'}
if [[ "$char" == "\n" ]] && [[ "$line" =~ ^fn\ calculate ]]; then
start=$line
fi
done < /dev/null
# Simpler: sed from known function names found above.
rg -n -A80 "^fn calculate_input_cost|^fn calculate_output_cost|^fn calculate_cache_cost" src/models.rs | sed -n '1,220p'
echo "== full calculate_* blocks via awk =="
python3 - <<'PY'
from pathlib import Path
p=Path('src/models.rs')
text=p.read_text()
for name in ['calculate_input_cost','calculate_output_cost','calculate_cache_cost']:
idx=text.find(f'fn {name}(')
if idx==-1: continue
brace=text.find('{', idx)
depth=0
end=len(text)
for i,char in enumerate(text[brace:], brace):
if char=='{': depth+=1
elif char=='}':
depth-=1
if depth==0:
end=i+1
break
print(f"\n--- {name} lines {text[:idx+1].count(chr(10))+1}-{text[:end].count(chr(10))+1} ---")
print(text[idx:end])
PY
echo "== tiered cache helper functions references =="
rg -n "TieredCaching|bracket_pricing|calculate_cache_cost_for" src/models.rsRepository: Piebald-AI/splitrail
Length of output: 739
🌐 Web query:
site:platform.minimax.io/docs MiniMax M3 prompt caching rate over 512k tokens
💡 Result:
For the MiniMax-M3 model, prompt caching is available with differentiated pricing based on the input token threshold of 512k [1][2]. When input tokens exceed 512k, the pricing for input, output, and prompt caching read tokens doubles compared to the standard rate for requests with 512k tokens or fewer [2]. As of July 2026, the specific Pay-As-You-Go pricing for the MiniMax-M3 standard service tier is as follows [2]: - For requests with ≤ 512k input tokens: - Input: $0.30 per 1M tokens - Output: $1.20 per 1M tokens - Prompt Caching Read: $0.06 per 1M tokens - For requests with > 512k input tokens: - Input: $0.60 per 1M tokens - Output: $2.40 per 1M tokens - Prompt Caching Read: $0.12 per 1M tokens If you choose the priority service tier, the pricing is 1.5 times these standard rates [2]. Prompt caching applies to API calls with 512 or more input tokens and uses prefix matching for context [1]. You can monitor your usage through the API response, which includes fields for cache hit tokens [3]. For the most accurate and up-to-date pricing, always refer to the official MiniMax Pay-As-You-Go pricing page [2].
Citations:
- 1: https://platform.minimax.io/docs/api-reference/text-prompt-caching
- 2: https://platform.minimax.io/docs/guides/pricing-paygo
- 3: https://platform.minimax.io/docs/api-reference/responses-create
Use tiered pricing for MiniMax M3. The current registration hardcodes the >512K rates for all 1M-token and lower requests, so it undercharges inputs where MiniMax M3 is billed at $0.30/$1.20/$0.06 at or below 512K and $0.60/$2.40/$0.12 above. Use PricingStructure::Tiered with a 512_000 threshold, default lower tier rates, and the current upper-tier rates, then update the 1M-token assertions.
📍 Affects 1 file
src/models.rs#L1714-L1725(this comment)src/models.rs#L3494-L3496
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/models.rs` around lines 1714 - 1725, The MiniMax M3 registration
currently uses flat pricing instead of the required token-tiered rates. Update
the “minimax-m3” entry to use PricingStructure::Tiered with a 512_000 threshold,
lower-tier input/output/cached-input rates of 0.30/1.20/0.06, and retain
0.60/2.40/0.12 for the upper tier; also update the 1M-token assertions in
src/models.rs:3494-3496 to reflect the upper-tier pricing.
Reason: Add the MiniMax-M3 model with its current input, output, and cache-read pricing to the built-in cost registry.
Adds the
minimax-m3model entry tosrc/models.rsalongside the existing MiniMax models. MiniMax-M3 is priced at $0.60 per 1M input tokens, $2.40 per 1M output tokens, and $0.12 per 1M cache-read tokens (no cache-write pricing). It is registered using the flat cached-input pricing variant and a self-resolving alias is added for the canonical name.Checks run:
cargo check(clean)cargo test --bin splitrail models::(36 passed, 0 failed)cargo fmt --check(clean)Summary by CodeRabbit
New Features
Tests