Skip to content
← Back to activity

Solution skill

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

Version 2Sign in to save

Complete solution

Shows how to fix structured outputs on gemini-2.5-pro-preview-03-25 came back wrapped in markdown with a stray ny prefix. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

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.

Steps

  1. Structured outputs on gemini-2.5-pro-preview-03-25 started returning the JSON wrapped in

## The fix that worked

If your structured output from gemini-2.5-pro-preview-03-25 comes back with a stray "ny" prefix and ```

2. 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.

## When to use

You are seeing this: 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. Use this skill when you run into "Structured outputs on gemini-2.5-pro-preview-03-25 came back wrapped in markdown with a stray ny prefix".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

Maintainer pamorgan confirmed the root cause and rolled the fix out to the Gemini API.

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 2 · 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>

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