@ai-sdk/xai 4.0.0-beta.44 → 4.0.0-beta.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/xai",
3
- "version": "4.0.0-beta.44",
3
+ "version": "4.0.0-beta.46",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -29,17 +29,17 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "3.0.0-beta.32",
33
- "@ai-sdk/provider": "4.0.0-beta.12",
34
- "@ai-sdk/provider-utils": "5.0.0-beta.27"
32
+ "@ai-sdk/openai-compatible": "3.0.0-beta.33",
33
+ "@ai-sdk/provider": "4.0.0-beta.13",
34
+ "@ai-sdk/provider-utils": "5.0.0-beta.28"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
38
38
  "tsup": "^8",
39
39
  "typescript": "5.8.3",
40
40
  "zod": "3.25.76",
41
- "@vercel/ai-tsconfig": "0.0.0",
42
- "@ai-sdk/test-server": "2.0.0-beta.1"
41
+ "@ai-sdk/test-server": "2.0.0-beta.2",
42
+ "@vercel/ai-tsconfig": "0.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "zod": "^3.25.76 || ^4.1.8"
@@ -54,7 +54,8 @@
54
54
  "homepage": "https://ai-sdk.dev/docs",
55
55
  "repository": {
56
56
  "type": "git",
57
- "url": "git+https://github.com/vercel/ai.git"
57
+ "url": "https://github.com/vercel/ai",
58
+ "directory": "packages/xai"
58
59
  },
59
60
  "bugs": {
60
61
  "url": "https://github.com/vercel/ai/issues"
@@ -66,9 +66,19 @@ export async function convertToXaiResponsesInput({
66
66
  : `data:${mediaType};base64,${convertToBase64(block.data)}`;
67
67
 
68
68
  contentParts.push({ type: 'input_image', image_url: imageUrl });
69
+ } else if (block.data instanceof URL) {
70
+ // xAI's Responses API accepts non-image documents (PDF, text, CSV, etc.)
71
+ // via `{ type: 'input_file', file_url }`. See
72
+ // https://docs.x.ai/docs/guides/chat-with-files. Inline bytes for
73
+ // non-image files are not supported by xAI; callers must upload via
74
+ // the Files API and pass a provider reference (file_id) instead.
75
+ contentParts.push({
76
+ type: 'input_file',
77
+ file_url: block.data.toString(),
78
+ });
69
79
  } else {
70
80
  throw new UnsupportedFunctionalityError({
71
- functionality: `file part media type ${block.mediaType}`,
81
+ functionality: `file part media type ${block.mediaType} as inline data (xAI Responses requires a URL or a Files API reference for non-image files)`,
72
82
  });
73
83
  }
74
84
  break;
@@ -27,7 +27,8 @@ export type XaiResponsesSystemMessage = {
27
27
  export type XaiResponsesUserMessageContentPart =
28
28
  | { type: 'input_text'; text: string }
29
29
  | { type: 'input_image'; image_url: string }
30
- | { type: 'input_file'; file_id: string };
30
+ | { type: 'input_file'; file_id: string }
31
+ | { type: 'input_file'; file_url: string };
31
32
 
32
33
  export type XaiResponsesUserMessage = {
33
34
  role: 'user';
@@ -80,6 +80,11 @@ export class XaiResponsesLanguageModel implements LanguageModelV4 {
80
80
 
81
81
  readonly supportedUrls: Record<string, RegExp[]> = {
82
82
  'image/*': [/^https?:\/\/.*$/],
83
+ // xAI's Responses API accepts non-image documents (PDF, plain text, CSV, etc.) as
84
+ // `{ type: 'input_file', file_url }`. Keeping these URLs intact here lets them pass
85
+ // through to the converter instead of being downloaded to bytes by the SDK.
86
+ 'application/pdf': [/^https?:\/\/.*$/],
87
+ 'text/*': [/^https?:\/\/.*$/],
83
88
  };
84
89
 
85
90
  private async getArgs({