Problem
When defining a function tool with an array parameter that uses prefixItems (valid JSON Schema 2020-12 syntax), the OpenAI API rejects the request with a 400 Bad Request error.
Example request (shortened for clarity):
{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "Hello, what’s the weather in Shanghai today?" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "Date, format YYYY-MM-DD"
},
"coords": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"prefixItems": [
{ "type": "number" },
{ "type": "number" }
],
"description": "Coordinates (lat, lon). Example: [31.14, 121.29]"
}
},
"required": ["date", "coords"]
}
}
}
]
}
Error Response
400 Bad Request
{
"error": {
"message": "Invalid schema for function 'get_weather': In context=('properties', 'coords'), array schema missing items.",
"type": "invalid_request_error",
"param": "tools[0].function.parameters",
"code": "invalid_function_parameters"
}
}
Expected Behavior
According to the official API documentation:
-
parametersshould accept a valid JSON Schema object. -
JSON Schema 2020-12 allows
prefixItemsfor tuple validation (fixed-length arrays). -
The schema above is valid JSON Schema.
Therefore, the API should accept this request instead of rejecting it.
Actual Behavior
-
The API rejects schemas using
prefixItems(tuple form). -
The error suggests the API only accepts the older
itemskeyword for arrays. -
This means the implementation does not fully align with the documented claim of “accepting JSON Schema.”
Notes
-
Omitting
prefixItemsand usingitems: { "type": "number" }works, but it loses tuple validation (e.g., enforcing exactly two numbers). -
The issue appears across all current models (
gpt-4o,gpt-4.1, etc.).
Request
Please confirm:
-
Is this a bug (API not supporting modern JSON Schema features like
prefixItems)? -
Or is the documentation incorrect (only older JSON Schema draft supported)?
Either the docs or the implementation should be updated for consistency.