SIGN IN SIGN UP

feat(xai): batch API support (#19525)

## Background

xAI has a [Batch
API](https://docs.x.ai/developers/advanced-api-usage/batch-api) for
processing large numbers of requests asynchronously. AI SDK already
supports its experimental text batch APIs in several providers, but
`@ai-sdk/xai` did not implement them.

## Summary

Added Batch API support to the xAI provider.

- Exposes batch support through `xai(modelId)` and
`xai.responses(modelId)`.
- Prepares each request through the existing Responses API
implementation.
- Uploads requests as JSONL through the xAI Files API and starts a
file-backed batch.

## End-to-End Verification

Ran the xAI batch example against the live API with `grok-4.3`. The
batch uploaded successfully, completed, and returned the expected
results for both request IDs.

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [x] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)

## Future Work

- Add fast-fail validation across batch providers for models that do not
support batch processing.
N
Nick Oates committed
3f8fa938c364278911d897c39cdd6b8dbae719b4
Parent: dee4c16
Committed by GitHub <noreply@github.com> on 8/25/2026, 8:46:55 PM