How to properly use the JSON PARSER tool?

I would like to make the JSON output of my LLM nodes more reliable by using the JSON PARSER tool.

The problem is that it’s called too often by the AI AGENT node, and this causes disconnections from the GEMINI API due to too many requests.

I’m using 2.5 Flash for writing and 2.5 Flash as the fallback model for the Parser as well.

Do you think I should use another API for the Parser, like Mistral / GPT / Claude for example? I’m not sure that’s really the problem because I don’t see any fallback model calls in the execution, just back-and-forth exchanges between the chat model and the output parser…

Any advice?

Hello!

Could you share your workflow so that we can take a look at the problem?
If your issue is with rate limits, I can recommend either using the Loop Node with a Wait node or setting the try again after failing setting with a 2000ms delay between tries.
You got this man!

Cheers :slight_smile:

@Bentl The root cause is the interaction pattern between your LLM and parser. To fix this you have a few options

  1. Add a simple JavaScript function node to clean the output before parsing it. This can remove markdown code blocks, fix trailing commas, and trim the output.
  2. Instead of using another AI model for parsing, use structured output with your main call. This can produce better JSON output and reduce errors.
  3. If you still want a separate parser, consider using Mistral, which is cheaper and faster for parsing.
  4. Add error handling with a function node that tries to parse the JSON output natively. If it fails, you can then use an AI parser.

The recommended architecture is to use a function node to clean the JSON output, followed by a try catch block to attempt native JSON parsing. If that fails, you can then use an AI parser.

Good luck bud

I already figured it out thanks once again for your replies I really appreciate them.

You are welcome friend, kindly mark as solution to help others. Good luck