Using the API, sending a query with an application/json mime type is inserting “```json” and “```” at the beginning and end. Bizarrely, it also often starts with the text shame or shamefully before outputting the json. Just manually sanitizing for now, but given that the API worked fine for every prompt before today I suspect there’s some kind of weird bug here
edit: I also just got shamefully-self-plagiarized at the start of the json lol the word plagiarize appeared nowhere in the data
I also ran into this weird issue when trying to upload a pdf and return structured output.
I suppose shame, shamefully, and shamefully-self-plagiarized are tokenised next to each other in the vectorspace. This is a weird issue and I suppose it’s a bug at Google.
I reported this as well 10 days ago or so. No resolution yet.
It affects also 2.0 Flash. It started in the last 2-3 weeks and there is no prompt that can overrule it.
It makes the model unusable even if it’s otherwise great.
Same prompt is working fine in AI studio, so it’s something happening only with the APIs.
Please fix it - thanks!
@Sangeetha_Jana, this requires more attention. After setting a response mime type and providing a response schema, I’m getting responses as (see excerpt):
It is also happening for me when querying structured outputs via the official NodeJS SDK.
I am using the model: gemini-2.0-pro-exp-02-05.
There are random occurencies, when the “shame” string is prepended to the response text, followed by a valid JSON response. I could not find any correlation between input/output, when these “shame” strings occur.
We’re also seeing the “ny\n” issue and a ton more other invalid JSON responses. We’re even seeing other random tokens interleaved with the json response that are not related to our request at all. This just started happening to us a day or two ago. Before that, gemini 2.0 pro exp and gemini 2.5 pro felt really stable. Seems to be there is a very serious bug Gemini introduced that I hope they’re all hands on deck trying to fix right now.
My usage has always had that, I think even 2.0 flash does it. I gave up and made a function to strip it out if present. (Not sure on my MIME type)
Insight into how to resolve would be appreciated.
Same issue. Getting ‘ny\n’ in front of the json file. I am working with openai compatible mode and it just cause my code to crash and leave me no choice but to switch back to 2.0 flash.