JSON Mode - Internal Server Error 500

When using JSON schema mode and the schema object is particularly big an Internal Server Error message is returned. This happens using the API and the AI Studio Playground. I have tested against all models and they all fail apart from gemini-1.5-flash-8b-exp-0827. To test you can use the following schema and the prompt ‘generate values’. The schema fails, however if you remove item_9 then the schema works as intended. This is just a sample schema but it also fails using schema generated in my production app:

{
    "type": "object",
    "properties": {
        "items": {
            "type": "object",
            "properties": {
                "item_1": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                },
                "item_2": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                },
                "item_3": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                },
                "item_4": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                },
                "item_5": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                }, "item_6": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                },
                "item_7": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                },
                "item_8": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                },
                "item_9": {
                    "type": "object",
                    "properties": {
                        "item_A": {
                            "type": "number",
                            "description": "A number for item_A"
                        },
                        "item_B": {
                            "type": "number",
                            "description": "A number for item_B"
                        },
                        "item_C": {
                            "type": "number",
                            "description": "A number for item_C"
                        },
                        "item_D": {
                            "type": "number",
                            "description": "A number for item_D"
                        },
                        "item_E": {
                            "type": "number",
                            "description": "A number for item_E"
                        },
                        "item_F": {
                            "type": "number",
                            "description": "A number for item_F"
                        },
                        "item_G": {
                            "type": "number",
                            "description": "A number for item_G"
                        },
                        "item_H": {
                            "type": "number",
                            "description": "A number for item_H"
                        },
                        "item_I": {
                            "type": "number",
                            "description": "A number for item_I"
                        },
                        "item_J": {
                            "type": "number",
                            "description": "A number for item_J"
                        }
                    }
                }
            },
            "required": [
                "item_1",
                "item_2",
                "item_3"
            ]
        },
        "costs_1": {
            "type": "array",
            "description": "Array of costs",
            "items": {
                "type": "object",
                "properties": {
                    "description": {
                        "type": "string"
                    },
                    "cost": {
                        "type": "number",
                        "description": "A cost value"
                    }
                },
                "required": [
                    "description",
                    "cost"
                ]
            }
        },
        "costs_2": {
            "type": "array",
            "description": "Array of costs",
            "items": {
                "type": "object",
                "properties": {
                    "description": {
                        "type": "string"
                    },
                    "cost": {
                        "type": "number",
                        "description": "A cost value"
                    }
                },
                "required": [
                    "description",
                    "cost"
                ]
            }
        }
    },
    "required": [
        "items",
        "costs_1",
        "costs_2"
    ]
}
1 Like