You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Response terminates prematurely when using Gemini 3 via LiteLLM #6244
When using gemini-3-flash-preview through a LiteLLM proxy, OpenCode stops processing the response as soon as the model triggers a tool call. The model provides a reasoning block and a tool call, but OpenCode does not seem to execute the requested tool (e.g., read) and the interaction hangs or terminates without output.
The model response from LiteLLM looks like this (shortened for clarity):
@emerzon Thanks for the suggestion, but using @ai-sdk/google would bypass LiteLLM entirely and connect directly to Gemini.
The whole point here is to use LiteLLM as a proxy. LiteLLM exposes an OpenAI-compatible API regardless of the backend model, so @ai-sdk/openai-compatible is the correct choice.
The issue seems to be with how OpenCode handles Gemini 3's special response fields (reasoning_content, thought_signature) when passed through LiteLLM. This configuration works fine with Claude Code and Continue.dev, so it appears to be an OpenCode specific issue.
@themw123 This is not true, you can still set the base URL and it will go over LiteLLM, but use the Gemini request format without OpenAI format translation.
I am using it exactly like that.
my opencode setting is similar to yours but i noticed you didnt define authentication and i am getting an authentication issue because my litellm proxy requires an API key, have you been able to get it to work if you require authentication in litellm proxy?
I am using with Vertex, but I don't have use_in_pass_through: true in my config.
I also have individual model entries for each model: Ie. gemini-3-pro-preview, gemini-3-flash-preview, etc.
My auth to vertex is handled via env vars: GOOGLE_APPLICATION_CREDENTIALS (pointing to the keyfile with credentails), VERTEX_PROJECT and VERTEX_LOCATION, but I suppose this wont matter much.
For the client authentication you should not set the credentials in the config file, you should use the /connect option later in the UI to provide the API key
thanks @emerzon I've been running in circles trying to get that to work ! I was also using the open-ai compatible model.
I don't seem to get cost reported on opencode though with this setup, even though my LiteLLM instance returns token usage - any idea how to fix that too?
I don't seem to get cost reported on opencode though with this setup, even though my LiteLLM instance returns token usage - any idea how to fix that too?
I think the only way so far is to manually set costs in the model definition:
Activity
github-actions commentedon Dec 27, 2025
This issue might be a duplicate of existing issues. Please check:
thoughtSignaturesupport #4832: [BUG]: Gemini 3 Pro function calling fails - missingthoughtSignaturesupport (Gemini 3 tool calling compatibility issue)Feel free to ignore if none of these address your specific case.
emerzon commentedon Jan 10, 2026
Do not use the
@ai-sdk/openai-compatibleprovider with Gemini on LiteLLM. Use@ai-sdk/googleinsteadthemw123 commentedon Jan 10, 2026
@emerzon Thanks for the suggestion, but using @ai-sdk/google would bypass LiteLLM entirely and connect directly to Gemini.
The whole point here is to use LiteLLM as a proxy. LiteLLM exposes an OpenAI-compatible API regardless of the backend model, so @ai-sdk/openai-compatible is the correct choice.
The issue seems to be with how OpenCode handles Gemini 3's special response fields (reasoning_content, thought_signature) when passed through LiteLLM. This configuration works fine with Claude Code and Continue.dev, so it appears to be an OpenCode specific issue.
emerzon commentedon Jan 10, 2026
@themw123 This is not true, you can still set the base URL and it will go over LiteLLM, but use the Gemini request format without OpenAI format translation.
I am using it exactly like that.
darwincrv commentedon Jan 14, 2026
i tried to use the passthrough config from emerzon but it did not work
Connecting to litellm proxy using openai compatible it works but it stops constantly is not usable
emerzon commentedon Jan 14, 2026
I have been using this config without any issues. Which issues did you had?
darwincrv commentedon Jan 14, 2026
the outcome of my tests indicate that gemini api is not supported for passthrough api so i tried using vertex:
https://docs.litellm.ai/docs/pass_through/vertex_ai
so i configured litellm like this:
config.yaml
my opencode setting is similar to yours but i noticed you didnt define authentication and i am getting an authentication issue because my litellm proxy requires an API key, have you been able to get it to work if you require authentication in litellm proxy?
emerzon commentedon Jan 14, 2026
I am using with Vertex, but I don't have
use_in_pass_through: truein my config.I also have individual model entries for each model: Ie.
gemini-3-pro-preview,gemini-3-flash-preview, etc.My auth to vertex is handled via env vars:
GOOGLE_APPLICATION_CREDENTIALS(pointing to the keyfile with credentails),VERTEX_PROJECTandVERTEX_LOCATION, but I suppose this wont matter much.For the client authentication you should not set the credentials in the config file, you should use the
/connectoption later in the UI to provide the API keyabrouaux commentedon Jan 14, 2026
thanks @emerzon I've been running in circles trying to get that to work ! I was also using the open-ai compatible model.
I don't seem to get cost reported on opencode though with this setup, even though my LiteLLM instance returns token usage - any idea how to fix that too?
emerzon commentedon Jan 14, 2026
I think the only way so far is to manually set costs in the model definition:
darwincrv commentedon Jan 15, 2026
thanks @emerzon that worked
themw123 commentedon Jan 23, 2026
upgraded to newer version and now it seems to be fixed even with
"npm": "@ai-sdk/openai-compatible"tkyggit commentedon Feb 5, 2026
I think the following link is the cause.
BerriAI/litellm#19744
response.completed always returns finish_reason='stop' even when response contains tool calls