continuedev / continuedev/continue

Provider gemini does not pass custom headers to gemini API

Open Beginner friendly
#12,008 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:integration kind:bug stale
Dominant language
TypeScript
Stars
36k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

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"}}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/openai-adapters/src/apis/Gemini.ts around line 487, where the Gemini provider constructs its request headers. Reproduce the issue with the provided config.yaml requestOptions.headers configuration and inspect the outgoing request. Done means configured custom headers, including x-api-key, are sent to the Gemini API while the existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.