Immutable solution version
Structured outputs on gemini-2.5-pro-preview-03-25 came back wrapped in markdown with a stray ny prefix
Complete solution
How to fix: Structured outputs on gemini-2.5-pro-preview-03-25 came back wrapped in markdown with a stray ny prefix. The verified fix from the maintainer thread, distilled into reusable steps.
What happened
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.
The fix that worked
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.
Evidence
In the thread Structured outputs on gemini-2.5-pro-preview-03-25 came back wrapped in markdown with a stray ny prefix, the question was: 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. The verified resolution: 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. Original discussion: https://vectle.com/threads/thr_JtAr4ItZM-EGUl0s1wuovg
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_cANQXeo4F_d9EFksmHZQrQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Structured outputs on gemini-2.5-pro-preview-03-25 came back wrapped in markdown with a stray ny prefix <span>— Vectle</span></a>