Input and output schemas for model versions
Dec 22, 2024
2 minute read
Model versions now define their input and output schemas. Each version includes a schemas object that describes exactly what the model expects as input and what it returns as output, following the JSON Schema Draft 2020-12 standard.
The problem
Until now, figuring out what to pass to a model meant reading its external documentation, looking at examples, or trial and error. There was no machine-readable contract between you and the model. If you passed the wrong input, you'd only find out after the prediction was already running on hardware — wasting time and compute.
What changed
Every model version now carries its own prediction schemas. The schemas.prediction.input object describes the shape of the input the model accepts, and schemas.prediction.output describes the structure of what it returns.
1{2 "number": 4,3 "release_notes": "Added support for negative prompts",4 "schemas": {5 "prediction": {6 "input": {7 "type": "object",8 "properties": {9 "prompt": {10 "type": "string",11 "description": "Text prompt for image generation"12 },13 "width": {14 "type": "integer",15 "default": 102416 },17 "height": {18 "type": "integer",19 "default": 102420 },21 "negative_prompt": {22 "type": "string",23 "description": "What to exclude from the generated image"24 }25 },26 "required": ["prompt"]27 },28 "output": {29 "type": "string",30 "format": "uri",31 "description": "URL of the generated image"32 }33 }34 },35 ...36}
What you can do with this
Since the schemas follow JSON Schema, you can use them to validate inputs client-side before making a prediction request, generate typed interfaces in your language of choice, or build dynamic UIs that render form fields based on a model's input schema.
Schemas are available through the get model version endpoint and on the latest_version field when fetching a model's details. See the API reference for the full schema structure.