Skip to content

fix(friendliai): sync serverless catalog with the models API - #33501

Closed
robust-WJL wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
robust-WJL:add-friendliai-serverless-models
Closed

robust-WJL wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
robust-WJL:add-friendliai-serverless-models

Conversation

@robust-WJL

@robust-WJL robust-WJL commented Jul 16, 2026 •

Copy link
Copy Markdown

TLDR

Problem this solves:

  • the only FriendliAI entries in the cost map were friendliai/meta-llama-3.1-70b-instruct and friendliai/meta-llama-3.1-8b-instruct; both are retired and neither is served by https://api.friendli.ai/serverless/v1/models anymore
  • so every currently served FriendliAI model resolved to no pricing and no context window, and the two entries that did resolve advertised a stale 8k context

How it solves it:

  • replaces those two entries with the seven models the serverless models endpoint actually returns, with every field read from that endpoint
  • adds tests/test_litellm/test_friendliai_model_metadata.py, which pins the lineup, keeps the retired keys from coming back, and asserts the root JSON and the bundled backup never drift apart for this provider

Relevant issues

Linear ticket

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)

osv-scan fails on this branch at the "Scan lockfiles" step. It is unrelated to this PR, which touches two JSON files and one new test file and no lockfile; the same job reports a Node 20 runner deprecation notice. Happy to look at it if you would rather it be green first

Screenshots / Proof of Fix

api.friendli.ai/serverless/v1/models is public and needs no auth, so the data in this PR can be checked against the source directly:

curl -s https://api.friendli.ai/serverless/v1/models -o /tmp/friendli_models.json
python3 - <<'PY'
import json
api = json.load(open("/tmp/friendli_models.json"))["data"]
cat = json.load(open("model_prices_and_context_window.json"))
for m in api:
    k = "friendliai/" + m["id"]
    e, p, f = cat[k], m["pricing"], m["functionality"]
    cache = float(p["input_cache_read"]) if p.get("input_cache_read") else None
    assert e["input_cost_per_token"] == float(p["input"])
    assert e["output_cost_per_token"] == float(p["output"])
    assert e.get("cache_read_input_token_cost") == cache
    assert e["max_input_tokens"] == m["context_length"]
    assert e["max_output_tokens"] == e["max_tokens"] == m["max_completion_tokens"]
    assert e["supports_function_calling"] == f["tool_call"]
    assert e["supports_parallel_function_calling"] == f["parallel_tool_call"]
    assert e["supports_response_schema"] == f["structured_output"]
    print("ok", k)
print(len(api), "models,", len([k for k in cat if k.startswith("friendliai/")]), "in catalog")
PY

Output on this branch:

ok friendliai/Qwen/Qwen3-235B-A22B-Instruct-2507
ok friendliai/LGAI-EXAONE/K-EXAONE-236B-A23B
ok friendliai/MiniMaxAI/MiniMax-M2.5
ok friendliai/deepseek-ai/DeepSeek-V3.2
ok friendliai/zai-org/GLM-5.1
ok friendliai/google/gemma-4-31B-it
ok friendliai/zai-org/GLM-5.2
7 models, 7 in catalog

I will follow up with live proxy logs showing a real completion and its logged cost against friendliai/zai-org/GLM-5.2

Type

Bug Fix

Changes

Seven entries, one per model the serverless endpoint returns. Field mapping, all of it read from that endpoint:

models endpoint cost map
pricing.input input_cost_per_token
pricing.output output_cost_per_token
pricing.input_cache_read cache_read_input_token_cost
context_length max_input_tokens
max_completion_tokens max_output_tokens, max_tokens
functionality.tool_call supports_function_calling
functionality.parallel_tool_call supports_parallel_function_calling
functionality.structured_output supports_response_schema
deprecation_date deprecation_date

supports_reasoning is not something the models endpoint reports, so rather than guess it I probed each model and set the flag from what came back. google/gemma-4-31B-it and deepseek-ai/DeepSeek-V3.2 return no reasoning_content by default but do return it under chat_template_kwargs.enable_thinking, so both get the flag. LGAI-EXAONE/K-EXAONE-236B-A23B, zai-org/GLM-5.1, zai-org/GLM-5.2 and MiniMaxAI/MiniMax-M2.5 return it unprompted. Qwen/Qwen3-235B-A22B-Instruct-2507 returns byte-identical output with thinking on and off and publishes no thinking markers in its chat template, so it does not get the flag; it is the non-thinking half of the Qwen3-235B pair. The transcript is in a comment below

supports_vision on google/gemma-4-31B-it is likewise verified rather than assumed: it answers a base64 image prompt correctly, while non-vision models on this endpoint reject the identical payload with This model does not support image/video inputs

supports_prompt_caching is set on exactly the four models that quote a cache read price. Qwen/Qwen3-235B-A22B-Instruct-2507 reports deprecation_date 2026-08-05T00:00:00Z and carries it through as 2026-08-05, matching the YYYY-MM-DD form already used across this file

Both retired llama entries are removed rather than left with a deprecation_date. They are not merely scheduled for retirement, they are already absent from the endpoint, so keeping their pricing would keep serving cost data for models that cannot be called

Keys are inserted in the same ASCII order the surrounding file uses, and each entry keeps the file's alphabetical field order

QA runbook

The tests read both JSON files off disk and need no network and no provider credentials:

pytest tests/test_litellm/test_friendliai_model_metadata.py -q

I checked they fail when the data regresses rather than only passing on the happy path. Reverting zai-org/GLM-5.2 to a 1000000 context fails 2, re-adding either retired llama key fails 3, dropping cache_read_input_token_cost from the backup copy alone fails 2, flipping supports_function_calling to false on google/gemma-4-31B-it fails 2, adding supports_reasoning to Qwen/Qwen3-235B-A22B-Instruct-2507 fails 2, and dropping it from google/gemma-4-31B-it fails 2

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

@CLAassistant

CLAassistant commented Jul 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds 6 current FriendliAI serverless models (GLM-5.2, GLM-5.1, DeepSeek-V3.2, MiniMax-M2.5, Qwen3-235B, gemma-4-31B) to both JSON catalog files, but the patch was applied twice — every model key appears twice in each file.

  • All 6 model entries are duplicated in both model_prices_and_context_window.json and its backup; JSON parsers (including Python's json.loads) silently discard the first occurrence and use the second, so the entire first block is dead code.
  • The second (winning) copy of friendliai/google/gemma-4-31B-it is missing \"supports_parallel_function_calling\": true and \"supports_tool_choice\": true that are present in the first copy, meaning those capabilities will be invisible to litellm after the merge.
  • The PR description's pricing and context-window figures match the data in the entries, and the additive-only approach (leaving deprecated llama entries in place) is correct.

Confidence Score: 3/5

Not safe to merge as-is: the duplicate-key issue causes the second block to silently override the first, and the second gemma entry is missing two capability flags.

Every model introduced by this PR ends up defined twice in each catalog file. Python's JSON parser takes the last occurrence, so the entire first block is silently discarded. More critically, the surviving second copy of friendliai/google/gemma-4-31B-it omits supports_parallel_function_calling and supports_tool_choice — capabilities the PR explicitly claims to add. Users relying on those flags for routing or validation would get incorrect behavior.

Both model_prices_and_context_window.json and litellm/model_prices_and_context_window_backup.json need the duplicate entries removed and the gemma-4-31B-it entry corrected.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds 6 new FriendliAI serverless models, but each entry is duplicated — all 6 keys appear twice. The second (winning) occurrence of friendliai/google/gemma-4-31B-it is also missing supports_parallel_function_calling and supports_tool_choice.
litellm/model_prices_and_context_window_backup.json Mirror of the primary JSON with the same two problems: all 6 model keys are duplicated, and the second friendliai/google/gemma-4-31B-it entry omits supports_parallel_function_calling and supports_tool_choice.

Reviews (1): Last reviewed commit: "Add FriendliAI serverless (Model API) mo..." | Re-trigger Greptile

Comment thread model_prices_and_context_window.json Resolved
Comment thread model_prices_and_context_window.json Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f26b2128e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread model_prices_and_context_window.json Resolved
@codecov

codecov Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing robust-WJL:add-friendliai-serverless-models (ddcc2cc) with litellm_internal_staging (2412326)

Open in CodSpeed

@robust-WJL
robust-WJL force-pushed the add-friendliai-serverless-models branch 2 times, most recently from 6d1355f to aaefb8c Compare July 16, 2026 06:04
@robust-WJL
robust-WJL changed the base branch from main to litellm_oss_daily_2026_07_15 July 16, 2026 06:05
@robust-WJL robust-WJL changed the title Add current FriendliAI serverless (Model API) models to catalog chore: add current FriendliAI serverless (Model API) models to catalog Jul 16, 2026
@robust-WJL
robust-WJL force-pushed the add-friendliai-serverless-models branch from aaefb8c to 94e4b45 Compare July 16, 2026 06:07
@robust-WJL robust-WJL changed the title chore: add current FriendliAI serverless (Model API) models to catalog fix(friendliai): update serverless catalog (add 6 models, remove deprecated llama) Jul 16, 2026
@robust-WJL

Copy link
Copy Markdown
Author

Hi Team. Resolved the duplicated keys. I don't think OSV Scan failure is related to my PR, but happy to adjust if anything is needed!

@robust-WJL

Copy link
Copy Markdown
Author

Hi LiteLLM team. Any updates regarding this? Let me know if I should submit the request to different channel / fix anything else.

The catalog carried only meta-llama-3.1-70b-instruct and
meta-llama-3.1-8b-instruct. Both are retired; neither is served by
https://api.friendli.ai/serverless/v1/models anymore, so their pricing and
8k context windows were the only FriendliAI data litellm exposed.

Every field is taken from that endpoint, which is public and unauthenticated:
pricing.input, pricing.output and pricing.input_cache_read map onto the token
costs, context_length onto max_input_tokens, max_completion_tokens onto
max_output_tokens and max_tokens, and functionality.tool_call,
functionality.parallel_tool_call and functionality.structured_output onto the
capability flags. Qwen3-235B-A22B-Instruct-2507 reports a deprecation_date of
2026-08-05 and carries it through.

tests/test_litellm/test_friendliai_model_metadata.py pins the lineup, asserts
the retired keys stay absent, and asserts the root JSON and the bundled backup
never drift apart for this provider
@robust-WJL
robust-WJL changed the base branch from litellm_oss_daily_2026_07_15 to litellm_internal_staging July 27, 2026 06:06
@robust-WJL
robust-WJL force-pushed the add-friendliai-serverless-models branch from 94e4b45 to daa43de Compare July 27, 2026 06:06
@robust-WJL robust-WJL changed the title fix(friendliai): update serverless catalog (add 6 models, remove deprecated llama) fix(friendliai): sync serverless catalog with the models API Jul 27, 2026
@robust-WJL

Copy link
Copy Markdown
Author

Heads up on overlap with #34703, so this does not read as a duplicate.

Both PRs touch the FriendliAI region of the cost map, but they are doing different jobs. #34703 teaches .github/workflows/auto_update_price_and_context_window_file.py to sync from https://api.friendli.ai/serverless/v1/models, so the provider gets picked up by the weekly cron the way OpenRouter and Vercel AI Gateway already are. This PR is the data fix: it corrects what is in the map today, drops the two retired llama entries, and adds a regression test that keeps the root JSON and the bundled backup from drifting apart. The automation is the durable answer, the data fix is what makes the current file correct, and neither one covers the other.

One practical note for whoever merges first. #34703 seeds only litellm/model_prices_and_context_window_backup.json, while litellm.model_cost is loaded at import time from model_prices_and_context_window.json at the repo root (model_cost_map_url in litellm/__init__.py, unless LITELLM_LOCAL_MODEL_COST_MAP is set). So the backup alone does not change what installed clients resolve until the cron writes the root file. This PR updates both, which is why the two are worth keeping separate rather than folding into one.

They will conflict textually since they add overlapping keys in the same place. Whichever lands first, I will rebase the other and repost the verification output. I would suggest this one first, since it makes the committed data correct immediately and the cron in #34703 will then just keep reproducing the same values.

Also worth flagging while this is open: Qwen/Qwen3-235B-A22B-Instruct-2507 reports deprecation_date 2026-08-05, which is about a week out, so the entry lands already carrying its retirement date.

CLA is signed now, and I have retargeted this from litellm_oss_daily_2026_07_15 onto litellm_internal_staging per the contributing guidance; that wrong base is probably why it sat unreviewed. Happy to split, reorder, or drop whatever you prefer.

supports_reasoning was guesswork on my part, so I probed each model against
the serverless endpoint instead and set the flag from what came back.

gemma-4-31B-it and DeepSeek-V3.2 return no reasoning_content by default but do
return it under chat_template_kwargs.enable_thinking, so both are reasoning
capable. K-EXAONE-236B-A23B, GLM-5.1, GLM-5.2 and MiniMax-M2.5 return it
without being asked. Qwen3-235B-A22B-Instruct-2507 returns byte-identical
output with thinking on and off and ships no thinking markers in its published
chat template, so it does not get the flag; it is the non-thinking half of the
Qwen3-235B pair.

gemma-4-31B-it also keeps supports_vision: it answers a base64 image prompt
correctly, whereas the non-vision models on this endpoint reject the same
payload with "This model does not support image/video inputs"

The metadata test now pins the reasoning flag per model
@rbren

rbren commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@krrish-berri we'd love to see this get in!

@robust-WJL

Copy link
Copy Markdown
Author

@krrish-berri Hi team. Any progress on this? We have some internal requirement to resolve this catalog problem before Mid August, so would love to get it done before that. Let me know if this PR needs any adjustments.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Superseded by rolling registry audit #37902, which reverified and absorbed the provider-documented metadata changes at field level

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.

3 participants