{} LLM JSON Schema View source ↗

Gemini · responseSchema

400 INVALID_ARGUMENT: Unknown name "$ref" at 'generation_config.response_schema': Cannot find field.

Gemini's responseSchema is a subset of JSON Schema

Gemini rejects a schema with Unknown name when it contains a keyword outside its supported subset — most often $ref, but also pattern, minLength, and others. The fix is to inline and strip what Gemini doesn't understand.

What the error means

Unlike OpenAI (which validates a strict superset) or Anthropic (which takes ordinary JSON Schema), Gemini's responseSchema accepts only a defined subset of fields. Any keyword outside that subset isn't ignored — it's a hard 400 INVALID_ARGUMENT. The usual culprits:

# commonly unsupported in responseSchema $ref, $defs → definitions/references must be inlined pattern → regex constraints are dropped minLength, maxLength format (except date-time, date, time, and enum/duration variants) additionalProperties on the object

The fix

Inline any $ref so the referenced definition is written out in place, and remove the keywords Gemini can't parse. Keep the structural fields it does support — type, properties, items, required, enum, nullable, and propertyOrdering.

# before — rejected { "type": "object", "properties": { "id": { "$ref": "#/$defs/Id" }, "code": { "type": "string", "pattern": "^[A-Z]{3}$" } } } # after — $ref inlined, pattern stripped, ordering added { "type": "object", "properties": { "id": { "type": "string" }, "code": { "type": "string" } }, "propertyOrdering": ["id", "code"] }

Bonus: stable field order

Gemini decides output field order from propertyOrdering. Without it, order is unpredictable and can hurt output quality — so the converter adds it to every object automatically.

Fix it automatically

Paste your schema, pick Gemini, and the converter inlines $ref, drops unsupported keywords, and adds propertyOrdering — listing each change with the doc rule behind it. Runs entirely in your browser.

Open the converter →
Gemini structured output docs ↗