feat(zai): add Web Search in Chat integration for Z.AI provider - #5
Closed
oldschoola wants to merge 0 commit into
Closed
feat(zai): add Web Search in Chat integration for Z.AI provider#5oldschoola wants to merge 0 commit into
oldschoola wants to merge 0 commit into
Conversation
oldschoola
force-pushed
the
feat/zai-web-search-in-chat
branch
3 times, most recently
from
June 4, 2026 04:49
428bd23 to
26a23dc
Compare
oldschoola
force-pushed
the
feat/zai-web-search-in-chat
branch
from
June 4, 2026 05:19
26a23dc to
2b50e06
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Adds Z.AI's built-in Web Search in Chat feature to the Anthropic-compatible chat completions pipeline. When enabled, a
web_searchtool is injected into requests to Z.AI endpoints, allowing the model to search the web natively and return cited answers.What it does
web_search_20250305built-in tool into requests when the model targets a Z.AI Anthropic-compatible endpoint andzai.webSearchInChatis enabledserver_tool_use(search tool calls),web_search_tool_result(Anthropic native), andtool_result(Z.AI's format for search results)zai.webSearchInChat(enable/disable),zai.webSearchCount(1-50 results),zai.webSearchRecency(time range filter)Files changed
packages/ai/src/providers/anthropic-wire.tsServerToolUseBlockParam,WebSearchResultItem,WebSearchToolResultBlockParamtypespackages/ai/src/providers/anthropic.tsZaiWebSearchConfigtype, tool injection inbuildParams, stream handler for new block typespackages/ai/src/stream.tszaiWebSearchthroughmapOptionsForApipackages/ai/src/types.tszaiWebSearchtoSimpleStreamOptionspackages/coding-agent/src/config/settings-schema.tszai.webSearchInChat,zai.webSearchCount,zai.webSearchRecencysettingspackages/coding-agent/src/sdk.tsstreamFnoptionsTesting
Verified with Z.AI API key:
web_search_20250305tooltext,server_tool_use,tool_resultblockstool_resultcontent is JSON with search results (title, link, content, refer)Usage
Set in settings or via env:
Requires
ZAI_API_KEYto be set.