High severity intermediate · Fix: 5-10 min

ValueError

azure.openai._function_calling.FunctionCallingSchemaError

What this error means
Azure OpenAI rejects the function calling request because the provided function schema is invalid or malformed.

Stack trace

traceback
ValueError: Function calling schema is invalid: 'parameters' field must be a valid JSON Schema object
  File "/usr/local/lib/python3.9/site-packages/azure/ai/openai/_function_calling.py", line 123, in _validate_function_schema
    raise FunctionCallingSchemaError("Function calling schema is invalid: 'parameters' field must be a valid JSON Schema object")
QUICK FIX
Pass a valid Python dict with a correct 'parameters' JSON Schema object to the function calling parameter to fix the schema error immediately.

Why it happens

Azure OpenAI requires the function calling schema to strictly follow JSON Schema standards. If the 'parameters' field or other parts of the schema are missing, malformed, or not valid JSON Schema objects, the SDK raises this error to prevent sending invalid requests to the API.

Detection

Validate your function schema JSON against the official JSON Schema specification before passing it to the Azure OpenAI client. Log schema validation errors or catch ValueError exceptions during client calls.

Causes & fixes

1

The 'parameters' field in the function schema is missing or not a valid JSON Schema object.

✓ Fix

Ensure the 'parameters' field is a properly formatted JSON Schema object with correct types and required fields as per Azure OpenAI documentation.

2

The function schema contains unsupported or incorrectly typed fields not allowed by Azure OpenAI.

✓ Fix

Remove unsupported fields and verify all fields conform exactly to the JSON Schema draft supported by Azure OpenAI.

3

Passing the function schema as a string instead of a Python dictionary.

✓ Fix

Pass the function schema as a Python dict object, not as a JSON string, so the SDK can validate and serialize it correctly.

Code: broken vs fixed

Broken - triggers the error
python
import os
from azure.ai.openai import OpenAIClient

client = OpenAIClient(os.environ["AZURE_OPENAI_API_KEY"])

functions = [
    {
        "name": "get_weather",
        "description": "Get the weather forecast",
        "parameters": "{\"type\": \"object\", \"properties\": {\"location\": {\"type\": \"string\"}}}"  # Incorrect: parameters as string
    }
]

response = client.chat.completions.create(
    engine="gpt-4o",
    messages=[{"role": "user", "content": "What's the weather in Seattle?"}],
    functions=functions  # This line triggers the ValueError
)
Fixed - works correctly
python
import os
from azure.ai.openai import OpenAIClient

client = OpenAIClient(os.environ["AZURE_OPENAI_API_KEY"])

functions = [
    {
        "name": "get_weather",
        "description": "Get the weather forecast",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string"}
            },
            "required": ["location"]
        }  # Fixed: parameters as dict with valid JSON Schema
    }
]

response = client.chat.completions.create(
    engine="gpt-4o",
    messages=[{"role": "user", "content": "What's the weather in Seattle?"}],
    functions=functions  # Fixed: valid schema passed
)
print(response.choices[0].message.content)
Changed 'parameters' from a JSON string to a Python dict with a valid JSON Schema object, allowing Azure OpenAI SDK to validate and accept the function schema.

Workaround

Catch the ValueError when creating the chat completion, then manually validate and fix the function schema JSON before retrying the request.

Prevention

Always define function calling schemas as Python dictionaries conforming strictly to JSON Schema standards and validate them with a JSON Schema validator before passing to Azure OpenAI.

Python 3.9+ · azure-ai-openai >=1.0.0 · tested on 1.0.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.