From f9f861ddf594082e82bfca522018b53e0b4db4eb Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 12 May 2026 14:17:25 -0700 Subject: [PATCH 1/8] fix(gemini): normalize response_schema on native generateContent The /v1beta/models/{model}:generateContent passthrough forwarded generationConfig.response_schema verbatim, so schemas containing $defs, $ref, anyOf-with-null, default, or title were rejected by Gemini even though /chat/completions already handles them. GoogleGenAIConfig.transform_generate_content_request now calls a new _normalize_response_schema helper that mirrors the chat/completions path: Gemini 2.0+ models get the schema promoted to responseJsonSchema via _build_json_schema (preserving $defs/$ref natively), older models keep responseSchema but the schema is flattened with _build_vertex_schema. VertexAIGoogleGenAIConfig (which overrides the transform entirely) calls the same helper before building the request. --- .../gemini/google_genai/transformation.py | 68 +++++++++ .../vertex_ai/google_genai/transformation.py | 3 + .../test_google_genai_transformation.py | 134 ++++++++++++++++++ 3 files changed, 205 insertions(+) diff --git a/litellm/llms/gemini/google_genai/transformation.py b/litellm/llms/gemini/google_genai/transformation.py index 7c4c7dba626a..9f588ba6d059 100644 --- a/litellm/llms/gemini/google_genai/transformation.py +++ b/litellm/llms/gemini/google_genai/transformation.py @@ -2,6 +2,7 @@ Transformation for Calling Google models in their native format. """ +from copy import deepcopy from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Tuple, Union, cast import httpx @@ -11,6 +12,11 @@ from litellm.llms.base_llm.google_genai.transformation import ( BaseGoogleGenAIGenerateContentConfig, ) +from litellm.llms.vertex_ai.common_utils import ( + _build_json_schema, + _build_vertex_schema, + supports_response_json_schema, +) from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import VertexLLM from litellm.types.router import GenericLiteLLMParams @@ -302,6 +308,66 @@ async def get_auth_token_and_url( litellm_params=litellm_params, ) + @staticmethod + def _normalize_response_schema( + generate_content_config_dict: Dict, model: str + ) -> None: + """ + Normalize ``responseSchema`` / ``responseJsonSchema`` in-place so the + native ``generateContent`` passthrough mirrors the chat/completions + path. Without this, schemas containing ``$defs``/``$ref``, ``anyOf`` + with ``null``, ``default``, ``title``, etc. are forwarded verbatim and + Gemini rejects them. + + - Gemini 2.0+ supports ``responseJsonSchema`` natively (preserves + ``$defs``/``$ref``). Promote ``responseSchema`` to + ``responseJsonSchema`` for those models. + - Older models keep ``responseSchema`` but the schema is flattened to + the OpenAPI subset via ``_build_vertex_schema``. + """ + schema_key = next( + ( + k + for k in ("responseSchema", "response_schema") + if k in generate_content_config_dict + ), + None, + ) + json_schema_key = next( + ( + k + for k in ("responseJsonSchema", "response_json_schema") + if k in generate_content_config_dict + ), + None, + ) + + use_json_schema = supports_response_json_schema(model) + + if json_schema_key is not None: + value = generate_content_config_dict[json_schema_key] + if isinstance(value, dict): + generate_content_config_dict[json_schema_key] = _build_json_schema( + deepcopy(value) + ) + + if schema_key is None: + return + + value = generate_content_config_dict[schema_key] + if not isinstance(value, dict): + return + + if use_json_schema: + generate_content_config_dict.pop(schema_key) + generate_content_config_dict["responseJsonSchema"] = _build_json_schema( + deepcopy(value) + ) + else: + generate_content_config_dict[schema_key] = _build_vertex_schema( + parameters=deepcopy(value), add_property_ordering=True + ) + def transform_generate_content_request( self, model: str, @@ -315,6 +381,8 @@ def transform_generate_content_request( GenerateContentRequestDict, ) + self._normalize_response_schema(generate_content_config_dict, model) + typed_generate_content_request = GenerateContentRequestDict( model=model, contents=contents, diff --git a/litellm/llms/vertex_ai/google_genai/transformation.py b/litellm/llms/vertex_ai/google_genai/transformation.py index d7a4ceeb3e7b..c1120d9ab8bc 100644 --- a/litellm/llms/vertex_ai/google_genai/transformation.py +++ b/litellm/llms/vertex_ai/google_genai/transformation.py @@ -79,6 +79,9 @@ def transform_generate_content_request( Transform the generate content request for Vertex AI. Since Vertex AI natively supports Google GenAI format, we can pass most fields directly. """ + if generate_content_config_dict: + self._normalize_response_schema(generate_content_config_dict, model) + # Build the request in Google GenAI format that Vertex AI expects result = { "model": model, diff --git a/tests/test_litellm/google_genai/test_google_genai_transformation.py b/tests/test_litellm/google_genai/test_google_genai_transformation.py index 908a68110fd0..88fbcdf0689b 100644 --- a/tests/test_litellm/google_genai/test_google_genai_transformation.py +++ b/tests/test_litellm/google_genai/test_google_genai_transformation.py @@ -335,6 +335,140 @@ def test_transform_generate_content_request_system_instruction_with_tools(): assert result["model"] == "gemini-3-flash-preview" +def test_transform_generate_content_request_normalizes_response_schema_2_5(): + """For Gemini 2.0+, ``response_schema`` with ``$defs``/``$ref`` should be + promoted to ``responseJsonSchema`` (which Gemini 2.0+ accepts natively), + not forwarded as ``responseSchema`` (which rejects ``$defs``).""" + config = GoogleGenAIConfig() + + schema = { + "$defs": { + "Highlight": { + "type": "object", + "properties": { + "title": {"type": "string"}, + "detail": {"type": "string"}, + }, + "required": ["title"], + } + }, + "type": "object", + "properties": { + "park_name": {"type": "string"}, + "highlights": { + "type": "array", + "items": {"$ref": "#/$defs/Highlight"}, + }, + }, + "required": ["park_name", "highlights"], + } + + result = config.transform_generate_content_request( + model="gemini-2.5-flash-lite", + contents=[{"role": "user", "parts": [{"text": "hi"}]}], + tools=None, + generate_content_config_dict={ + "responseMimeType": "application/json", + "responseSchema": schema, + }, + system_instruction=None, + ) + + gen_config = result["generationConfig"] + assert "responseSchema" not in gen_config + assert "responseJsonSchema" in gen_config + normalized = gen_config["responseJsonSchema"] + # _build_json_schema preserves $defs/$ref for 2.0+ models + assert "$defs" in normalized + assert normalized["properties"]["highlights"]["items"] == { + "$ref": "#/$defs/Highlight" + } + + +def test_transform_generate_content_request_flattens_response_schema_1_5(): + """For Gemini 1.5, ``responseSchema`` is kept but flattened via + ``_build_vertex_schema`` so ``$defs``/``$ref`` are unpacked.""" + config = GoogleGenAIConfig() + + schema = { + "$defs": { + "Highlight": { + "type": "object", + "properties": {"title": {"type": "string"}}, + "required": ["title"], + } + }, + "type": "object", + "properties": { + "highlights": { + "type": "array", + "items": {"$ref": "#/$defs/Highlight"}, + } + }, + "required": ["highlights"], + } + + result = config.transform_generate_content_request( + model="gemini-1.5-pro", + contents=[{"role": "user", "parts": [{"text": "hi"}]}], + tools=None, + generate_content_config_dict={"responseSchema": schema}, + system_instruction=None, + ) + + gen_config = result["generationConfig"] + assert "responseSchema" in gen_config + assert "responseJsonSchema" not in gen_config + normalized = gen_config["responseSchema"] + # $defs should be stripped, $ref expanded inline + assert "$defs" not in normalized + items = normalized["properties"]["highlights"]["items"] + assert "$ref" not in items + assert "title" in items["properties"] + assert items["properties"]["title"]["type"].lower() == "string" + + +def test_transform_generate_content_request_passes_through_response_json_schema(): + """If the caller already used ``responseJsonSchema``, it should be + preserved (Gemini 2.0+ accepts standard JSON Schema as-is).""" + config = GoogleGenAIConfig() + + schema = { + "type": "object", + "properties": {"name": {"type": "string"}}, + "required": ["name"], + } + + result = config.transform_generate_content_request( + model="gemini-2.5-flash-lite", + contents=[{"role": "user", "parts": [{"text": "hi"}]}], + tools=None, + generate_content_config_dict={"responseJsonSchema": schema}, + system_instruction=None, + ) + + gen_config = result["generationConfig"] + assert gen_config["responseJsonSchema"] == schema + assert "responseSchema" not in gen_config + + +def test_transform_generate_content_request_without_schema_unchanged(): + """No schema in config → no normalization side effects.""" + config = GoogleGenAIConfig() + + result = config.transform_generate_content_request( + model="gemini-2.5-flash-lite", + contents=[{"role": "user", "parts": [{"text": "hi"}]}], + tools=None, + generate_content_config_dict={"temperature": 0.7}, + system_instruction=None, + ) + + assert result["generationConfig"]["temperature"] == 0.7 + assert "responseSchema" not in result["generationConfig"] + assert "responseJsonSchema" not in result["generationConfig"] + + def test_validate_environment_with_dict_api_key(): """ Test that validate_environment correctly handles api_key as a dict. From 7b4e749dbd02aeeed3ca0acc7f12156b7794f30d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 12 May 2026 21:32:09 +0000 Subject: [PATCH 2/8] fix(gemini): preserve caller-supplied responseJsonSchema when responseSchema co-present Previously, when both responseJsonSchema and responseSchema were present on Gemini 2.0+, _normalize_response_schema processed responseJsonSchema first (no-op normalization) then unconditionally promoted responseSchema to responseJsonSchema, clobbering the caller-supplied value. Now skip the promotion (and drop the redundant responseSchema) when the caller already supplied responseJsonSchema. Co-authored-by: Mateo Wang --- .../gemini/google_genai/transformation.py | 5 +++ .../test_google_genai_transformation.py | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/litellm/llms/gemini/google_genai/transformation.py b/litellm/llms/gemini/google_genai/transformation.py index 9f588ba6d059..5dd8d9551bdc 100644 --- a/litellm/llms/gemini/google_genai/transformation.py +++ b/litellm/llms/gemini/google_genai/transformation.py @@ -359,6 +359,11 @@ def _normalize_response_schema( return if use_json_schema: + if json_schema_key is not None: + # Caller already supplied responseJsonSchema; preserve it and + # drop the redundant responseSchema rather than clobbering. + generate_content_config_dict.pop(schema_key) + return generate_content_config_dict.pop(schema_key) generate_content_config_dict["responseJsonSchema"] = _build_json_schema( deepcopy(value) diff --git a/tests/test_litellm/google_genai/test_google_genai_transformation.py b/tests/test_litellm/google_genai/test_google_genai_transformation.py index 88fbcdf0689b..972ea138091a 100644 --- a/tests/test_litellm/google_genai/test_google_genai_transformation.py +++ b/tests/test_litellm/google_genai/test_google_genai_transformation.py @@ -452,6 +452,38 @@ def test_transform_generate_content_request_passes_through_response_json_schema( assert "responseSchema" not in gen_config +def test_transform_generate_content_request_preserves_response_json_schema_when_response_schema_co_present(): + """When both ``responseJsonSchema`` and ``responseSchema`` are supplied on + Gemini 2.0+, the caller's ``responseJsonSchema`` must win — the + ``responseSchema`` value must not clobber it.""" + config = GoogleGenAIConfig() + + caller_json_schema = { + "type": "object", + "properties": {"answer": {"type": "string"}}, + "required": ["answer"], + } + redundant_response_schema = { + "type": "object", + "properties": {"other": {"type": "string"}}, + } + + result = config.transform_generate_content_request( + model="gemini-2.5-flash-lite", + contents=[{"role": "user", "parts": [{"text": "hi"}]}], + tools=None, + generate_content_config_dict={ + "responseJsonSchema": caller_json_schema, + "responseSchema": redundant_response_schema, + }, + system_instruction=None, + ) + + gen_config = result["generationConfig"] + assert "responseSchema" not in gen_config + assert gen_config["responseJsonSchema"] == caller_json_schema + + def test_transform_generate_content_request_without_schema_unchanged(): """No schema in config → no normalization side effects.""" config = GoogleGenAIConfig() From 14a64ad393fe980d58d188a599b5700ce6be1918 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 12 May 2026 14:39:36 -0700 Subject: [PATCH 3/8] chore: strip restating comments from response-schema normalize Drop the docstring on _normalize_response_schema and the two inline comments that just restated what the surrounding code/asserts already say. Function name + variable names carry the intent; PR description covers the why-it-exists context. --- .../llms/gemini/google_genai/transformation.py | 15 --------------- .../test_google_genai_transformation.py | 2 -- 2 files changed, 17 deletions(-) diff --git a/litellm/llms/gemini/google_genai/transformation.py b/litellm/llms/gemini/google_genai/transformation.py index 5dd8d9551bdc..23ddba78a5f1 100644 --- a/litellm/llms/gemini/google_genai/transformation.py +++ b/litellm/llms/gemini/google_genai/transformation.py @@ -312,19 +312,6 @@ async def get_auth_token_and_url( def _normalize_response_schema( generate_content_config_dict: Dict, model: str ) -> None: - """ - Normalize ``responseSchema`` / ``responseJsonSchema`` in-place so the - native ``generateContent`` passthrough mirrors the chat/completions - path. Without this, schemas containing ``$defs``/``$ref``, ``anyOf`` - with ``null``, ``default``, ``title``, etc. are forwarded verbatim and - Gemini rejects them. - - - Gemini 2.0+ supports ``responseJsonSchema`` natively (preserves - ``$defs``/``$ref``). Promote ``responseSchema`` to - ``responseJsonSchema`` for those models. - - Older models keep ``responseSchema`` but the schema is flattened to - the OpenAPI subset via ``_build_vertex_schema``. - """ schema_key = next( ( k @@ -360,8 +347,6 @@ def _normalize_response_schema( if use_json_schema: if json_schema_key is not None: - # Caller already supplied responseJsonSchema; preserve it and - # drop the redundant responseSchema rather than clobbering. generate_content_config_dict.pop(schema_key) return generate_content_config_dict.pop(schema_key) diff --git a/tests/test_litellm/google_genai/test_google_genai_transformation.py b/tests/test_litellm/google_genai/test_google_genai_transformation.py index 972ea138091a..b9af4975a7ff 100644 --- a/tests/test_litellm/google_genai/test_google_genai_transformation.py +++ b/tests/test_litellm/google_genai/test_google_genai_transformation.py @@ -378,7 +378,6 @@ def test_transform_generate_content_request_normalizes_response_schema_2_5(): assert "responseSchema" not in gen_config assert "responseJsonSchema" in gen_config normalized = gen_config["responseJsonSchema"] - # _build_json_schema preserves $defs/$ref for 2.0+ models assert "$defs" in normalized assert normalized["properties"]["highlights"]["items"] == { "$ref": "#/$defs/Highlight" @@ -420,7 +419,6 @@ def test_transform_generate_content_request_flattens_response_schema_1_5(): assert "responseSchema" in gen_config assert "responseJsonSchema" not in gen_config normalized = gen_config["responseSchema"] - # $defs should be stripped, $ref expanded inline assert "$defs" not in normalized items = normalized["properties"]["highlights"]["items"] assert "$ref" not in items From d0070051e9d1a01fc2d6578780e22a21737487f7 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 12 May 2026 22:16:58 +0000 Subject: [PATCH 4/8] perf(gemini): drop redundant deepcopy on responseJsonSchema normalize _build_json_schema is a no-op (returns its argument unchanged), so the deepcopy + round-trip on the responseJsonSchema branch allocated a full schema copy on every request with no observable effect. Forward the caller's value as-is, and just move the popped responseSchema value when promoting on Gemini 2.0+. Co-authored-by: Mateo Wang --- .../llms/gemini/google_genai/transformation.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/litellm/llms/gemini/google_genai/transformation.py b/litellm/llms/gemini/google_genai/transformation.py index 23ddba78a5f1..3a59336ecdf8 100644 --- a/litellm/llms/gemini/google_genai/transformation.py +++ b/litellm/llms/gemini/google_genai/transformation.py @@ -13,7 +13,6 @@ BaseGoogleGenAIGenerateContentConfig, ) from litellm.llms.vertex_ai.common_utils import ( - _build_json_schema, _build_vertex_schema, supports_response_json_schema, ) @@ -329,14 +328,8 @@ def _normalize_response_schema( None, ) - use_json_schema = supports_response_json_schema(model) - - if json_schema_key is not None: - value = generate_content_config_dict[json_schema_key] - if isinstance(value, dict): - generate_content_config_dict[json_schema_key] = _build_json_schema( - deepcopy(value) - ) + # responseJsonSchema is forwarded as-is — Gemini 2.0+ accepts standard + # JSON Schema natively, so no transformation (and no deepcopy) is needed. if schema_key is None: return @@ -345,14 +338,12 @@ def _normalize_response_schema( if not isinstance(value, dict): return - if use_json_schema: + if supports_response_json_schema(model): if json_schema_key is not None: generate_content_config_dict.pop(schema_key) return generate_content_config_dict.pop(schema_key) - generate_content_config_dict["responseJsonSchema"] = _build_json_schema( - deepcopy(value) - ) + generate_content_config_dict["responseJsonSchema"] = value else: generate_content_config_dict[schema_key] = _build_vertex_schema( parameters=deepcopy(value), add_property_ordering=True From c81dea40221b1df8f4d18138c0a00e35ac771cca Mon Sep 17 00:00:00 2001 From: Mateo Wang <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 12 May 2026 17:01:33 -0700 Subject: [PATCH 5/8] style: remove unneeded comment --- litellm/llms/gemini/google_genai/transformation.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/litellm/llms/gemini/google_genai/transformation.py b/litellm/llms/gemini/google_genai/transformation.py index 3a59336ecdf8..aafa106d8b45 100644 --- a/litellm/llms/gemini/google_genai/transformation.py +++ b/litellm/llms/gemini/google_genai/transformation.py @@ -328,9 +328,6 @@ def _normalize_response_schema( None, ) - # responseJsonSchema is forwarded as-is — Gemini 2.0+ accepts standard - # JSON Schema natively, so no transformation (and no deepcopy) is needed. - if schema_key is None: return From dac62e56239a0e6949be2982bf9087fea97e1fb6 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 13 May 2026 00:08:52 +0000 Subject: [PATCH 6/8] fix(gemini): drop unsupported responseJsonSchema for older models --- litellm/llms/gemini/google_genai/transformation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litellm/llms/gemini/google_genai/transformation.py b/litellm/llms/gemini/google_genai/transformation.py index aafa106d8b45..b5bbafadee4d 100644 --- a/litellm/llms/gemini/google_genai/transformation.py +++ b/litellm/llms/gemini/google_genai/transformation.py @@ -342,6 +342,8 @@ def _normalize_response_schema( generate_content_config_dict.pop(schema_key) generate_content_config_dict["responseJsonSchema"] = value else: + if json_schema_key is not None: + generate_content_config_dict.pop(json_schema_key) generate_content_config_dict[schema_key] = _build_vertex_schema( parameters=deepcopy(value), add_property_ordering=True ) From 49f601ed8bab4cb94b34d3847aaa2e8ebb89266f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 13 May 2026 04:11:31 +0000 Subject: [PATCH 7/8] test(gemini): add parity test between native and chat schema normalization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per @Sameerlite review: lock the two Gemini schema-normalization paths together. If either GoogleGenAIConfig._normalize_response_schema (native generateContent) or VertexGeminiConfig.apply_response_schema_transformation (/chat/completions) drifts, the parity test fails — forcing both to be updated together. --- .../test_google_genai_transformation.py | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tests/test_litellm/google_genai/test_google_genai_transformation.py b/tests/test_litellm/google_genai/test_google_genai_transformation.py index b9af4975a7ff..6b0cd500a828 100644 --- a/tests/test_litellm/google_genai/test_google_genai_transformation.py +++ b/tests/test_litellm/google_genai/test_google_genai_transformation.py @@ -482,6 +482,69 @@ def test_transform_generate_content_request_preserves_response_json_schema_when_ assert gen_config["responseJsonSchema"] == caller_json_schema +def test_response_schema_normalization_parity_across_chat_and_native_paths(): + """Parity guard between the two Gemini schema-normalization paths. + + The native ``generateContent`` path (``_normalize_response_schema``) must + produce the same normalized schema as the ``/chat/completions`` path + (``apply_response_schema_transformation``) for the same input schema, on + both Gemini 2.0+ and Gemini 1.5. If either implementation drifts, this + test fails — forcing both paths to be updated together. + """ + from copy import deepcopy + + from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import ( + VertexGeminiConfig, + ) + + schema = { + "$defs": { + "Highlight": { + "type": "object", + "properties": { + "title": {"type": "string"}, + "detail": {"type": "string"}, + }, + "required": ["title"], + } + }, + "type": "object", + "properties": { + "park_name": {"type": "string"}, + "highlights": { + "type": "array", + "items": {"$ref": "#/$defs/Highlight"}, + }, + "rating": {"anyOf": [{"type": "number"}, {"type": "null"}]}, + }, + "required": ["park_name", "highlights"], + } + + native_config = GoogleGenAIConfig() + chat_config = VertexGeminiConfig() + + for model, native_out_key, chat_out_key in ( + ("gemini-2.5-flash-lite", "responseJsonSchema", "response_json_schema"), + ("gemini-1.5-pro", "responseSchema", "response_schema"), + ): + native_dict = {"responseSchema": deepcopy(schema)} + native_config._normalize_response_schema(native_dict, model) + + chat_optional_params: dict = {} + chat_config.apply_response_schema_transformation( + value={"type": "json_schema", "response_schema": deepcopy(schema)}, + optional_params=chat_optional_params, + model=model, + ) + + assert native_dict[native_out_key] == chat_optional_params[chat_out_key], ( + f"Schema normalization drifted between native generateContent and " + f"chat/completions paths for {model}. Update both " + f"GoogleGenAIConfig._normalize_response_schema and " + f"VertexGeminiConfig.apply_response_schema_transformation together." + ) + + def test_transform_generate_content_request_without_schema_unchanged(): """No schema in config → no normalization side effects.""" config = GoogleGenAIConfig() From 9b8474c3916fdd5ce7e1caa8504878413e971883 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 13 May 2026 04:37:36 +0000 Subject: [PATCH 8/8] fix(google_genai): preserve key naming convention in _normalize_response_schema When the input schema key is snake_case (response_schema), the promoted JSON schema key should also be snake_case (response_json_schema) instead of mixing in camelCase (responseJsonSchema). This matters for the Vertex AI google_genai path which converts all keys to snake_case before calling _normalize_response_schema. --- litellm/llms/gemini/google_genai/transformation.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/litellm/llms/gemini/google_genai/transformation.py b/litellm/llms/gemini/google_genai/transformation.py index b5bbafadee4d..ee201af7e1a4 100644 --- a/litellm/llms/gemini/google_genai/transformation.py +++ b/litellm/llms/gemini/google_genai/transformation.py @@ -340,7 +340,12 @@ def _normalize_response_schema( generate_content_config_dict.pop(schema_key) return generate_content_config_dict.pop(schema_key) - generate_content_config_dict["responseJsonSchema"] = value + new_json_schema_key = ( + "response_json_schema" + if schema_key == "response_schema" + else "responseJsonSchema" + ) + generate_content_config_dict[new_json_schema_key] = value else: if json_schema_key is not None: generate_content_config_dict.pop(json_schema_key)