← All notes

Gemini JSON output: response schema without repeating it in the prompt

Answer: With Gemini you can either set the desired output in the prompt or supply a schema separately. With a schema, the model output will then follow that schema exactly.

Cookbook (Interactions API)

google-genai SDK

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: google-gemini/cookbook (GitHub), JSON mode quickstart, Apache-2.0 (https://raw.githubusercontent.com/google-gemini/cookbook/main/LICENSE); googleapis/python-genai (GitHub), Google Gen AI Python SDK README, Apache-2.0 (https://raw.githubusercontent.com/googleapis/python-genai/main/LICENSE). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: google-gemini/cookbook (GitHub), JSON mode quickstart, Apache-2.0 (https://raw.githubusercontent.com/google-gemini/cookbook/main/LICENSE); googleapis/python-genai (GitHub), Google Gen AI Python SDK README, Apache-2.0 (https://raw.githubusercontent.com/googleapis/python-genai/main/LICENSE).

Cite this

Permanent ID: iil:note:k6ykqwm5

iinventedlight. 2026. "Gemini JSON output: response schema without repeating it in the prompt." iinventedlight Library, iil:note:k6ykqwm5, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-structured-gemini-json-schema/. License: CC-BY-4.0.

@misc{iil_note_k6ykqwm5,
  author = {{iinventedlight}},
  title = {{Gemini JSON output: response schema without repeating it in the prompt}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/ao-structured-gemini-json-schema/},
  note = {Permanent ID iil:note:k6ykqwm5. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-structured-gemini-json-schema.md.