continuedev / continuedev/continue
Provider gemini does not pass custom headers to gemini API
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 36k
- Forks
- 5.4k
- PR merge metrics
- No merged PRs in 30d
Description
Before submitting your bug report
- I've tried using the "Ask AI" feature on the Continue docs site to see if the docs have an answer
- I'm not able to find a related conversation on GitHub discussions that reports the same bug
- I'm not able to find an open issue that reports the same bug
- I've seen the troubleshooting guide on the Continue Docs
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
- Use the above configuration with a valide API key
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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