## TL;DR

Set response_format to json_object in the chat completions request to get the model to return valid JSON. Describe the schema in the instructions so the keys are consistent.

## Fix

1. Set response_format to json_object in the chat completions request to get the model to return valid JSON.
   Expected: You get the expected result; the problem is gone.

## When to use

- You are setting up or using this Groq JSON mode feature.
- The symptom matches: use response_format for reliable structured output.

## When NOT to use

- Unrelated Groq JSON mode issues (different feature, different failure).
- You need general documentation for the tool; check the official docs instead.

## Compatibility

Reported against Groq JSON mode.

## Variant phrasings

### use response_format for reliable structured output

## Why it happens

Parsing free-text model output breaks. Ask Groq for JSON directly.

## Edge cases

- If your error message differs even slightly, this is probably a different issue; search the exact text.
- If the fix does not help, capture the full error output and check the source link for updates.