Skip to content

fix(gemini): add presence_penalty support for Google AI Studio - #18154

Merged
2 commits merged into
BerriAI:mainfrom
Chesars:fix/gemini-presence-penalty
Jan 12, 2026
Merged

2 commits merged into
BerriAI:mainfrom
Chesars:fix/gemini-presence-penalty

Conversation

@Chesars

@Chesars Chesars commented Dec 17, 2025 •

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #14753

Pre-Submission checklist

  • I have Added testing in the tests/litellm/ directory
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Summary

presencePenalty` is a native Google Gemini API parameter as documented:

When using presence_penalty with Google AI Studio Gemini models via LiteLLM, it throws an UnsupportedParamsError:

import litellm

response = litellm.completion(
    model='gemini/gemini-2.0-flash',
    messages=[{'role': 'user', 'content': 'Hello'}],
    presence_penalty=0.5
)
# ERROR: litellm.UnsupportedParamsError: gemini does not support parameters: ['presence_penalty']

Solution

Added presence_penalty to the list of supported OpenAI params in GoogleAIStudioGeminiConfig.get_supported_openai_params().

The parameter mapping to presencePenalty (camelCase) already existed in the parent class VertexGeminiConfig, so only the supported params list needed updating.

Tests Added

  • test_google_ai_studio_presence_penalty_supported in tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py

Note

Ensures Google AI Studio Gemini accepts presence_penalty without raising UnsupportedParamsError.

  • Adds presence_penalty to GoogleAIStudioGeminiConfig.get_supported_openai_params()
  • Adds regression test test_google_ai_studio_presence_penalty_supported validating support
  • Updates tests to import GoogleAIStudioGeminiConfig

Written by Cursor Bugbot for commit b962f61. This will update automatically on new commits. Configure here.

@vercel

vercel Bot commented Dec 17, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
litellm Ready Ready Preview, Comment Jan 12, 2026 11:43am

@ghost
ghost merged commit f791299 into BerriAI:main Jan 12, 2026
6 of 8 checks passed
@Chesars
Chesars deleted the fix/gemini-presence-penalty branch January 12, 2026 11:55
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…AI#18154)

Fixes BerriAI#14753

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
This pull request was closed.

This branch was successfully deployed

1 active deployment
Preview — b962f61a Deployed Jan 12, 2026 by vercel[bot]
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.

[Bug]: Google Gemini Flash 2.0 - Parameter "presence_penalty" not supported

1 participant