Consider using structured output. You can define a JSON with specific fields, and LLMs are only used to fill in the values.
https://ai.google.dev/gemini-api/docs/structured-output