-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: upgrade xAI web search from deprecated Live Search to Responses API #12812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Upgrade @ai-sdk/xai from 2.0.36 to 2.0.56 and switch xAI provider to use the Responses API with tool-based web search instead of the deprecated Live Search approach using provider options. Changes: - Upgrade @ai-sdk/xai to 2.0.56 (ai-v5 compatible) - Switch xAI provider to use xai.responses(modelId) by default - Change web search plugin from searchParameters to xai.tools.webSearch() - Simplify xAI web search config to use only excludedDomains (max 5) - Remove unused createXaiOptions function - Update tests to match new config format Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Hi maintainers, this PR is ready for review. Could someone please take a look |
GeorgeDong32
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR correctly implements the migration from deprecated xAI Live Search API to the new Responses API. The code quality is excellent with reduced complexity and better performance.
However, there are two documentation issues that should be addressed before merging:
1. Breaking changes not fully documented
The PR introduces breaking changes (default configuration changes), but the "Breaking changes" section in the PR description is empty.
Suggestion: Add the following to the PR description:
### Breaking changes
- xAI web search default configuration changed from using `searchParameters` to `xai.tools.webSearch()`
- Previous default settings (returnCitations, maxSources, sources) are no longer applied by default
- Users requiring custom xAI search behavior should update their web search configuration2. Release Note missing
The PR description has an empty Release Note, but this is a user-visible feature change.
Suggestion: Add a Release Note:
```release-note
Upgraded xAI provider to use the new Responses API with tool-based web search.
The deprecated Live Search approach has been removed.
xAI web search now uses `xai.tools.webSearch()` with simplified configuration.
---
**Overall**: The code changes are good and ready to merge. Please update the PR description with the missing documentation sections.
EurFelux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
整体来看,这个 PR 将 xAI web search 从已弃用的 Live Search (provider options 方式) 迁移到 Responses API (tool-based 方式),方向正确,代码质量良好。
👍 做得好的地方
- 类型系统升级:
XAISearchConfig从ProviderOptionsMap['xai']['searchParameters']改为Parameters<typeof xai.tools.webSearch>[0],直接从 SDK 推导类型,更安全也更易维护 - 一致性: xAI 现在和 OpenAI、Anthropic、Google 一样使用
applyToolBasedSearch,而不是走applyProviderOptionsSearch的特殊路径 - 清理干净:
createXaiOptions删除后无残留引用,ProviderOptionsMap的导入也一并清理 - 测试更新: 测试用例完整覆盖了新的配置格式(空配置、有 excludeDomains、超过 5 个域名截断)
- 符合 API 文档: xAI Responses API 的
web_searchtool 确实只支持excludedDomains/allowedDomains(最多 5 个),代码实现与官方文档一致
⚠️ 需要关注的点
- 所有 xAI 模型默认走 Responses API —
schemas.ts中将languageModel重定向到provider.responses(modelId),这是一个全局行为变更,需要确认所有 xAI 模型都支持 Responses API maxResults对 xAI 不再生效 — 用户之前配置的搜索结果数量限制会被静默忽略,建议在代码中加个注释说明原因- PR 描述的 Breaking Changes 和 Release Note 部分为空 — 同意 @GeorgeDong32 的建议,应补充这些信息
📝 Minor
excludeDomains.slice(0, 5)比之前的excludeDomains.slice(0, Math.min(excludeDomains.length, 5))更简洁 👌
| maxSearchResults: 5, | ||
| sources: [{ type: 'web' }, { type: 'x' }, { type: 'news' }] | ||
| }, | ||
| xai: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Observation: Default xAI web search config is now empty
The old default config had explicit settings:
xai: {
mode: 'on',
returnCitations: true,
maxSearchResults: 5,
sources: [{ type: 'web' }, { type: 'x' }, { type: 'news' }]
}Now it's just xai: {}. This delegates all behavior to xAI's server-side defaults for the Responses API web_search tool, which is cleaner — but it means users lose the ability to control maxSearchResults and source types (web, x, news) that were previously configurable.
Is this intentional? The xAI Responses API web_search tool currently only supports excludedDomains and allowedDomains as parameters, so this simplification aligns with the new API surface. Just flagging the behavioral difference.
|
Note This comment was translated by Claude. Hey friends, could a real person please review my PR? Why are all the reviews from AI? Original Content朋友们,有没有真人review一下我的pr,怎么都是AI在review |
|
Note This comment was translated by Claude. After upgrading to the response API, the xAI provider type needs to be modified. Original Content升级成response api之后,需要修改xai的provider 类型 |
|
Note This comment was translated by Claude. It still shows chat/completion here. Original Content这里还显示的是 chat/completion |
Upgrade @ai-sdk/xai from 2.0.36 to 2.0.56 and switch xAI provider to use the Responses API with tool-based web search instead of the deprecated Live Search approach using provider options.
Changes:
What this PR does
Before this PR:
After this PR:
Fixes #
Why we need it and why it was done in this way
The following tradeoffs were made:
The following alternatives were considered:
Links to places where the discussion took place:
Breaking changes
If this PR introduces breaking changes, please describe the changes and the impact on users.
Special notes for your reviewer
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note