litellm - 💡(How to fix) Fix [Bug]: Model replicate/anthropic/claude-opus-4.6 did not work [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#26786Fetched 2026-04-30 06:19:52
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Error Message

Prediction failed

Error: Prediction input failed validation: {"detail":[{"loc":["body","input","max_new_tokens"],"msg":"Unexpected field 'max_new_tokens'","type":"value_error.extra"},{"loc":["body","input","stream"],"msg":"Unexpected field 'stream'","type":"value_error.extra"},{"loc":["body","input","temperature"],"msg":"Unexpected field 'temperature'","type":"value_error.extra"}]}

Fix Action

Fix / Workaround

I patched as follows as a workaround:

def _patched_map_openai_params( self: litellm.ReplicateConfig, non_default_params: dict[str, Any], optional_params: dict[str, Any], model: str, drop_params: bool, ) -> dict[str, Any]: if "/anthropic/" in model or model.startswith("anthropic/"): for param, value in non_default_params.items(): if param == "max_tokens": optional_params["max_tokens"] = max(value, _REPLICATE_ANTHROPIC_MIN_MAX_TOKENS) # Intentionally drop "stream" and "temperature": the Replicate Anthropic # input schema rejects them. Streaming still works via the prediction URL. # Tell ReplicateConfig.transform_request to pop the system message into # the dedicated system_prompt input field. optional_params["supports_system_prompt"] = True return optional_params return _original_map_openai_params( self, non_default_params, optional_params, model, drop_params )

litellm.ReplicateConfig.map_openai_params = _patched_map_openai_params # type: ignore[method-assign]

Code Example

Prediction failed

Error: Prediction input failed validation: {"detail":[{"loc":["body","input","max_new_tokens"],"msg":"Unexpected field 'max_new_tokens'","type":"value_error.extra"},{"loc":["body","input","stream"],"msg":"Unexpected field 'stream'","type":"value_error.extra"},{"loc":["body","input","temperature"],"msg":"Unexpected field 'temperature'","type":"value_error.extra"}]}
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

In the replicate log I see:

Prediction failed

Error: Prediction input failed validation: {"detail":[{"loc":["body","input","max_new_tokens"],"msg":"Unexpected field 'max_new_tokens'","type":"value_error.extra"},{"loc":["body","input","stream"],"msg":"Unexpected field 'stream'","type":"value_error.extra"},{"loc":["body","input","temperature"],"msg":"Unexpected field 'temperature'","type":"value_error.extra"}]}

I patched as follows as a workaround:

_REPLICATE_ANTHROPIC_MIN_MAX_TOKENS = 1024 _original_map_openai_params = litellm.ReplicateConfig.map_openai_params

def _patched_map_openai_params( self: litellm.ReplicateConfig, non_default_params: dict[str, Any], optional_params: dict[str, Any], model: str, drop_params: bool, ) -> dict[str, Any]: if "/anthropic/" in model or model.startswith("anthropic/"): for param, value in non_default_params.items(): if param == "max_tokens": optional_params["max_tokens"] = max(value, _REPLICATE_ANTHROPIC_MIN_MAX_TOKENS) # Intentionally drop "stream" and "temperature": the Replicate Anthropic # input schema rejects them. Streaming still works via the prediction URL. # Tell ReplicateConfig.transform_request to pop the system message into # the dedicated system_prompt input field. optional_params["supports_system_prompt"] = True return optional_params return _original_map_openai_params( self, non_default_params, optional_params, model, drop_params )

litellm.ReplicateConfig.map_openai_params = _patched_map_openai_params # type: ignore[method-assign]

Steps to Reproduce

  1. Call litellm.completion with model replicate/anthropic/claude-opus-4.6

Relevant log output

Prediction failed

Error: Prediction input failed validation: {"detail":[{"loc":["body","input","max_new_tokens"],"msg":"Unexpected field 'max_new_tokens'","type":"value_error.extra"},{"loc":["body","input","stream"],"msg":"Unexpected field 'stream'","type":"value_error.extra"},{"loc":["body","input","temperature"],"msg":"Unexpected field 'temperature'","type":"value_error.extra"}]}

What part of LiteLLM is this about?

SDK (litellm Python package)

What LiteLLM version are you on ?

1.83.14

Twitter / LinkedIn details

No response

extent analysis

TL;DR

The issue can be resolved by modifying the map_openai_params function to handle the max_new_tokens, stream, and temperature fields correctly for the Anthropic model.

Guidance

  • The error message indicates that the max_new_tokens, stream, and temperature fields are not expected in the input validation for the Anthropic model. The provided patch attempts to address this by dropping these fields.
  • To verify the fix, call litellm.completion with the modified map_openai_params function and check if the prediction is successful.
  • The patch sets supports_system_prompt to True for Anthropic models, which may need to be adjusted based on the actual requirements.
  • The REPLICATE_ANTHROPIC_MIN_MAX_TOKENS constant is set to 1024, which may need to be adjusted based on the specific use case.

Example

# The provided patch code can be used as an example
def _patched_map_openai_params(
    self: litellm.ReplicateConfig,
    non_default_params: dict[str, Any],
    optional_params: dict[str, Any],
    model: str,
    drop_params: bool,
) -> dict[str, Any]:
    # ...

Notes

The provided patch is a workaround and may not be the final solution. The root cause of the issue is the mismatch between the expected input fields for the Anthropic model and the actual fields provided.

Recommendation

Apply the provided workaround patch to the map_openai_params function, as it attempts to address the issue by dropping the unexpected fields and setting supports_system_prompt to True. However, this may need to be adjusted based on the actual requirements and use case.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Bug]: Model replicate/anthropic/claude-opus-4.6 did not work [1 participants]