Skip to content

fix(fireworks_ai): correct Kimi K2.5/K2.6/K2.7 max output token limits - #35174

Merged
mateo-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_fix_fireworks_kimi_output_limits
Jul 31, 2026
Merged

fix(fireworks_ai): correct Kimi K2.5/K2.6/K2.7 max output token limits#35174
mateo-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_fix_fireworks_kimi_output_limits

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Fireworks Kimi K2.5/K2.6/K2.7 entries claimed 262144 max output tokens
  • That equals the context window, which Fireworks never allows for generation
  • Pre-call context checks and fallback routing decide on these bad limits

How it solves it:

  • Set max_output_tokens/max_tokens to 32768 for all ten Kimi aliases
  • Keep max_input_tokens at the real 262144 context window
  • Add a regression test pinning the limits for every alias

Relevant issues

Linear ticket

Resolves LIT-4986

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

Every Kimi K2.5, K2.6 and K2.7 model on Fireworks publishes a 262144-token context window, but generation is capped well below that; the sibling entries set by hand show the pattern (fireworks_ai/accounts/fireworks/models/kimi-k2-instruct caps output at 16384, kimi-k2-instruct-0905 at 32768). The affected entries had copied 262144 into max_output_tokens/max_tokens, so the pre-call context-window check would admit a request asking for a full 262144-token completion that Fireworks rejects.

Before (parent commit 581f5c3), the cost map reported output == context:

$ git show HEAD~1:model_prices_and_context_window.json | python3 -c "..."
BEFORE fireworks_ai/accounts/fireworks/models/kimi-k2p6 -> max_input 262144 max_output 262144 max_tokens 262144
BEFORE fireworks_ai/accounts/fireworks/models/kimi-k2p7-code -> max_input 262144 max_output 262144 max_tokens 262144

After (fix commit f9c5be8), against a live proxy on localhost:4000 loading these two Fireworks Kimi deployments with LITELLM_LOCAL_MODEL_COST_MAP=True:

$ curl -s http://localhost:4000/v1/model/info -H "Authorization: Bearer sk-1234"
kimi-k2p6 -> fireworks_ai/accounts/fireworks/models/kimi-k2p6
   max_input_tokens = 262144 | max_output_tokens = 32768 | max_tokens = 32768
kimi-k2p7-code -> fireworks_ai/accounts/fireworks/models/kimi-k2p7-code
   max_input_tokens = 262144 | max_output_tokens = 32768 | max_tokens = 32768

A real chat completion against Fireworks Kimi K2.6 through the same proxy still succeeds and tracks usage (real Fireworks API call):

$ curl -s http://localhost:4000/v1/chat/completions -H "Authorization: Bearer sk-1234" \
    -H "Content-Type: application/json" \
    -d '{"model":"kimi-k2p6","messages":[{"role":"user","content":"Reply with exactly: fix verified"}],"max_tokens":16}'
content: 'The user wants me to reply with exactly: "fix verified". No other text'
model: kimi-k2p6
usage: {'completion_tokens': 16, 'prompt_tokens': 14, 'total_tokens': 30, 'prompt_tokens_details': {'cached_tokens': 0}}

Type

🐛 Bug Fix

Changes

Corrected max_output_tokens and max_tokens from 262144 to 32768 for the ten affected fireworks_ai Kimi aliases in both model_prices_and_context_window.json and the bundled litellm/model_prices_and_context_window_backup.json, leaving max_input_tokens at the real 262144 context window. The aliases are the short names (kimi-k2p5, kimi-k2p6, kimi-k2p6-fast, kimi-k2p7-code, kimi-k2p7-code-fast), the accounts/fireworks/models/... names and the accounts/fireworks/routers/... names. Fireworks lists K2.7 only as "Kimi K2.7 Code", so there is no plain non-code K2.7 alias to add.

Added tests/test_litellm/llms/fireworks_ai/test_fireworks_ai_kimi_model_metadata.py, which asserts the corrected limits for all ten aliases through both the raw cost map and get_model_info, so a future bulk edit that flattens output back to the context window fails.

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/62267d31816b438abf0e1f3651912e9a
Requested by: @mateo-berri


Note

Low Risk
Metadata-only correction in the model cost map plus tests; no runtime routing or auth changes, though callers may see stricter max-completion limits than before.

Overview
Fixes Fireworks Kimi K2.5/K2.6/K2.7 metadata so max_output_tokens and max_tokens are 32768 instead of 262144 (which matched the input context window and let pre-call checks admit completions Fireworks rejects). max_input_tokens stays 262144 across all ten aliases (short names, accounts/fireworks/models/..., and router variants) in both model_prices_and_context_window.json and the bundled backup.

Adds test_fireworks_ai_kimi_model_metadata.py to pin those limits on the raw cost map and get_model_info, and updates existing Fireworks parametrized expectations in test_utils.py for the Kimi entries.

Reviewed by Cursor Bugbot for commit b0a48d5. Bugbot is set up for automated code reviews on this repo. Configure here.

Fireworks publishes a 262144-token context window for the Kimi K2.5, K2.6
and K2.7 models but caps generation well below that. Every fireworks_ai
Kimi K2.5/K2.6/K2.7 alias had max_output_tokens/max_tokens flattened to
262144 (equal to the context window), so the pre-call context-window check
admitted requests asking for a full 262144-token completion that Fireworks
rejects. Correct max_output_tokens/max_tokens to 32768 while keeping
max_input_tokens at 262144, and add a regression test pinning the limits
for all ten aliases.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri mateo-berri self-assigned this Jul 30, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Corrects Fireworks Kimi K2.5, K2.6, and K2.7 Code model metadata.

  • Reduces maximum output-token metadata to 32,768 across ten short, model, and router aliases.
  • Keeps the 262,144-token input context window unchanged.
  • Synchronizes the canonical and bundled backup model maps.
  • Adds regression coverage for raw metadata and get_model_info lookups.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Updates the canonical Fireworks Kimi aliases to report a 32,768-token output limit while preserving their input context limits.
litellm/model_prices_and_context_window_backup.json Mirrors the corrected Kimi token limits in the bundled fallback model map.
tests/test_litellm/llms/fireworks_ai/test_fireworks_ai_kimi_model_metadata.py Adds regression assertions for all ten affected aliases through direct map access and get_model_info.
tests/test_litellm/test_utils.py Aligns existing canonical and backup Fireworks metadata expectations with the corrected output limits.

Reviews (2): Last reviewed commit: "test(fireworks_ai): align Kimi output-li..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…p fix

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@codspeed-hq

codspeed-hq Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_fireworks_kimi_output_limits (b0a48d5) with litellm_internal_staging (551e5d0)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (9f9d72b) during the generation of this report, so 551e5d0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

QA: live proxy, real Fireworks API, no mocks

Tested against a live LiteLLM proxy with LITELLM_LOCAL_MODEL_COST_MAP=True, hitting the real Fireworks API. All scenarios pass

  • Served /model/info reports max_output_tokens=32768, max_tokens=32768 and max_input_tokens=262144 for all seven Kimi forms (k2p5, k2p6, k2p6-fast, k2p7-code, k2p7-code-fast, and the accounts/fireworks/routers/... forms); the broken 262144 output value is gone
  • A real fireworks_ai/kimi-k2p6 chat completion returns 200 with content and a usage block

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b0a48d5. Configure here.

@mateo-berri
mateo-berri merged commit c3da121 into litellm_internal_staging Jul 31, 2026
77 checks passed
@mateo-berri
mateo-berri deleted the litellm_fix_fireworks_kimi_output_limits branch July 31, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants