Skip to content

Failed Google/Gemini API requests show the API key in the output #3191

@SalvatoreT

Description

@SalvatoreT

Describe the bug

When you get an HTTP error for calling the Google AI endpoint, you get the following error.

Ran into this error: Request failed: Request failed: error sending request for url (https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro-preview-06-05:generateContent?key=abc123def

Please retry if you think this is a transient or recoverable error.

This is bad because we're showing the API key in plain text.

To Reproduce
Steps to reproduce the behavior:

  1. Start a Goose session with Google AI
  2. Make a request
  3. Quickly turn off your internet access
  4. See error

Expected behavior
I don't want to see the API key in the output.

Screenshots
Image

Please provide following information:

  • OS & Arch: macOS, ARM
  • Interface: UI
  • Version: v1.0.31
  • Provider & Model: Google - gemini-2.5-pro-preview-06-05

Additional context
It's buried in their other documentation, but you can use an HTTP header instead of including the API key in the query parameters.

To include an API key with a REST API call, use the x-goog-api-key HTTP header, as shown in the following example

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