Skip to content

Conversation

@PhoenixCPH
Copy link

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

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


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>
@PhoenixCPH
Copy link
Author

Hi maintainers, this PR is ready for review. Could someone please take a look

Copy link
Collaborator

@GeorgeDong32 GeorgeDong32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ PR Review Comments

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 configuration

2. 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.

@GeorgeDong32 GeorgeDong32 requested review from DeJeune and EurFelux and removed request for EurFelux February 8, 2026 15:58
Copy link
Collaborator

@EurFelux EurFelux left a 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 方式),方向正确,代码质量良好。

👍 做得好的地方

  • 类型系统升级: XAISearchConfigProviderOptionsMap['xai']['searchParameters'] 改为 Parameters<typeof xai.tools.webSearch>[0],直接从 SDK 推导类型,更安全也更易维护
  • 一致性: xAI 现在和 OpenAI、Anthropic、Google 一样使用 applyToolBasedSearch,而不是走 applyProviderOptionsSearch 的特殊路径
  • 清理干净: createXaiOptions 删除后无残留引用,ProviderOptionsMap 的导入也一并清理
  • 测试更新: 测试用例完整覆盖了新的配置格式(空配置、有 excludeDomains、超过 5 个域名截断)
  • 符合 API 文档: xAI Responses API 的 web_search tool 确实只支持 excludedDomains / allowedDomains(最多 5 个),代码实现与官方文档一致

⚠️ 需要关注的点

  1. 所有 xAI 模型默认走 Responses APIschemas.ts 中将 languageModel 重定向到 provider.responses(modelId),这是一个全局行为变更,需要确认所有 xAI 模型都支持 Responses API
  2. maxResults 对 xAI 不再生效 — 用户之前配置的搜索结果数量限制会被静默忽略,建议在代码中加个注释说明原因
  3. 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: {},
Copy link
Collaborator

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.

@PhoenixCPH
Copy link
Author

PhoenixCPH commented Feb 9, 2026

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

@DeJeune
Copy link
Collaborator

DeJeune commented Feb 9, 2026

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 类型

@DeJeune
Copy link
Collaborator

DeJeune commented Feb 9, 2026

Note

This comment was translated by Claude.

It still shows chat/completion here.


Original Content

这里还显示的是 chat/completion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants