Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when sending an image to Gemini #990

Open
1 task done
HamzaFarhan opened this issue Feb 25, 2025 · 0 comments
Open
1 task done

Error when sending an image to Gemini #990

HamzaFarhan opened this issue Feb 25, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@HamzaFarhan
Copy link

Initial Checks

  • I confirm that I'm using the latest version of Pydantic AI

Description

Getting this error with Gemini but not with GPT

Example Code

from pydantic_ai import Agent, ImageUrl

agent = Agent(model="google-gla:gemini-2.0-flash-exp")
result = await agent.run(["What company is this logo from?", ImageUrl(url="https://goo.gle/instrument-img")])

"""
UnexpectedModelBehavior: Unexpected response from gemini 400, body:
{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"data\" at 'contents[0].parts[1]': Cannot find field.\nInvalid JSON payload received. Unknown name \"mimeType\" at 'contents[0].parts[1]': Cannot find field.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "contents[0].parts[1]",
            "description": "Invalid JSON payload received. Unknown name \"data\" at 'contents[0].parts[1]': Cannot find field."
          },
          {
            "field": "contents[0].parts[1]",
            "description": "Invalid JSON payload received. Unknown name \"mimeType\" at 'contents[0].parts[1]': Cannot find field."
          }
        ]
      }
    ]
  }
}
"""

Python, Pydantic AI & LLM client version

Python 3.12.7
Pydantic AI 0.0.26
@Kludex Kludex added bug Something isn't working and removed need confirmation labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants