🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ai-sdk/xai

Package Overview
Dependencies
Maintainers
3
Versions
465
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/xai - npm Package Compare versions

Comparing version
3.0.105
to
3.0.106
+11
-0
CHANGELOG.md
# @ai-sdk/xai
## 3.0.106
### Patch Changes
- e1af05f: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
- 1ce0d1c: feat (provider/xai): add grok-4.5 model id
- Updated dependencies [e1af05f]
- @ai-sdk/provider@3.0.14
- @ai-sdk/openai-compatible@2.0.59
- @ai-sdk/provider-utils@4.0.38
## 3.0.105

@@ -4,0 +15,0 @@

+2
-2

@@ -6,3 +6,3 @@ import { z } from 'zod/v4';

type XaiChatModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
type XaiChatModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
declare const xaiLanguageModelChatOptions: z.ZodObject<{

@@ -76,3 +76,3 @@ reasoningEffort: z.ZodOptional<z.ZodEnum<{

type XaiResponsesModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
type XaiResponsesModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
/**

@@ -79,0 +79,0 @@ * @see https://docs.x.ai/docs/api-reference#create-new-response

@@ -6,3 +6,3 @@ import { z } from 'zod/v4';

type XaiChatModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
type XaiChatModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
declare const xaiLanguageModelChatOptions: z.ZodObject<{

@@ -76,3 +76,3 @@ reasoningEffort: z.ZodOptional<z.ZodEnum<{

type XaiResponsesModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
type XaiResponsesModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
/**

@@ -79,0 +79,0 @@ * @see https://docs.x.ai/docs/api-reference#create-new-response

{
"name": "@ai-sdk/xai",
"version": "3.0.105",
"version": "3.0.106",
"license": "Apache-2.0",

@@ -32,5 +32,5 @@ "sideEffects": false,

"dependencies": {
"@ai-sdk/openai-compatible": "2.0.58",
"@ai-sdk/provider-utils": "4.0.37",
"@ai-sdk/provider": "3.0.13"
"@ai-sdk/openai-compatible": "2.0.59",
"@ai-sdk/provider-utils": "4.0.38",
"@ai-sdk/provider": "3.0.14"
},

@@ -37,0 +37,0 @@ "devDependencies": {

import { z } from 'zod/v4';
export type XaiResponsesModelId =
| 'grok-4.5'
| 'grok-4.3'

@@ -5,0 +6,0 @@ | 'grok-4.20-0309-reasoning'

@@ -5,2 +5,3 @@ import { z } from 'zod/v4';

export type XaiChatModelId =
| 'grok-4.5'
| 'grok-4.3'

@@ -7,0 +8,0 @@ | 'grok-4.20-0309-reasoning'

@@ -65,2 +65,10 @@ import {

function getTopLevelMediaType(mediaType: string): string {
const slashIndex = mediaType.indexOf('/');
return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
}
const isVideoFile = (file: Experimental_VideoModelV3File): boolean =>
file.mediaType != null && getTopLevelMediaType(file.mediaType) === 'video';
function fileToXaiImageUrl(file: Experimental_VideoModelV3File): string {

@@ -75,3 +83,3 @@ if (file.type === 'url') {

: convertUint8ArrayToBase64(file.data);
return `data:${file.mediaType ?? 'image/png'};base64,${base64Data}`;
return `data:${file.mediaType};base64,${base64Data}`;
}

@@ -81,8 +89,26 @@

// `inputReferences` win over the legacy `referenceImageUrls` provider option.
// Video references are not supported for reference-to-video and are skipped
// with a warning.
function resolveReferenceImages(
options: XaiVideoDoGenerateOptions,
xaiOptions: XaiParsedVideoModelOptions | undefined,
warnings: SharedV3Warning[],
): Array<{ url: string }> | undefined {
if (options.inputReferences != null && options.inputReferences.length > 0) {
return options.inputReferences.map(reference => ({
const imageReferences = options.inputReferences.filter(reference => {
if (isVideoFile(reference)) {
warnings.push({
type: 'unsupported',
feature: 'inputReferences',
details:
'xAI reference-to-video accepts image references only. The video ' +
'reference was ignored. Use providerOptions.xai.mode ' +
'"extend-video" to continue from a video.',
});
return false;
}
return true;
});
return imageReferences.map(reference => ({
url: fileToXaiImageUrl(reference),

@@ -284,14 +310,30 @@ }));

if (startImage != null) {
body.image = { url: fileToXaiImageUrl(startImage) };
if (isVideoFile(startImage)) {
const fromFrameImages = getFirstFrameImage(options) != null;
warnings.push({
type: 'unsupported',
feature: fromFrameImages ? 'frameImages' : 'image',
details:
'xAI does not accept a video as a start/frame image. The video ' +
'was ignored. Use providerOptions.xai.mode "extend-video" to ' +
'continue from a video instead.',
});
} else {
body.image = { url: fileToXaiImageUrl(startImage) };
}
}
// xAI has no first-last-frame interpolation; warn and ignore last_frame.
if (getLastFrameImage(options) != null) {
const lastFrameImage = getLastFrameImage(options);
if (lastFrameImage != null) {
warnings.push({
type: 'unsupported',
feature: 'frameImages',
details:
'xAI video models do not support last_frame. Use ' +
'providerOptions.xai.mode "extend-video" to continue from a ' +
"video's last frame. The last frame image was ignored.",
details: isVideoFile(lastFrameImage)
? 'xAI does not accept a video as a start/frame image. The video ' +
'last frame was ignored. Use providerOptions.xai.mode ' +
'"extend-video" to continue from a video instead.'
: 'xAI video models do not support last_frame. Use ' +
'providerOptions.xai.mode "extend-video" to continue from a ' +
"video's last frame. The last frame image was ignored.",
});

@@ -302,3 +344,7 @@ }

if (hasReferenceImages) {
const referenceImages = resolveReferenceImages(options, xaiOptions);
const referenceImages = resolveReferenceImages(
options,
xaiOptions,
warnings,
);
if (referenceImages != null) {

@@ -305,0 +351,0 @@ body.reference_images = referenceImages;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet