Skip to content

[Bug]: Add support for skipping role validation in gemini #997

@maxidelo

Description

@maxidelo

Prerequisites

  • I have searched existing issues and discussions to avoid duplicates
  • I am using the latest version (or have tested against main/nightly)

Description

I'm using https://koog.ai/ with Gemini and noticed that when doing system prompts, koog is not sending the role, which is a valid payload for Gemini and it works fine. But when I set it up with Bifrost I receive an error {"error":{"code":400,"message":"Request contains an invalid argument.\n","status":""}}.

Steps to reproduce

To prove this, I did the same request directly to gemini and then using Bifrost and these are the results.

Gemini

With role: "user"

This works fine

curl -s --request POST \
  --url 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-lite:generateContent' \
  --header 'Content-Type: application/json' \
  --header 'x-goog-api-key: <api-key>' \
  --data '{
    "contents": [{
      "role": "user",
      "parts": [{"text": "Hello, how are you?"}]
    }]
  }'

Without role

This works fine too

curl -s --request POST \
  --url 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-lite:generateContent' \
  --header 'Content-Type: application/json' \
  --header 'x-goog-api-key: <api-key>' \
  --data '{
    "contents": [{
      "parts": [{"text": "Hello, how are you?"}]
    }]
  }'

Bifrost (using Gemini too)

With role: "user"

This works fine

curl -s --request POST \
  --url 'http://localhost:8080/genai/v1beta/models/gemini-2.5-flash-lite:generateContent' \
  --header 'Content-Type: application/json' \
  --header 'x-goog-api-key: <vk>' \
  --data '{
    "contents": [{
      "role": "user",
      "parts": [{"text": "Hello, how are you?"}]
    }]
  }'

Without role

This throws {"error":{"code":400,"message":"Request contains an invalid argument.\n","status":""}}%

curl -s --request POST \
  --url 'http://localhost:8080/genai/v1beta/models/gemini-2.5-flash-lite:generateContent' \
  --header 'Content-Type: application/json' \
  --header 'x-goog-api-key: <vk>' \
  --data '{
    "contents": [{
      "parts": [{"text": "Hello, how are you?"}]
    }]
  }'

Expected behavior

I expect Bifrost to just proxy the request and work same as Gemini does

Actual behavior

Bifrost is failing and changing the expected behaviour

Affected area(s)

Transports (HTTP)

Version

v1.3.38

Environment


Relevant logs/output

Regression?

No response

Severity

Low (minor issue or cosmetic)

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions