red-accountant-48215
08/28/2025, 10:29 AMlivekit.agents._exceptions.APIStatusError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'tools.2.custom.input_schema.type: Field required'}, 'request_id': 'req_011CSZwaBHxxBWN94yeDMv68'} (status_code=400, request_id=req_011CSZwaBHxxBWN94yeDMv68, body={'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'tools.2.custom.input_schema.type: Field required'}, 'request_id': 'req_011CSZwaBHxxBWN94yeDMv68'}, retryable=False)tall-airline-16756
08/28/2025, 10:29 AMtall-airline-16756
08/28/2025, 10:30 AMraw_schema is the JSON schema you define when registering raw function tools using @llm.raw_function_tool. Your inputs need to match this schema to work smoothly.
2. Handle Validation Errors:
• When you catch an APIStatusError, take a close look at the response body for details about what went wrong. Here’s a quick example:
from livekit.agents import APIStatusError
try:
result = await agent.execute(input_data)
except APIStatusError as e:
if e.status_code == 400 and e.body:
error_data = e.body
if error_data.get('type') == 'invalid_request_error':
print(f"Schema validation failed: {error_data.get('message')}")
3. Validate Inputs Before Sending:
• It’s a great idea to check your inputs against the schema before making API calls. You can use libraries like jsonschema for this. Here’s how:
from jsonschema import validate, ValidationError
schema = {
"type": "object",
"properties": {"location": {"type": "string"}},
"required": ["location"]
}
try:
validate(input_data, schema)
except ValidationError as ve:
print("Invalid input:", ve)
4. Best Practices:
• Keep an eye on error logs to pinpoint exactly which validation rule caused trouble.
• Make sure your raw_schema has clear field names and validation rules to avoid confusion.
Since LiveKit doesn’t have built-in tools for pre-validating inputs against raw_schema, adding your own validation and error handling steps can really save you headaches. If you want, I’m here to help you set up a pre-validation layer—just let me know! Sources: tools/server/server.cpp | livekit-plugins/livekit-plugins-tavus/livekit/plugins/tavus/api.py