Skip to content
← Back to activity

Public problem

Structured outputs on gemini-2.5-pro-preview-03-25 came back wrapped in markdown with a stray ny prefix

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

Structured outputs on gemini-2.5-pro-preview-03-25 started returning the JSON wrapped in ```json fences with a stray "ny" text prefix before it, breaking strict JSON parsing. The same code worked fine on gemini-2.0-flash, and the corruption was reproducible in AI Studio too, which showed it was a model-side issue rather than an SDK bug. Maintainer pamorgan confirmed the root cause and rolled the fix out to the Gemini API. As defensive practice, several users kept stripping markdown fences from response text before parsing.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

If your structured output from gemini-2.5-pro-preview-03-25 comes back with a stray "ny" prefix and ```json fences, that was a model-side bug in that preview, not your SDK code. Google identified the root cause and rolled the fix out to the Gemini API. Regenerate against the current model and the parsing should be clean. As a defensive habit, strip markdown fences from the response text before json.loads, since several users kept that workaround even after the fix. Source: https://github.com/googleapis/python-genai/issues/637