Skip to content

Error when using anthropic-proxy with Google models #1

@rogerheykoop

Description

@rogerheykoop

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:

  1. Function declaration #14's parameters.properties is empty when it should be non-empty for OBJECT type
  2. Function declaration #42's parameters.properties is empty when it should be non-empty for OBJECT type
  3. 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

  1. 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)
  2. Send a request that includes function calls
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions