-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Error when using anthropic-proxy with Google models
Summary
When attempting to use the anthropic-proxy service with Openrouter Google models, the request fails with a 400 error indicating invalid function declarations in the request body.
Error Details
OpenAI response chunk: data: {"error":{"message":"Provider returned error","code":400,"metadata":{"raw":"{\n "error": {\n "code": 400,\n "message": "* GenerateContentRequest.tools[0].function_declarations[14].parameters.properties: should be non-empty for OBJECT type\n* GenerateContentRequest.tools[0].function_declarations[42].parameters.properties: should be non-empty for OBJECT type\n* GenerateContentRequest.tools[0].function_declarations[56].parameters.properties: should be non-empty for OBJECT type\n",\n "status": "INVALID_ARGUMENT"\n }\n}\n","provider_name":"Google AI Studio"}},"user_id":"user_****************"}
Analysis
The error message indicates three specific issues with function declarations in the request payload:
- Function declaration #14's parameters.properties is empty when it should be non-empty for OBJECT type
- Function declaration #42's parameters.properties is empty when it should be non-empty for OBJECT type
- Function declaration #56's parameters.properties is empty when it should be non-empty for OBJECT type
This suggests that the anthropic-proxy service is not correctly formatting function declarations when translating between Anthropic's API format and Openrouter/Google AI Studio's expected format.
The error occurs in anthropic-proxy/index.js, line 318
Reproduction Steps
- Configure anthropic-proxy to use a Openrouter Google model (I have tried with google/gemini-2.5-pro-exp-03-25:free and the default model)
- Send a request that includes function calls
- Observe the 400 error response
Potential Fix
The issue appears to be in the function declaration transformation logic. The proxy needs to ensure that all OBJECT type parameters have non-empty properties objects, even if there are no actual properties to specify. Empty objects are not valid according to Google AI Studio's API requirements.