Skip to content

Provider gemini does not pass custom headers to gemini API #12008

@siom79

Description

@siom79

Before submitting your bug report

Relevant environment info

- OS: macOS
- Continue version: > 1.2.11
- IDE version: VSCode 1.114
- Model: gemini
- config:
  
name: Gemini
version: 1.0.0
models: 
  - name: Gemini Flash
    provider: gemini
    model: gemini-2.5-flash
    apiBase: https://example.com/v1/streaming-models/locations/europe-west4/publishers/google # region can be adjusted (all european regions are possible)
    apiKey: <api-key>
    requestOptions:
      headers:
        x-api-key: <api-key>
        Content-Type: application/json
      verifySsl: true
      caBundlePath: "ca-bundle.crt"
    roles:
      - apply
      - chat
      - edit
    defaultCompletionOptions: # optional
      contextLength: 1048576
      maxTokens: 65536

Description

The API we are using still uses the API-Header x-api-key instead of x-goog-api-key. But configuring the header as shown above does not send it to the gemini API.
It seems that the code in the gemini-Extension here sends two hard-coded headers but not custom ones.
Can you please extend the code such that it also sends custom header configured in config.yaml?
Thanks in advance.

To reproduce

  1. Use the above configuration with a valide API key
  2. Try to chat with gemini
    You will get the following error message:
{"error":{"message":"{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"API key not valid. Please pass a valid API key.\",\n    \"status\": \"INVALID_ARGUMENT\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.ErrorInfo\",\n        \"reason\": \"API_KEY_INVALID\",\n        \"domain\": \"googleapis.com\",\n        \"metadata\": {\n          \"service\": \"generativelanguage.googleapis.com\"\n        }\n      },\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.LocalizedMessage\",\n        \"locale\": \"en-US\",\n        \"message\": \"API key not valid. Please pass a valid API key.\"\n      }\n    ]\n  }\n}\n","code":400,"status":"Bad Request"}}

Log output

{"error":{"message":"{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"API key not valid. Please pass a valid API key.\",\n    \"status\": \"INVALID_ARGUMENT\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.ErrorInfo\",\n        \"reason\": \"API_KEY_INVALID\",\n        \"domain\": \"googleapis.com\",\n        \"metadata\": {\n          \"service\": \"generativelanguage.googleapis.com\"\n        }\n      },\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.LocalizedMessage\",\n        \"locale\": \"en-US\",\n        \"message\": \"API key not valid. Please pass a valid API key.\"\n      }\n    ]\n  }\n}\n","code":400,"status":"Bad Request"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:integrationIntegrations (context providers, model providers, etc.)kind:bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions