pydantic-ai icon indicating copy to clipboard operation
pydantic-ai copied to clipboard

Support "responseMimeType" as part of generationConfig for Gemini

Open talos opened this issue 6 months ago • 1 comments

Description

Gemini allows you to ask the model to create "structured output" without specifying a schema. This ends up being "JSON mode", with untyped (but valid JSON) output.

This is generally useful because prompting the model to "write JSON" isn't foolproof, it will often include various delimiters etc.

Image

This could be supported by allowing a customization of responseMimeType for GeminiModelSettings. Right now only "gemini_safety_settings" is supported.

LMK if you'd prefer I try to open a PR for this, it just might be a minute. Seems like a nice improvement and light lift. Keep up the great work!

References

No response

talos avatar Mar 28 '25 22:03 talos