Skip to content

feat(fireworks): add GLM 5.2 Fast router and fix glm-5p2 context window - #31460

Open
shzdehmd wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
shzdehmd:litellm_fireworks_glm_5p2_fast
Open

shzdehmd wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
shzdehmd:litellm_fireworks_glm_5p2_fast

Conversation

@shzdehmd

@shzdehmd shzdehmd commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Closes #31459

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 requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Type

The new model and its pricing can be verified on the Fireworks model page: https://app.fireworks.ai/models/fireworks/glm-5p2

image

For the context window size, an API request can be made for verification:

curl -s \
  -H "Authorization: Bearer $FIREWORKS_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @/tmp/glm_payload.json \
  https://api.fireworks.ai/inference/v1/chat/completions

A test payload can be generated using the following:

#!/usr/bin/env bash
python3 -c "
import json
words = 'the quick brown fox jumps over lazy dog hello world this is a test of context window artificial intelligence machine learning deep neural network language model token embedding attention transformer architecture training inference generation '
text = words * 35000
payload = json.dumps({
  'model': 'accounts/fireworks/models/glm-5p2',
  'messages': [{'role': 'user', 'content': text + '\n\nSay ok.'}],
  'max_tokens': 1
})
with open('/tmp/glm_payload.json', 'w') as f:
    f.write(payload)
print('Payload written to /tmp/glm_payload.json')
"
image

Type

🆕 New Feature

Changes

Adds the glm-5p2-fast router endpoint to model_prices_and_context_window.json and its bundled backup, and corrects the max_input_tokens and cache_read_input_token_cost values for the existing glm-5p2 direct model entry.

Per-token costs, context/output limits, cache_read_input_token_cost, and capability flags for the new router entry are sourced from the Fireworks model page at https://app.fireworks.ai/models/fireworks/glm-5p2. The glm-5p2-fast router is a load-balanced endpoint over GLM 5.2 with 1.5x pricing (input $2.10/M, output $6.60/M, cache_read $0.21/M) and the same context window (1048575) and output limit (131072) as the base model. Capability flags match the base model: supports_function_calling, supports_reasoning, supports_response_schema, supports_tool_choice all true; supports_vision false.

The max_input_tokens correction from 1048576 to 1048575 applies to both the existing glm-5p2 direct model entry and its short-form alias, and to the new glm-5p2-fast router entry and its short-form alias. The value 1048575 matches the context window published on the Fireworks model page and can be verified by sending a payload that exceeds 1048575 tokens to the API.

The cache_read_input_token_cost for the glm-5p2 base model is corrected from 2.6e-07 to 1.4e-07 ($0.14/M), reflecting a price reduction on the Fireworks platform. The glm-5p2-fast router entry uses 2.1e-07 ($0.21/M) for cache reads.

Short-form aliases (fireworks_ai/glm-5p2-fast) are added so cost attribution works for callers using bare model names. FireworksAIConfig.transform_request already routes bare names ending in -fast to accounts/fireworks/routers/, so no handler code changes are needed.

File by file:

  • model_prices_and_context_window.json: 1 new router long-form entry (accounts/fireworks/routers/glm-5p2-fast), 1 new router short-form alias (fireworks_ai/glm-5p2-fast), max_input_tokens corrected from 1048576 to 1048575 and cache_read_input_token_cost corrected from 2.6e-07 to 1.4e-07 for the existing glm-5p2 direct model entry and its short-form alias
  • litellm/model_prices_and_context_window_backup.json: mirrored so the bundled fallback cost map stays in sync
  • tests/test_litellm/test_utils.py: test_fireworks_models_in_cost_map and test_fireworks_models_in_backup_cost_map updated with the new glm-5p2-fast router entry in _FIREWORKS_MODELS and glm-5p2-fast in _FIREWORKS_ROUTER_SHORT_FORMS; the glm-5p2 base model entry's expected max_input_tokens corrected to 1048575 and cache_read_input_token_cost corrected to 1.4e-07
  • tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py: glm-5p2 and glm-5p2-fast (direct, router, and short-form variants) added to the supported_models list in test_supports_reasoning_effort; the previously missing glm-5p1-fast (router and short-form) is also added to the same list, as it has supports_reasoning: true in the cost map but was absent from the test

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds the glm-5p2-fast Fireworks AI router endpoint (both long-form accounts/fireworks/routers/glm-5p2-fast and short-form alias fireworks_ai/glm-5p2-fast) to the cost map, and corrects pricing and context-window metadata for the existing glm-5p2 base model entries.

  • Adds glm-5p2-fast router entries with input $2.10/M, output $6.60/M, cache-read $0.21/M, and 1 048 575-token context window to both the main and backup JSON files.
  • Corrects max_input_tokens (1 048 576 → 1 048 575) and cache_read_input_token_cost (2.6e-07 → 1.4e-07) for the glm-5p2 direct model and its short-form alias, reflecting a price reduction on the Fireworks platform.
  • Extends test coverage in test_supports_reasoning_effort and _FIREWORKS_MODELS / _FIREWORKS_ROUTER_SHORT_FORMS to validate the new entries and corrected values.

Confidence Score: 5/5

Safe to merge — changes are confined to static JSON cost-map data and their corresponding test fixtures.

The change touches only two data files (main and backup JSON) and two test files. The JSON edits are internally consistent — both files receive identical updates, the new router entry mirrors the structure of the existing glm-5p1-fast router entry, and the corrected glm-5p2 values are reflected in the test expectations. Test coverage is expanded rather than weakened. No logic code is modified.

No files require special attention.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds glm-5p2-fast router entries (short-form and long-form), corrects max_input_tokens from 1048576→1048575 and cache_read_input_token_cost from 2.6e-07→1.4e-07 for glm-5p2 base model; all values consistent with Fireworks pricing page.
litellm/model_prices_and_context_window_backup.json Mirror of the main JSON — identical changes applied to keep the bundled fallback cost map in sync.
tests/test_litellm/test_utils.py Updates expected values for glm-5p2 to match corrected pricing/context, adds glm-5p2-fast to _FIREWORKS_MODELS and _FIREWORKS_ROUTER_SHORT_FORMS — no test coverage weakened.
tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py Extends the supported_models list in test_supports_reasoning_effort with glm-5p2, glm-5p2-fast, and glm-5p1-fast variants; coverage is expanded, not weakened.

Reviews (2): Last reviewed commit: "feat(fireworks): add GLM 5.2 Fast router..." | Re-trigger Greptile

Comment thread model_prices_and_context_window.json
@shzdehmd
shzdehmd force-pushed the litellm_fireworks_glm_5p2_fast branch from 54ec669 to 66cbbe8 Compare June 26, 2026 16:38
Adds the glm-5p2-fast router endpoint to model_prices_and_context_window.json
and its bundled backup, and corrects the max_input_tokens and
cache_read_input_token_cost values for the existing glm-5p2 direct model
entry. New router: accounts/fireworks/routers/glm-5p2-fast. Updated:
glm-5p2 now carries the correct context window (1048575) and lowered
cache-read pricing (1.4e-07, down from 2.6e-07)

The glm-5p2-fast router is a load-balanced endpoint over GLM 5.2 with 1.5x
pricing (input 2.1e-06, output 6.6e-06, cache_read 2.1e-07) and the same
context window (1048575) and output limit (131072) as the base model.
Capability flags match the base model: supports_function_calling,
supports_reasoning, supports_response_schema, supports_tool_choice all
true; supports_vision false

Short-form aliases (fireworks_ai/glm-5p2-fast) are added so cost
attribution works for callers using bare model names.
FireworksAIConfig.transform_request already routes bare names ending in
-fast to accounts/fireworks/routers/, so no handler code changes are
needed

The max_input_tokens correction from 1048576 to 1048575 applies to both
the existing glm-5p2 direct model entry and its short-form alias, and to
the new glm-5p2-fast router entry and its short-form alias. The value
1048575 matches the context window published on the Fireworks model page

The cache_read_input_token_cost for the glm-5p2 base model is corrected
from 2.6e-07 to 1.4e-07, reflecting a price reduction on the Fireworks
platform

Regression tests in test_utils.py assert the exact per-token costs, token
limits, capability flags, and short-form-to-long-form equality for the new
glm-5p2-fast entry against both the main and backup cost maps. The
glm-5p2 base model entry assertions are updated to match the corrected
context window and cache-read pricing. test_supports_reasoning_effort in
test_fireworks_ai_chat_transformation.py now includes glm-5p2 and
glm-5p2-fast (direct, router, and short-form variants) in its supported
models list
@shzdehmd
shzdehmd force-pushed the litellm_fireworks_glm_5p2_fast branch from 66cbbe8 to a09c340 Compare June 26, 2026 16:40
@shzdehmd

Copy link
Copy Markdown
Contributor Author

@greptile-apps

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

[Feature]: Add GLM 5.2 Fast router to Fireworks AI model registry

2 participants