Files
litellm/tests/local_testing
Cesar Garcia d30c25af21 feat(gemini): use responseJsonSchema for Gemini 2.0+ models (#19314)
* feat(gemini): add opt-in support for responseJsonSchema

Add support for Gemini's native responseJsonSchema parameter which uses
standard JSON Schema format instead of OpenAPI-style responseSchema.

Benefits of responseJsonSchema (Gemini 2.0+ only):
- Standard JSON Schema format (lowercase types)
- Supports additionalProperties for stricter validation
- Better compatibility with Pydantic's model_json_schema()
- No propertyOrdering required

Usage:
```python
response_format={
    "type": "json_schema",
    "json_schema": {"schema": {...}},
    "use_json_schema": True  # opt-in
}
```

This is backwards compatible - existing code continues to use
responseSchema by default.

Closes #16340

* docs: add documentation for use_json_schema parameter

Document the new use_json_schema option for Gemini 2.0+ models
in the JSON Mode documentation.

* refactor(gemini): use responseJsonSchema by default for Gemini 2.0+

Remove opt-in flag `use_json_schema` and automatically detect model version:
- Gemini 2.0+: uses responseJsonSchema (standard JSON Schema, supports additionalProperties)
- Gemini 1.5: uses responseSchema (OpenAPI format, legacy)

This follows LiteLLM's philosophy of abstracting provider differences -
users write the same code regardless of model version.

* test(vertex): update json_schema tests to accept both responseSchema formats

Gemini 2.x+ uses responseJsonSchema while Gemini 1.x uses responseSchema.
Update tests to accept both formats since litellm now auto-selects based
on model version.
2026-01-19 10:45:37 -08:00
..
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-11-22 09:28:37 -08:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-11-22 09:41:15 -08:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-09-01 17:59:40 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-09-01 17:04:47 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 16:46:29 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-09-01 17:04:47 -07:00
2026-01-07 15:02:10 +05:30
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00