Skip to content

400 Invalid JSON payload while sending an image message to Google Gemini 1.5 model #103

@nimish-gupta

Description

@nimish-gupta

Description

We encountered an issue when sending an image as part of a message to the Google Gemini 1.5 Flash model using the Braintrust Proxy. The request fails with the following error:

400 Invalid JSON payload received. 
Unknown name "text" at 'contents[1].parts[0]': Proto field is not repeating, cannot start list.

Steps to Reproduce:

  1. Set up the Braintrust Proxy with Google Gemini 1.5 Flash API using the following code snippet:
const client = new OpenAI({
  baseURL: "https://api.braintrust.dev/v1/proxy",
  apiKey: process.env.BRAINTRUST_API_KEY,
});

const response = await client.chat.completions.create({
  model: "gemini-1.5-flash-latest",
  messages: [
    { role: "user", content: "What do you think of this image?" },
    { role: "user", content: [{ type: "image_url", image_url: { url: "https://example.com/image.jpg" } }] }
  ],
});
console.log(response);

  1. The request fails with the 400 error mentioned above.

Expected Behaviour:

  1. The message containing the image should be processed successfully by the Gemini 1.5 Flash model via the Braintrust Proxy.
  2. The API should return a valid response describing the image or engaging with the user prompt accordingly.

Impact:

  1. This issue blocks us from sending media (specifically images) along with text messages to the Gemini 1.5 model.
  2. It is affecting the functionality needed for applications involving image and text-based conversation flows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions