@ai-sdk/xai 4.0.53 → 4.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +121 -81
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +21 -12
- package/package.json +3 -3
- package/src/responses/xai-responses-language-model.ts +43 -28
- package/src/{responses/xai-responses-batch.ts → xai-batch.ts} +93 -74
- package/src/xai-provider.ts +25 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 4.0.55
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a4ba394: feat: support per-request models in batch
|
|
8
|
+
- Updated dependencies [a4ba394]
|
|
9
|
+
- Updated dependencies [45099da]
|
|
10
|
+
- Updated dependencies [9e1d1b2]
|
|
11
|
+
- Updated dependencies [a495511]
|
|
12
|
+
- @ai-sdk/provider@4.0.11
|
|
13
|
+
- @ai-sdk/provider-utils@5.0.37
|
|
14
|
+
|
|
15
|
+
## 4.0.54
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 048ce06: feat(batch): surface the uploaded input file on the batch start result (`providerMetadata.<provider>.inputFileId` / `inputFileExpiresAt`) and accept an `inputFileExpiresAfter` provider option on the OpenAI and xAI batch input file upload
|
|
20
|
+
|
|
3
21
|
## 4.0.53
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { InferSchema, FetchFunction, WebSocketConstructor } from '@ai-sdk/provider-utils';
|
|
4
|
-
import { ProviderV4,
|
|
4
|
+
import { ProviderV4, LanguageModelV4, Experimental_BatchV4, ImageModelV4, Experimental_VideoModelV4, Experimental_RealtimeFactoryV4, SpeechModelV4, TranscriptionModelV4, FilesV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig } from '@ai-sdk/provider';
|
|
5
5
|
|
|
6
6
|
type XaiChatModelId = 'grok-4.20-non-reasoning' | 'grok-4.20-reasoning' | 'grok-4.3' | 'grok-4.5' | 'grok-4.6' | 'grok-latest' | (string & {});
|
|
7
7
|
declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
@@ -535,11 +535,11 @@ declare const xaiTools: {
|
|
|
535
535
|
};
|
|
536
536
|
|
|
537
537
|
interface XaiProvider extends ProviderV4 {
|
|
538
|
-
(modelId: XaiResponsesModelId):
|
|
538
|
+
(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
539
539
|
/**
|
|
540
540
|
* Creates an Xai language model for text generation.
|
|
541
541
|
*/
|
|
542
|
-
languageModel(modelId: XaiResponsesModelId):
|
|
542
|
+
languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
543
543
|
/**
|
|
544
544
|
* Creates an Xai chat model for text generation.
|
|
545
545
|
*/
|
|
@@ -547,7 +547,13 @@ interface XaiProvider extends ProviderV4 {
|
|
|
547
547
|
/**
|
|
548
548
|
* Creates an Xai responses model for text generation.
|
|
549
549
|
*/
|
|
550
|
-
responses: (modelId: XaiResponsesModelId) =>
|
|
550
|
+
responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
|
|
551
|
+
/**
|
|
552
|
+
* Returns a BatchV4 interface for processing batches with xAI.
|
|
553
|
+
*/
|
|
554
|
+
experimental_batch(): Experimental_BatchV4<{
|
|
555
|
+
text: XaiResponsesModelId;
|
|
556
|
+
}>;
|
|
551
557
|
/**
|
|
552
558
|
* Creates an Xai image model for image generation.
|
|
553
559
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1239,7 +1239,7 @@ var xaiImageResponseSchema = z6.object({
|
|
|
1239
1239
|
}).nullish()
|
|
1240
1240
|
});
|
|
1241
1241
|
|
|
1242
|
-
// src/
|
|
1242
|
+
// src/xai-batch.ts
|
|
1243
1243
|
import {
|
|
1244
1244
|
InvalidArgumentError
|
|
1245
1245
|
} from "@ai-sdk/provider";
|
|
@@ -1251,11 +1251,10 @@ import {
|
|
|
1251
1251
|
getFromApi as getFromApi2,
|
|
1252
1252
|
lazySchema as lazySchema7,
|
|
1253
1253
|
normalizeBatchRequestCounts,
|
|
1254
|
+
parseProviderOptions as parseProviderOptions6,
|
|
1254
1255
|
postFormDataToApi,
|
|
1255
1256
|
postJsonToApi as postJsonToApi4,
|
|
1256
1257
|
safeValidateTypes,
|
|
1257
|
-
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE4,
|
|
1258
|
-
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE4,
|
|
1259
1258
|
zodSchema as zodSchema7
|
|
1260
1259
|
} from "@ai-sdk/provider-utils";
|
|
1261
1260
|
import { z as z15 } from "zod/v4";
|
|
@@ -2519,17 +2518,18 @@ function getHttpStatusCode(value) {
|
|
|
2519
2518
|
function isRetryableStatusCode(statusCode) {
|
|
2520
2519
|
return statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500;
|
|
2521
2520
|
}
|
|
2521
|
+
var xaiResponsesSupportedUrls = {
|
|
2522
|
+
"image/*": [/^https?:\/\/.*$/],
|
|
2523
|
+
// xAI's Responses API accepts non-image documents (PDF, plain text, CSV, etc.) as
|
|
2524
|
+
// `{ type: 'input_file', file_url }`. Keeping these URLs intact here lets them pass
|
|
2525
|
+
// through to the converter instead of being downloaded to bytes by the SDK.
|
|
2526
|
+
"application/pdf": [/^https?:\/\/.*$/],
|
|
2527
|
+
"text/*": [/^https?:\/\/.*$/]
|
|
2528
|
+
};
|
|
2522
2529
|
var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
2523
2530
|
constructor(modelId, config) {
|
|
2524
2531
|
this.specificationVersion = "v4";
|
|
2525
|
-
this.supportedUrls =
|
|
2526
|
-
"image/*": [/^https?:\/\/.*$/],
|
|
2527
|
-
// xAI's Responses API accepts non-image documents (PDF, plain text, CSV, etc.) as
|
|
2528
|
-
// `{ type: 'input_file', file_url }`. Keeping these URLs intact here lets them pass
|
|
2529
|
-
// through to the converter instead of being downloaded to bytes by the SDK.
|
|
2530
|
-
"application/pdf": [/^https?:\/\/.*$/],
|
|
2531
|
-
"text/*": [/^https?:\/\/.*$/]
|
|
2532
|
-
};
|
|
2532
|
+
this.supportedUrls = xaiResponsesSupportedUrls;
|
|
2533
2533
|
this.modelId = modelId;
|
|
2534
2534
|
this.config = config;
|
|
2535
2535
|
}
|
|
@@ -2545,21 +2545,24 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2545
2545
|
get provider() {
|
|
2546
2546
|
return this.config.provider;
|
|
2547
2547
|
}
|
|
2548
|
-
async
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2548
|
+
static async prepareRequest({
|
|
2549
|
+
modelId,
|
|
2550
|
+
options: {
|
|
2551
|
+
prompt,
|
|
2552
|
+
maxOutputTokens,
|
|
2553
|
+
temperature,
|
|
2554
|
+
topP,
|
|
2555
|
+
topK,
|
|
2556
|
+
frequencyPenalty,
|
|
2557
|
+
presencePenalty,
|
|
2558
|
+
stopSequences,
|
|
2559
|
+
seed,
|
|
2560
|
+
responseFormat,
|
|
2561
|
+
providerOptions,
|
|
2562
|
+
tools,
|
|
2563
|
+
toolChoice,
|
|
2564
|
+
reasoning
|
|
2565
|
+
}
|
|
2563
2566
|
}) {
|
|
2564
2567
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2565
2568
|
const warnings = [];
|
|
@@ -2622,7 +2625,7 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2622
2625
|
}
|
|
2623
2626
|
let resolvedReasoningEffort = options.reasoningEffort;
|
|
2624
2627
|
if (resolvedReasoningEffort == null && isCustomReasoning2(reasoning)) {
|
|
2625
|
-
if (!supportsReasoningEffort(
|
|
2628
|
+
if (!supportsReasoningEffort(modelId)) {
|
|
2626
2629
|
warnings.push({
|
|
2627
2630
|
type: "unsupported",
|
|
2628
2631
|
feature: "reasoning",
|
|
@@ -2638,14 +2641,14 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2638
2641
|
low: "low",
|
|
2639
2642
|
medium: "medium",
|
|
2640
2643
|
high: "high",
|
|
2641
|
-
xhigh:
|
|
2644
|
+
xhigh: modelId === "grok-4.6" ? "xhigh" : "high"
|
|
2642
2645
|
},
|
|
2643
2646
|
warnings
|
|
2644
2647
|
});
|
|
2645
2648
|
}
|
|
2646
2649
|
}
|
|
2647
2650
|
const baseArgs = {
|
|
2648
|
-
model:
|
|
2651
|
+
model: modelId,
|
|
2649
2652
|
input,
|
|
2650
2653
|
logprobs: options.logprobs === true || options.topLogprobs != null ? true : void 0,
|
|
2651
2654
|
top_logprobs: options.topLogprobs,
|
|
@@ -2704,6 +2707,12 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2704
2707
|
imageGenerationToolName
|
|
2705
2708
|
};
|
|
2706
2709
|
}
|
|
2710
|
+
getArgs(options) {
|
|
2711
|
+
return _XaiResponsesLanguageModel.prepareRequest({
|
|
2712
|
+
modelId: this.modelId,
|
|
2713
|
+
options
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2707
2716
|
async doGenerate(options) {
|
|
2708
2717
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
2709
2718
|
const {
|
|
@@ -3506,10 +3515,22 @@ function mapWebSearchAction(action) {
|
|
|
3506
3515
|
}
|
|
3507
3516
|
}
|
|
3508
3517
|
|
|
3509
|
-
// src/
|
|
3518
|
+
// src/xai-batch.ts
|
|
3510
3519
|
var xaiBatchEndpoint = "/v1/responses";
|
|
3511
3520
|
var xaiBatchName = "ai-sdk-text-batch";
|
|
3512
3521
|
var xaiBatchResultsPageSize = 1e3;
|
|
3522
|
+
var xaiBatchProviderOptionsSchema = lazySchema7(
|
|
3523
|
+
() => zodSchema7(
|
|
3524
|
+
z15.object({
|
|
3525
|
+
/**
|
|
3526
|
+
* TTL in seconds for the uploaded batch input file, measured from
|
|
3527
|
+
* upload time. xAI accepts integers between 3600 (1 hour) and
|
|
3528
|
+
* 2592000 (30 days) inclusive. Without it the file has no expiry.
|
|
3529
|
+
*/
|
|
3530
|
+
inputFileExpiresAfter: z15.number().int().min(3600).max(2592e3).optional()
|
|
3531
|
+
})
|
|
3532
|
+
)
|
|
3533
|
+
);
|
|
3513
3534
|
var xaiBatchResponseSchema = lazySchema7(
|
|
3514
3535
|
() => zodSchema7(
|
|
3515
3536
|
z15.object({
|
|
@@ -3551,11 +3572,14 @@ var xaiBatchResultsPageSchema = lazySchema7(
|
|
|
3551
3572
|
})
|
|
3552
3573
|
)
|
|
3553
3574
|
);
|
|
3554
|
-
var
|
|
3575
|
+
var XaiBatch = class {
|
|
3555
3576
|
constructor(options) {
|
|
3556
3577
|
this.options = options;
|
|
3578
|
+
this.specificationVersion = "v4";
|
|
3579
|
+
this.supportedUrls = xaiResponsesSupportedUrls;
|
|
3580
|
+
this.provider = options.provider;
|
|
3557
3581
|
}
|
|
3558
|
-
async
|
|
3582
|
+
async doStartBatch(options) {
|
|
3559
3583
|
var _a, _b;
|
|
3560
3584
|
const fileParts = [];
|
|
3561
3585
|
const warnings = options.webhookUrl == null ? [] : [
|
|
@@ -3567,8 +3591,13 @@ var XaiResponsesBatch = class {
|
|
|
3567
3591
|
}
|
|
3568
3592
|
}
|
|
3569
3593
|
];
|
|
3594
|
+
const batchOptions = await parseProviderOptions6({
|
|
3595
|
+
provider: "xai",
|
|
3596
|
+
providerOptions: options.providerOptions,
|
|
3597
|
+
schema: xaiBatchProviderOptionsSchema
|
|
3598
|
+
});
|
|
3570
3599
|
for (const request of options.requests) {
|
|
3571
|
-
const preparedRequest = await this.
|
|
3600
|
+
const preparedRequest = await this.prepareRequest(request);
|
|
3572
3601
|
fileParts.push(
|
|
3573
3602
|
JSON.stringify({
|
|
3574
3603
|
custom_id: request.id,
|
|
@@ -3586,6 +3615,12 @@ var XaiResponsesBatch = class {
|
|
|
3586
3615
|
const file = new Blob(fileParts, { type: "application/jsonl" });
|
|
3587
3616
|
fileParts.length = 0;
|
|
3588
3617
|
const formData = new FormData();
|
|
3618
|
+
if ((batchOptions == null ? void 0 : batchOptions.inputFileExpiresAfter) != null) {
|
|
3619
|
+
formData.append(
|
|
3620
|
+
"expires_after",
|
|
3621
|
+
String(batchOptions.inputFileExpiresAfter)
|
|
3622
|
+
);
|
|
3623
|
+
}
|
|
3589
3624
|
formData.append("file", file, filename);
|
|
3590
3625
|
const headers = combineHeaders4(
|
|
3591
3626
|
(_b = (_a = this.options.config).headers) == null ? void 0 : _b.call(_a),
|
|
@@ -3619,13 +3654,23 @@ var XaiResponsesBatch = class {
|
|
|
3619
3654
|
return {
|
|
3620
3655
|
batchId: batch.batch_id,
|
|
3621
3656
|
...convertXaiBatchStatus(batch),
|
|
3657
|
+
providerMetadata: {
|
|
3658
|
+
xai: {
|
|
3659
|
+
inputFileId: uploadedFile.id,
|
|
3660
|
+
...uploadedFile.expires_at != null ? {
|
|
3661
|
+
inputFileExpiresAt: new Date(
|
|
3662
|
+
uploadedFile.expires_at * 1e3
|
|
3663
|
+
).toISOString()
|
|
3664
|
+
} : {}
|
|
3665
|
+
}
|
|
3666
|
+
},
|
|
3622
3667
|
warnings
|
|
3623
3668
|
};
|
|
3624
3669
|
}
|
|
3625
|
-
async
|
|
3670
|
+
async doGetBatchStatus(options) {
|
|
3626
3671
|
return convertXaiBatchStatus(await this.retrieveBatch(options));
|
|
3627
3672
|
}
|
|
3628
|
-
async
|
|
3673
|
+
async doGetBatchResults(options) {
|
|
3629
3674
|
const batch = await this.retrieveBatch(options);
|
|
3630
3675
|
if (convertXaiBatchStatus(batch).status === "pending") {
|
|
3631
3676
|
throw new InvalidArgumentError({
|
|
@@ -3690,6 +3735,7 @@ var XaiResponsesBatch = class {
|
|
|
3690
3735
|
if (((_c = (_b = result.error_message) == null ? void 0 : _b.length) != null ? _c : 0) > 0 || (error == null ? void 0 : error.code) != null && error.code !== 0 && error.code !== "0" || (error == null ? void 0 : error.code) == null && ((_e = (_d = error == null ? void 0 : error.message) == null ? void 0 : _d.length) != null ? _e : 0) > 0) {
|
|
3691
3736
|
const convertedError = convertXaiBatchError(result);
|
|
3692
3737
|
return {
|
|
3738
|
+
type: "text",
|
|
3693
3739
|
id: result.batch_request_id,
|
|
3694
3740
|
status: isXaiCancellationError(error == null ? void 0 : error.code) ? "cancelled" : "failed",
|
|
3695
3741
|
error: convertedError
|
|
@@ -3706,10 +3752,12 @@ var XaiResponsesBatch = class {
|
|
|
3706
3752
|
}
|
|
3707
3753
|
const conversion = convertXaiChatBatchResponse(validation.value);
|
|
3708
3754
|
return conversion.success ? {
|
|
3755
|
+
type: "text",
|
|
3709
3756
|
id: result.batch_request_id,
|
|
3710
3757
|
status: "succeeded",
|
|
3711
3758
|
result: conversion.result
|
|
3712
3759
|
} : {
|
|
3760
|
+
type: "text",
|
|
3713
3761
|
id: result.batch_request_id,
|
|
3714
3762
|
status: "failed",
|
|
3715
3763
|
error: conversion.error
|
|
@@ -3717,38 +3765,18 @@ var XaiResponsesBatch = class {
|
|
|
3717
3765
|
}
|
|
3718
3766
|
return invalidXaiBatchResult(result.batch_request_id);
|
|
3719
3767
|
}
|
|
3768
|
+
async prepareRequest(request) {
|
|
3769
|
+
const { args: body, warnings } = await XaiResponsesLanguageModel.prepareRequest({
|
|
3770
|
+
modelId: request.modelId,
|
|
3771
|
+
options: request.options
|
|
3772
|
+
});
|
|
3773
|
+
return { body, warnings };
|
|
3774
|
+
}
|
|
3720
3775
|
getUrl(path) {
|
|
3721
3776
|
var _a;
|
|
3722
3777
|
return `${(_a = this.options.config.baseURL) != null ? _a : "https://api.x.ai/v1"}${path}`;
|
|
3723
3778
|
}
|
|
3724
3779
|
};
|
|
3725
|
-
var XaiResponsesBatchLanguageModel = class _XaiResponsesBatchLanguageModel extends XaiResponsesLanguageModel {
|
|
3726
|
-
static [WORKFLOW_SERIALIZE4](model) {
|
|
3727
|
-
return XaiResponsesLanguageModel[WORKFLOW_SERIALIZE4](model);
|
|
3728
|
-
}
|
|
3729
|
-
static [WORKFLOW_DESERIALIZE4](options) {
|
|
3730
|
-
return new _XaiResponsesBatchLanguageModel(options.modelId, options.config);
|
|
3731
|
-
}
|
|
3732
|
-
constructor(modelId, config) {
|
|
3733
|
-
super(modelId, config);
|
|
3734
|
-
this.batch = new XaiResponsesBatch({
|
|
3735
|
-
config,
|
|
3736
|
-
prepareRequest: async (request) => {
|
|
3737
|
-
const { args: body, warnings } = await this.getArgs(request.options);
|
|
3738
|
-
return { body, warnings };
|
|
3739
|
-
}
|
|
3740
|
-
});
|
|
3741
|
-
}
|
|
3742
|
-
experimental_doStartBatch(options) {
|
|
3743
|
-
return this.batch.startBatch(options);
|
|
3744
|
-
}
|
|
3745
|
-
experimental_doGetBatchStatus(options) {
|
|
3746
|
-
return this.batch.getBatchStatus(options);
|
|
3747
|
-
}
|
|
3748
|
-
experimental_doGetBatchResults(options) {
|
|
3749
|
-
return this.batch.getBatchResults(options);
|
|
3750
|
-
}
|
|
3751
|
-
};
|
|
3752
3780
|
function convertXaiBatchStatus(batch) {
|
|
3753
3781
|
var _a, _b, _c, _d, _e, _f;
|
|
3754
3782
|
const requestCounts = normalizeBatchRequestCounts({
|
|
@@ -3799,6 +3827,7 @@ function isXaiCancellationError(code) {
|
|
|
3799
3827
|
}
|
|
3800
3828
|
function invalidXaiBatchResult(id) {
|
|
3801
3829
|
return {
|
|
3830
|
+
type: "text",
|
|
3802
3831
|
id,
|
|
3803
3832
|
status: "failed",
|
|
3804
3833
|
error: {
|
|
@@ -4329,7 +4358,7 @@ var xaiTools = {
|
|
|
4329
4358
|
};
|
|
4330
4359
|
|
|
4331
4360
|
// src/version.ts
|
|
4332
|
-
var VERSION = true ? "4.0.
|
|
4361
|
+
var VERSION = true ? "4.0.55" : "0.0.0-test";
|
|
4333
4362
|
|
|
4334
4363
|
// src/files/xai-files.ts
|
|
4335
4364
|
import {
|
|
@@ -4342,7 +4371,7 @@ import {
|
|
|
4342
4371
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
4343
4372
|
deleteFromApi,
|
|
4344
4373
|
getFromApi as getFromApi3,
|
|
4345
|
-
parseProviderOptions as
|
|
4374
|
+
parseProviderOptions as parseProviderOptions7,
|
|
4346
4375
|
postFormDataToApi as postFormDataToApi2,
|
|
4347
4376
|
postMultipartStreamToApi
|
|
4348
4377
|
} from "@ai-sdk/provider-utils";
|
|
@@ -4405,7 +4434,7 @@ var XaiFiles = class {
|
|
|
4405
4434
|
var _a, _b;
|
|
4406
4435
|
let xaiOptions;
|
|
4407
4436
|
try {
|
|
4408
|
-
xaiOptions = await
|
|
4437
|
+
xaiOptions = await parseProviderOptions7({
|
|
4409
4438
|
provider: "xai",
|
|
4410
4439
|
providerOptions,
|
|
4411
4440
|
schema: xaiFilesOptionsSchema
|
|
@@ -4594,7 +4623,7 @@ import {
|
|
|
4594
4623
|
extractResponseHeaders as extractResponseHeaders2,
|
|
4595
4624
|
getFromApi as getFromApi4,
|
|
4596
4625
|
getTopLevelMediaType as getTopLevelMediaType3,
|
|
4597
|
-
parseProviderOptions as
|
|
4626
|
+
parseProviderOptions as parseProviderOptions8,
|
|
4598
4627
|
postJsonToApi as postJsonToApi5,
|
|
4599
4628
|
safeParseJSON as safeParseJSON2
|
|
4600
4629
|
} from "@ai-sdk/provider-utils";
|
|
@@ -4706,7 +4735,7 @@ var XaiVideoModel = class {
|
|
|
4706
4735
|
}
|
|
4707
4736
|
async buildRequestBody(options) {
|
|
4708
4737
|
const warnings = [];
|
|
4709
|
-
const xaiOptions = await
|
|
4738
|
+
const xaiOptions = await parseProviderOptions8({
|
|
4710
4739
|
provider: "xai",
|
|
4711
4740
|
providerOptions: options.providerOptions,
|
|
4712
4741
|
schema: xaiVideoModelOptionsSchema
|
|
@@ -5126,12 +5155,12 @@ import {
|
|
|
5126
5155
|
convertBase64ToUint8Array,
|
|
5127
5156
|
createBinaryResponseHandler as createBinaryResponseHandler2,
|
|
5128
5157
|
createJsonResponseHandler as createJsonResponseHandler7,
|
|
5129
|
-
parseProviderOptions as
|
|
5158
|
+
parseProviderOptions as parseProviderOptions9,
|
|
5130
5159
|
postJsonToApi as postJsonToApi6,
|
|
5131
5160
|
resolve,
|
|
5132
5161
|
serializeModelOptions as serializeModelOptions4,
|
|
5133
|
-
WORKFLOW_DESERIALIZE as
|
|
5134
|
-
WORKFLOW_SERIALIZE as
|
|
5162
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE4,
|
|
5163
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE4
|
|
5135
5164
|
} from "@ai-sdk/provider-utils";
|
|
5136
5165
|
import { z as z23 } from "zod/v4";
|
|
5137
5166
|
|
|
@@ -5196,13 +5225,13 @@ var XaiSpeechModel = class _XaiSpeechModel {
|
|
|
5196
5225
|
this.config = config;
|
|
5197
5226
|
this.specificationVersion = "v4";
|
|
5198
5227
|
}
|
|
5199
|
-
static [
|
|
5228
|
+
static [WORKFLOW_SERIALIZE4](model) {
|
|
5200
5229
|
return serializeModelOptions4({
|
|
5201
5230
|
modelId: model.modelId,
|
|
5202
5231
|
config: model.config
|
|
5203
5232
|
});
|
|
5204
5233
|
}
|
|
5205
|
-
static [
|
|
5234
|
+
static [WORKFLOW_DESERIALIZE4](options) {
|
|
5206
5235
|
return new _XaiSpeechModel(options.modelId, options.config);
|
|
5207
5236
|
}
|
|
5208
5237
|
get provider() {
|
|
@@ -5218,7 +5247,7 @@ var XaiSpeechModel = class _XaiSpeechModel {
|
|
|
5218
5247
|
providerOptions
|
|
5219
5248
|
}) {
|
|
5220
5249
|
const warnings = [];
|
|
5221
|
-
const xaiOptions = await
|
|
5250
|
+
const xaiOptions = await parseProviderOptions9({
|
|
5222
5251
|
provider: "xai",
|
|
5223
5252
|
providerOptions,
|
|
5224
5253
|
schema: xaiSpeechModelOptionsSchema
|
|
@@ -5347,14 +5376,14 @@ import {
|
|
|
5347
5376
|
createJsonResponseHandler as createJsonResponseHandler8,
|
|
5348
5377
|
connectToWebSocket,
|
|
5349
5378
|
mediaTypeToExtension,
|
|
5350
|
-
parseProviderOptions as
|
|
5379
|
+
parseProviderOptions as parseProviderOptions10,
|
|
5351
5380
|
postFormDataToApi as postFormDataToApi3,
|
|
5352
5381
|
safeParseJSON as safeParseJSON3,
|
|
5353
5382
|
serializeModelOptions as serializeModelOptions5,
|
|
5354
5383
|
toWebSocketUrl,
|
|
5355
5384
|
waitForWebSocketBufferDrain,
|
|
5356
|
-
WORKFLOW_DESERIALIZE as
|
|
5357
|
-
WORKFLOW_SERIALIZE as
|
|
5385
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
|
|
5386
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
|
|
5358
5387
|
} from "@ai-sdk/provider-utils";
|
|
5359
5388
|
import { z as z25 } from "zod/v4";
|
|
5360
5389
|
|
|
@@ -5442,13 +5471,13 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
5442
5471
|
this.config = config;
|
|
5443
5472
|
this.specificationVersion = "v4";
|
|
5444
5473
|
}
|
|
5445
|
-
static [
|
|
5474
|
+
static [WORKFLOW_SERIALIZE5](model) {
|
|
5446
5475
|
return serializeModelOptions5({
|
|
5447
5476
|
modelId: model.modelId,
|
|
5448
5477
|
config: model.config
|
|
5449
5478
|
});
|
|
5450
5479
|
}
|
|
5451
|
-
static [
|
|
5480
|
+
static [WORKFLOW_DESERIALIZE5](options) {
|
|
5452
5481
|
return new _XaiTranscriptionModel(options.modelId, options.config);
|
|
5453
5482
|
}
|
|
5454
5483
|
get provider() {
|
|
@@ -5460,7 +5489,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
5460
5489
|
providerOptions
|
|
5461
5490
|
}) {
|
|
5462
5491
|
const warnings = [];
|
|
5463
|
-
const xaiOptions = await
|
|
5492
|
+
const xaiOptions = await parseProviderOptions10({
|
|
5464
5493
|
provider: "xai",
|
|
5465
5494
|
providerOptions,
|
|
5466
5495
|
schema: xaiTranscriptionModelOptionsSchema
|
|
@@ -5537,7 +5566,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
5537
5566
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
5538
5567
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
5539
5568
|
const warnings = [];
|
|
5540
|
-
const xaiOptions = await
|
|
5569
|
+
const xaiOptions = await parseProviderOptions10({
|
|
5541
5570
|
provider: "xai",
|
|
5542
5571
|
providerOptions: options.providerOptions,
|
|
5543
5572
|
schema: xaiTranscriptionModelOptionsSchema
|
|
@@ -5868,7 +5897,7 @@ function createXai(options = {}) {
|
|
|
5868
5897
|
});
|
|
5869
5898
|
};
|
|
5870
5899
|
const createResponsesLanguageModel = (modelId) => {
|
|
5871
|
-
return new
|
|
5900
|
+
return new XaiResponsesLanguageModel(modelId, {
|
|
5872
5901
|
provider: "xai.responses",
|
|
5873
5902
|
baseURL,
|
|
5874
5903
|
headers: getHeaders,
|
|
@@ -5940,6 +5969,16 @@ function createXai(options = {}) {
|
|
|
5940
5969
|
headers: getHeaders,
|
|
5941
5970
|
fetch: options.fetch
|
|
5942
5971
|
});
|
|
5972
|
+
const createBatch = () => new XaiBatch({
|
|
5973
|
+
provider: "xai.batch",
|
|
5974
|
+
config: {
|
|
5975
|
+
provider: "xai.responses",
|
|
5976
|
+
baseURL,
|
|
5977
|
+
headers: getHeaders,
|
|
5978
|
+
generateId,
|
|
5979
|
+
fetch: options.fetch
|
|
5980
|
+
}
|
|
5981
|
+
});
|
|
5943
5982
|
const provider = (modelId) => createResponsesLanguageModel(modelId);
|
|
5944
5983
|
provider.specificationVersion = "v4";
|
|
5945
5984
|
provider.languageModel = createResponsesLanguageModel;
|
|
@@ -5959,6 +5998,7 @@ function createXai(options = {}) {
|
|
|
5959
5998
|
provider.transcriptionModel = createTranscriptionModel;
|
|
5960
5999
|
provider.transcription = createTranscriptionModel;
|
|
5961
6000
|
provider.files = createFiles;
|
|
6001
|
+
provider.experimental_batch = createBatch;
|
|
5962
6002
|
provider.tools = xaiTools;
|
|
5963
6003
|
return provider;
|
|
5964
6004
|
}
|