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
Add opt-in -search model aliases for models that support Google Search.
For example:
gemini-3.8-flash → unchanged
gemini-3.8-flash-search → resolves to gemini-3.8-flash with Google Search enabled
This allows clients that support Gemini-compatible APIs but do not send the native googleSearch tool to still use AIStudio2API's existing Google Search capability.
Motivation
Some third-party clients can connect to AIStudio2API through the Gemini API, but do not include Gemini's provider-native Google Search tool in the request.
In that case the incoming request contains no Search tool, so AIStudio2API correctly treats it as a normal generation request.
AIStudio2API's existing Google Search implementation already works when googleSearch is explicitly supplied.
This PR adds an opt-in compatibility mechanism without changing the behavior of existing model IDs.
Behavior
A request using:
gemini-3.8-flash-search
is internally resolved to:
gemini-3.8-flash
and Google Search is enabled through the existing GoogleSearchOptions path.
The upstream AI Studio request still uses the canonical model ID.
Normal models remain unchanged:
gemini-3.8-flash
does not automatically enable Search.
Model catalog
For eligible models that support Google Search and generateContent, an additional -search alias is exposed.
Example:
gemini-3.8-flash
gemini-3.8-flash-search
The alias inherits the base model metadata and capabilities.
Implementation
Search aliases are resolved before generation and tool capability validation.
The injected Search option continues through the existing pipeline:
GoogleSearchOptions
→ validateRequestedTools
→ encodeRequestedTools
→ encodeSearchTool
→ AI Studio
Existing tools are preserved when Search is injected.
Compatibility
This PR does not change:
the existing Google Search wire encoding
WAA handling
grounding decoding
normal model behavior
requests that already provide Google Search
unsupported model capability validation
The feature is only enabled when a -search model alias is explicitly requested.
API support
The shared alias resolution path supports:
Gemini generateContent
Gemini streamGenerateContent
OpenAI Chat Completions
Responses API
Tests
Added coverage for:
Search alias resolution
normal model behavior
automatic Google Search injection
preserving existing tools
avoiding duplicate Search tools
canonical upstream model resolution
model catalog alias generation
unsupported model validation
Gemini streaming requests
Validation performed with:
go test ./internal/api ./internal/aistudio
go test ./...
git diff --check
Thanks so much for this. We'd rather not add -search model aliases for now, so we won't merge it yet, but we'll keep it open.
What we did instead: the service now recognizes the search fields clients already send — web_search_options in OpenAI Chat, the web_search server tool in Anthropic Messages, and googleSearch in Gemini requests (fb87416). That covers clients that expose a web search option without adding model IDs. An alias would add a second catalog entry for every search-capable model, and the model list is built from each account's live upstream catalog.
The case your PR targets, clients that can't send any search field at all, isn't covered yet. If you can tell us which client you're using, we'll look at its actual requests and decide whether an alias or another mechanism fits best. This PR stays open as the reference for that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add opt-in
-searchmodel aliases for models that support Google Search.For example:
gemini-3.8-flash→ unchangedgemini-3.8-flash-search→ resolves togemini-3.8-flashwith Google Search enabledThis allows clients that support Gemini-compatible APIs but do not send the native
googleSearchtool to still use AIStudio2API's existing Google Search capability.Motivation
Some third-party clients can connect to AIStudio2API through the Gemini API, but do not include Gemini's provider-native Google Search tool in the request.
In that case the incoming request contains no Search tool, so AIStudio2API correctly treats it as a normal generation request.
AIStudio2API's existing Google Search implementation already works when
googleSearchis explicitly supplied.This PR adds an opt-in compatibility mechanism without changing the behavior of existing model IDs.
Behavior
A request using:
is internally resolved to:
and Google Search is enabled through the existing
GoogleSearchOptionspath.The upstream AI Studio request still uses the canonical model ID.
Normal models remain unchanged:
does not automatically enable Search.
Model catalog
For eligible models that support Google Search and
generateContent, an additional-searchalias is exposed.Example:
The alias inherits the base model metadata and capabilities.
Implementation
Search aliases are resolved before generation and tool capability validation.
The injected Search option continues through the existing pipeline:
Existing tools are preserved when Search is injected.
Compatibility
This PR does not change:
The feature is only enabled when a
-searchmodel alias is explicitly requested.API support
The shared alias resolution path supports:
generateContentstreamGenerateContentTests
Added coverage for:
Validation performed with:
All tests pass.