Gemini and OpenAI json is not correct

Hello,I have asked OpenAI and Gemini to give the following output after analysis the image:Output Instructions:

Return ONLY valid JSON with the following structure:

{“image_analysis”: “string, short description of what’s visually notable in the images (colors, textures, shapes, mood, design style)”,“seo_title”: “string, Etsy-optimized title (max 140 chars)”,“short_description”: “string, 1–2 sentences, engaging with CTA”,“long_description”: “string, 3–4 paragraphs for Etsy/Facebook”,“etsy_tags”: [“string”, “string”, “… up to 13 tags, max 20 chars each”],“instagram_hashtags”: [“string”, “string”, “… up to 20 hashtags”],“filenames”: [“string”, “string”, “… 5 SEO-friendly filenames based on product + image features”]}

However, the output I am getting in not the same, I am getting:
[

{

“content”: {

“parts”: [

{

“text”: "```json\n{\n \“image_analysis\”: \"The images display a hand-painted wooden cart holding several decorated shot glasses. The design features a vibrant folk art style with a dominant color palette of red, yellow, and black, accented with blue, white, and pink. The motifs include intricate swirls, dots, and floral-like patterns, indicating a traditional, artisanal craftsmanship. The overall mood is festive, colorful, and cele…..

Any idea how to fix this?

1 Like

Hello! In which field of the node are you entering these instructions?

I used Gemini in a recent stream and passed the parameters as shown in the image. Then I created a code node with the following structure. With that, I got the text I needed.

Code node:

const input = $input.first().json.content.parts[1].text;
const clean = input.replace(/json|/g, “”).trim();
return JSON.parse(clean);

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.