Skip to content

feat: update Morph model support - #39242

Open
skeptrunedev wants to merge 4 commits into
BerriAI:mainfrom
skeptrunedev:litellm_update_morph_models
Open

skeptrunedev wants to merge 4 commits into
BerriAI:mainfrom
skeptrunedev:litellm_update_morph_models

Conversation

@skeptrunedev

@skeptrunedev skeptrunedev commented Sep 2, 2026 •

Copy link
Copy Markdown

TLDR

Problem this solves:

  • Current Morph chat models are missing from cost tracking
  • Morph requests drop standard OpenAI chat parameters

How it solves it:

  • Adds current model prices, limits, caching, and modalities
  • Passes tools, structured output, sampling, and token limits

User Flow

Before: a developer can call a current Morph model, but LiteLLM lacks its metadata and drops supported request parameters

  1. They call POST https://api.morphllm.com/v1/chat/completions through LiteLLM with model: "morph/morph-dsv4flash"
  2. LiteLLM routes the request, but the model is absent from its catalog
  3. Cost tracking cannot use the current model price, context, or cache rate
  4. Tools and response_format are not forwarded by the Morph provider config

After: the same request routes with current metadata and supported OpenAI parameters

  1. They call POST https://api.morphllm.com/v1/chat/completions through LiteLLM with model: "morph/morph-dsv4flash"
  2. LiteLLM identifies the model as Morph and forwards the request
  3. Cost tracking uses the published input, cached input, and output rates
  4. Tools, response_format, sampling controls, and token limits reach the provider

Relevant issues

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • The focused Morph and model schema tests pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible
  • I have received a Greptile Confidence Score of at least 4/5

Screenshots / Proof of Fix

Before (3dac3f7)

  1. jq 'has("morph/morph-kimik3")' model_prices_and_context_window.json
  2. The result is false

After (81c3598)

  1. The same catalog check returns true
  2. A real litellm.completion call to morph/morph-dsv4flash returns morph litellm ok
  3. The response reports 13 prompt tokens and 7 completion tokens
  4. uv run pytest tests/llm_translation/test_morph.py -q passes 8 tests
  5. uv run pytest tests/test_litellm/test_model_prices_schema.py -q passes 21 tests

Type

New Feature

Caveats (if any)

Final Attestation

  • The tests check model discovery, metadata, parameter mapping, and schema validity

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR expands Morph model catalog metadata and forwards additional OpenAI-compatible chat parameters.

  • Adds five current Morph models, pricing, cache rates, context limits, and modality capabilities.
  • Updates the existing Morph v3 limits.
  • Extends Morph request mapping and adds focused catalog and parameter-mapping tests.

Confidence Score: 4/5

The PR should not merge until Morph tool parameters are gated for the existing v3 models that declare tool calling unsupported.

The native Morph adapter now forwards tools and tool_choice for every model, including two existing models explicitly marked as not supporting those capabilities, allowing invalid requests to reach the provider.

Files Needing Attention: litellm/llms/morph/chat/transformation.py, model_prices_and_context_window.json, tests/llm_translation/test_morph.py

Important Files Changed

Filename Overview
litellm/llms/morph/chat/transformation.py Expands parameter forwarding, but unconditionally enables tool parameters for two models whose metadata declares tools unsupported.
model_prices_and_context_window.json Adds current Morph pricing and capability metadata while retaining explicit no-tool capabilities for the existing v3 models.
litellm/model_prices_and_context_window_backup.json Mirrors the Morph catalog updates from the primary model metadata file.
tests/llm_translation/test_morph.py Adds model and mapping coverage, but the supported-parameter test codifies unconditional tool support for morph-v3-large despite its catalog capabilities.

Reviews (1): Last reviewed commit: "feat: update Morph model support" | Re-trigger Greptile

Comment on lines +52 to +53
"tool_choice",
"tools",

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.

P1 Tool capability gating is bypassed

When callers supply tools or tool_choice for morph-v3-fast or morph-v3-large, this model-agnostic list forwards those fields despite both models declaring tool calling unsupported, causing invalid requests to reach the Morph API and be rejected upstream.

Knowledge Base Used: Provider adapters and capabilities

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 0aadfe1. get_supported_openai_params now withholds tools and tool_choice when the registry entry sets supports_function_calling: false (morph-v3-fast, morph-v3-large), so LiteLLM raises UnsupportedParamsError or drops them under drop_params. Models not yet in the registry still pass tools through. Coverage is in tests/test_litellm/llms/morph/chat/test_morph_chat_transformation.py (ccf2b45).

@codspeed

codspeed Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing skeptrunedev:litellm_update_morph_models (ccf2b45) with litellm_internal_staging (c2c2a62)

Open in CodSpeed

@codecov

codecov Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

skeptrune added 2 commits September 13, 2026 03:14
Merge litellm_internal_staging and address PR review and CI failures:

- Withhold tools/tool_choice for Morph models whose registry entry sets
  supports_function_calling to false (morph-v3-fast, morph-v3-large).
  Models missing from the registry still pass tools through.
- Set morph-v3 max_tokens to max_output_tokens (131072) so
  test_max_tokens_consistency passes.
- Keep the updated Morph model info tests that upstream removed.

Claude-Session: https://claude.ai/code/session_01LDxX4kpF7ajmSNbhzPsqNT
tests/llm_translation is outside the coverage-reporting unit shards, so
add registry-gating tests under tests/test_litellm/llms/morph.

Claude-Session: https://claude.ai/code/session_01LDxX4kpF7ajmSNbhzPsqNT
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


skeptrune seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
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