Google Gemini responseSchema 400 fixer
Resolve 400 INVALID_ARGUMENT failures by inlining non-cyclic $ref definitions, converting type arrays to nullable: true, and stripping unsupported string formats.
- Error $ GEMINI_REF_INLINED
Gemini legacy responseSchema rejects $ref / $defs (HTTP 400 INVALID_ARGUMENT).
Auto-fix: Resolved and inlined 1 non-cyclic $ref reference.
- Warn $.subject GEMINI_STRIP_MINLENGTH
Gemini legacy responseSchema does not support "minLength".
Auto-fix: Removed "minLength" and appended (minLength: 5) to description.
- Warn $.subject GEMINI_STRIP_MAXLENGTH
Gemini legacy responseSchema does not support "maxLength".
Auto-fix: Removed "maxLength" and appended (maxLength: 120) to description.
- Error $.priority GEMINI_EMPTY_ENUM_VALUE
Gemini rejects empty string ("") inside enum lists with 400 INVALID_ARGUMENT.
Auto-fix: Removed empty string "" from enum.
- Error $.contact.email GEMINI_UNSUPPORTED_FORMAT
Gemini legacy responseSchema only allows string formats "enum" and "date-time" (got "email").
Auto-fix: Stripped format "email" and preserved hint in description.
- Warn $.contact.locale GEMINI_STRIP_MINLENGTH
Gemini legacy responseSchema does not support "minLength".
Auto-fix: Removed "minLength" and appended (minLength: 2) to description.
- Warn $.contact.locale GEMINI_STRIP_MAXLENGTH
Gemini legacy responseSchema does not support "maxLength".
Auto-fix: Removed "maxLength" and appended (maxLength: 5) to description.
- Warn $.tags GEMINI_STRIP_UNIQUEITEMS
Gemini legacy responseSchema does not support "uniqueItems".
Auto-fix: Removed "uniqueItems" and appended (uniqueItems: true) to description.
- Warn $.notes GEMINI_STRIP_DEFAULT
Gemini legacy responseSchema rejects "default".
Auto-fix: Removed "default".
- Error $.notes GEMINI_TYPE_ARRAY_TO_NULLABLE
Gemini legacy responseSchema rejects JSON Schema type arrays (["string","null"]).
Auto-fix: Converted to type: "string", nullable: true.
{
"generationConfig": {
"responseMimeType": "application/json",
"responseSchema": {
"title": "CreateSupportTicket",
"description": "File a customer support ticket with optional billing context.",
"type": "object",
"properties": {
"subject": {
"type": "string",
"description": "(minLength: 5) (maxLength: 120)"
},
"priority": {
"type": "string",
"enum": [
"low",
"normal",
"urgent"
]
},
"contact": {
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "(format: email)"
},
"locale": {
"type": "string",
"description": "(minLength: 2) (maxLength: 5)"
}
},
"required": [
"email"
]
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "(uniqueItems: true)"
},
"notes": {
"type": "string",
"nullable": true
}
},
"required": [
"subject",
"contact"
]
}
}
} Gemini responseSchema vs responseJsonSchema
Gemini supports two structured output fields: the legacy OpenAPI 3.0 subset (responseSchema) and the modern JSON Schema field (responseJsonSchema). Never send both in the same request.
| Keyword / feature | responseSchema (Legacy OpenAPI 3.0) | responseJsonSchema (Modern) |
|---|---|---|
$defs and $ref | Rejected with 400. SchemaGate inlines acyclic refs and blocks cycles with exact cycle path. | Supported, including recursive schemas when nullable. |
additionalProperties | Rejected with 400. Stripped automatically. | Accepted. |
| Nullable types | Requires nullable: true; rejects type: ["string", "null"]. | Accepts JSON Schema type arrays and anyOf. |
String format | Only enum and date-time allowed; others like email or uuid return 400. | Accepted (some formats advisory only). |
Empty "" in enum | Rejected with 400. Stripped with error diagnostic. | Avoid empty enum values across providers. |