continue icon indicating copy to clipboard operation
continue copied to clipboard

400 Error with Gemini 3 Pro *via OpenRouter* when calling tools

Open m13253 opened this issue 1 year ago • 9 comments

Before submitting your bug report

Relevant environment info

- OS: macOS 26.1
- Continue version: 1.3.24 (pre-release)
- IDE version: VSCode 1.106.3
- Model: google/gemini-3-pro-preview **via OpenRouter** (important)
- config:
name: Local Config
version: 1.0.0
schema: v1
models:
  - name: Gemini 3 Pro Preview
    model: google/gemini-3-pro-preview
    apiKey: ${{ secrets.OPENROUTER_API_KEY }}
    roles:
      - chat
      - edit
    capabilities:
      - tool_use
      - image_input
    defaultCompletionOptions:
      contextLength: 1048576
    provider: openrouter

Description

Related (but not identical) issues: #8785

I read the patch in #8865 which fixes the thought_signature issue for Gemini 3 Pro, but it seems to only apply to direct connections to Gemini API.

Users who connect to Gemini via OpenRouter, which uses OpenAI-compatible API, seem not covered by that fix.

To reproduce

  1. Get an OpenRouter API key. (Contact me if you are unable to.)
  2. Open the Continue chat in VSCode.
  3. Type a prompt that involves a tool call. (e.g., “List the files in this directory.”)
Screenshot

Log output

DevTools log:

[Extension Host] [@continuedev] error: 400 Provider returned error {"context":"llm_stream_chat","model":"google/gemini-3-pro-preview","provider":"openrouter","useOpenAIAdapter":true,"streamEnabled":true,"templateMessages":false}

[Extension Host] Error: 400 Provider returned error
	at APIError.generate (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:151942:18)
	at OpenAI.makeStatusError (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:158839:25)
	at OpenAI.makeRequest (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:158997:29)
	at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
	at async OpenRouterApi.chatCompletionStream (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:159893:26)
	at async OpenRouter.openAIAdapterStream (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:245129:26)
	at async OpenRouter.streamChat (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:245250:32)
	at async llmStreamChat (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:724132:19)
	at async Wd.handleMessage [as value] (/Users/brilliant/.vscode/extensions/continue.continue-1.3.24-darwin-arm64/out/extension.js:762419:29)

Continue Console:

Request 1

Type: Chat
Result: Success
Prompt Tokens: 149
Generated Tokens: 10
ThinkingTokens: 60
Total Time: 3.04s
To First Token: 3.02s
Tokens/s: 3500.0

thinking
**Exploring the Directory Structure**

I've begun listing files in the current directory. My intention is to map out the project's layout, and establish a foundational understanding. The goal is to see how everything is organized, and what key components are present, with the ultimate objective of efficient future progress.


assistant
Tool call: {
  "id": "tool_ls_porgeuX63RpoFuvSPVsU",
  "type": "function",
  "function": {
    "name": "ls",
    "arguments": "{\"dirPath\":\".\"}"
  }
}

Request 2

Type: Chat
Result: Error
Prompt Tokens: 268
Generated Tokens: 0
ThinkingTokens: 0
Total Time: 0.34s

Error 400 Provider returned error

m13253 avatar Dec 03 '25 04:12 m13253

Related issues:

  • #8785 - Gemini 3 Pro "Function call is missing a thought_signature in functionCall parts" (fixed by #8865 for direct Gemini API connections)
  • #8773 - No tool call found for function call output with call_id (similar error message to this issue)
  • #6483 - Use builtin_create_rule_block tool with google models return 400 error (OpenRouter with Google models)
  • #6121 - Gemini models in agent mode giving error 400 invalid argument (OpenRouter with Gemini models)
  • #3378 - OpenRouter chat doesn't work with some providers/models (general OpenRouter tool support issue)

The fix in #8865 added thought_signature support for Gemini, but only applies to the native Gemini provider. This issue appears to be the same root cause but affects users connecting to Gemini via OpenRouter's OpenAI-compatible API.

continue avatar Dec 03 '25 04:12 continue

Facing the same issue.

lakshya-skyfall avatar Dec 14 '25 06:12 lakshya-skyfall

Try to use non-stream mode ("stream": false) via OpenRouter. The delta object in SSE implementation of OpenRouter is ambiguous.

gongzhang avatar Dec 14 '25 07:12 gongzhang

I face the same issue

abdurrahmanregi avatar Dec 18 '25 01:12 abdurrahmanregi

Try to use non-stream mode ("stream": false) via OpenRouter. The delta object in SSE implementation of OpenRouter is ambiguous.

in my case, this does not solve the 400 Error.

abdurrahmanregi avatar Dec 18 '25 01:12 abdurrahmanregi

are there any solutions to this problem? having the same issue

groza-tech avatar Dec 27 '25 19:12 groza-tech

Thank you for your information. However, I want to respond that:

OpenRouter forwards the OpenAI-style function declaration format but Gemini expects its own format

I believe OpenRouter does convert the schema. Otherwise we won’t be able to use Claude models. However, per its privacy policy, it can’t help us copy the thought_signature from the previous request because it doesn’t remember our previous requests.

It's an OpenRouter-Gemini interop problem, not a Continue.dev bug.

Kilo Code does not observe this issue when calling Gemini 3 through OpenRouter. We just need to make sure the thought_signature needs to be preserved between calls.

Komilion normalizes tool call schemas per-model internally

I wish to have a local program for schema conversion instead of reading one more privacy policy. I believe this is the same reason why people use Continue.dev instead of VS Code’s built-in Copilot.

m13253 avatar Feb 21 '26 22:02 m13253

This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue.

github-actions[bot] avatar May 25 '26 02:05 github-actions[bot]

This issue was closed because it wasn't updated for 10 days after being marked stale. If it's still important, please reopen + comment and we'll gladly take another look!

github-actions[bot] avatar Jun 05 '26 02:06 github-actions[bot]