| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- diff --git a/dist/index.d.mts b/dist/index.d.mts
- index 266c5ffdd9ee74ff95908ce90858ee4369d4e4ae..6ac6e2873b7681ac632c903694aa38c7b09773fa 100644
- --- a/dist/index.d.mts
- +++ b/dist/index.d.mts
- @@ -5,12 +5,7 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
-
- 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 & {});
- declare const xaiLanguageModelChatOptions: z.ZodObject<{
- - reasoningEffort: z.ZodOptional<z.ZodEnum<{
- - none: "none";
- - low: "low";
- - medium: "medium";
- - high: "high";
- - }>>;
- + reasoningEffort: z.ZodOptional<z.ZodString>;
- logprobs: z.ZodOptional<z.ZodBoolean>;
- topLogprobs: z.ZodOptional<z.ZodNumber>;
- parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
- @@ -68,16 +63,12 @@ type XaiResponsesModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-
- * @see https://docs.x.ai/docs/api-reference#create-new-response
- */
- declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
- - reasoningEffort: z.ZodOptional<z.ZodEnum<{
- - none: "none";
- - low: "low";
- - medium: "medium";
- - high: "high";
- - }>>;
- + reasoningEffort: z.ZodOptional<z.ZodString>;
- logprobs: z.ZodOptional<z.ZodBoolean>;
- topLogprobs: z.ZodOptional<z.ZodNumber>;
- store: z.ZodOptional<z.ZodBoolean>;
- previousResponseId: z.ZodOptional<z.ZodString>;
- + promptCacheKey: z.ZodOptional<z.ZodString>;
- include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
- "file_search_call.results": "file_search_call.results";
- }>>>>;
- diff --git a/dist/index.d.ts b/dist/index.d.ts
- index 266c5ffdd9ee74ff95908ce90858ee4369d4e4ae..6ac6e2873b7681ac632c903694aa38c7b09773fa 100644
- --- a/dist/index.d.ts
- +++ b/dist/index.d.ts
- @@ -5,12 +5,7 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
-
- 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 & {});
- declare const xaiLanguageModelChatOptions: z.ZodObject<{
- - reasoningEffort: z.ZodOptional<z.ZodEnum<{
- - none: "none";
- - low: "low";
- - medium: "medium";
- - high: "high";
- - }>>;
- + reasoningEffort: z.ZodOptional<z.ZodString>;
- logprobs: z.ZodOptional<z.ZodBoolean>;
- topLogprobs: z.ZodOptional<z.ZodNumber>;
- parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
- @@ -68,16 +63,12 @@ type XaiResponsesModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-
- * @see https://docs.x.ai/docs/api-reference#create-new-response
- */
- declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
- - reasoningEffort: z.ZodOptional<z.ZodEnum<{
- - none: "none";
- - low: "low";
- - medium: "medium";
- - high: "high";
- - }>>;
- + reasoningEffort: z.ZodOptional<z.ZodString>;
- logprobs: z.ZodOptional<z.ZodBoolean>;
- topLogprobs: z.ZodOptional<z.ZodNumber>;
- store: z.ZodOptional<z.ZodBoolean>;
- previousResponseId: z.ZodOptional<z.ZodString>;
- + promptCacheKey: z.ZodOptional<z.ZodString>;
- include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
- "file_search_call.results": "file_search_call.results";
- }>>>>;
- diff --git a/dist/index.js b/dist/index.js
- index 717b74538f5c8f0d6ab1475ebb2a84a47ccd3950..0fd8f0d1cae951cd24401034a9c1dba762d9fd84 100644
- --- a/dist/index.js
- +++ b/dist/index.js
- @@ -246,7 +246,7 @@ var searchSourceSchema = import_v4.z.discriminatedUnion("type", [
- rssSourceSchema
- ]);
- var xaiLanguageModelChatOptions = import_v4.z.object({
- - reasoningEffort: import_v4.z.enum(["none", "low", "medium", "high"]).optional(),
- + reasoningEffort: import_v4.z.string().optional(),
- logprobs: import_v4.z.boolean().optional(),
- topLogprobs: import_v4.z.number().int().min(0).max(8).optional(),
- /**
- @@ -1119,6 +1119,14 @@ async function convertToXaiResponsesInput({
- type: "input_file",
- file_url: block.data.toString()
- });
- + } else if (block.mediaType === "application/pdf") {
- + contentParts.push({
- + type: "input_file",
- + ...typeof block.data === "string" && block.data.startsWith("file-") ? { file_id: block.data } : {
- + filename: block.filename ?? "file",
- + file_data: `data:application/pdf;base64,${(0, import_provider_utils5.convertToBase64)(block.data)}`
- + }
- + });
- } else {
- throw new import_provider4.UnsupportedFunctionalityError({
- functionality: `file part media type ${block.mediaType} as inline data (xAI Responses requires a URL or a Files API reference for non-image files)`
- @@ -1746,7 +1754,7 @@ var xaiLanguageModelResponsesOptions = import_v47.z.object({
- * tokens), `medium` and `high` (uses more reasoning tokens). Not all models
- * support reasoning effort; see xAI's docs for the values each model accepts.
- */
- - reasoningEffort: import_v47.z.enum(["none", "low", "medium", "high"]).optional(),
- + reasoningEffort: import_v47.z.string().optional(),
- logprobs: import_v47.z.boolean().optional(),
- topLogprobs: import_v47.z.number().int().min(0).max(8).optional(),
- /**
- @@ -1760,6 +1768,10 @@ var xaiLanguageModelResponsesOptions = import_v47.z.object({
- * The ID of the previous response from the model.
- */
- previousResponseId: import_v47.z.string().optional(),
- + /**
- + * A stable key used by xAI to improve prompt cache routing.
- + */
- + promptCacheKey: import_v47.z.string().optional(),
- /**
- * Specify additional output data to include in the model response.
- * Example values: 'file_search_call.results'.
- @@ -2165,6 +2177,9 @@ var XaiResponsesLanguageModel = class {
- },
- ...options.previousResponseId != null && {
- previous_response_id: options.previousResponseId
- + },
- + ...options.promptCacheKey != null && {
- + prompt_cache_key: options.promptCacheKey
- }
- };
- if (xaiTools2 && xaiTools2.length > 0) {
- diff --git a/dist/index.mjs b/dist/index.mjs
- index a26af109585fc2bd3053b320142aa869c06d36f4..5faca56477b4e55a87f6f57850731c7d3e1721a5 100644
- --- a/dist/index.mjs
- +++ b/dist/index.mjs
- @@ -230,7 +230,7 @@ var searchSourceSchema = z.discriminatedUnion("type", [
- rssSourceSchema
- ]);
- var xaiLanguageModelChatOptions = z.object({
- - reasoningEffort: z.enum(["none", "low", "medium", "high"]).optional(),
- + reasoningEffort: z.string().optional(),
- logprobs: z.boolean().optional(),
- topLogprobs: z.number().int().min(0).max(8).optional(),
- /**
- @@ -1122,6 +1122,14 @@ async function convertToXaiResponsesInput({
- type: "input_file",
- file_url: block.data.toString()
- });
- + } else if (block.mediaType === "application/pdf") {
- + contentParts.push({
- + type: "input_file",
- + ...typeof block.data === "string" && block.data.startsWith("file-") ? { file_id: block.data } : {
- + filename: block.filename ?? "file",
- + file_data: `data:application/pdf;base64,${convertToBase642(block.data)}`
- + }
- + });
- } else {
- throw new UnsupportedFunctionalityError3({
- functionality: `file part media type ${block.mediaType} as inline data (xAI Responses requires a URL or a Files API reference for non-image files)`
- @@ -1749,7 +1757,7 @@ var xaiLanguageModelResponsesOptions = z7.object({
- * tokens), `medium` and `high` (uses more reasoning tokens). Not all models
- * support reasoning effort; see xAI's docs for the values each model accepts.
- */
- - reasoningEffort: z7.enum(["none", "low", "medium", "high"]).optional(),
- + reasoningEffort: z7.string().optional(),
- logprobs: z7.boolean().optional(),
- topLogprobs: z7.number().int().min(0).max(8).optional(),
- /**
- @@ -1763,6 +1771,10 @@ var xaiLanguageModelResponsesOptions = z7.object({
- * The ID of the previous response from the model.
- */
- previousResponseId: z7.string().optional(),
- + /**
- + * A stable key used by xAI to improve prompt cache routing.
- + */
- + promptCacheKey: z7.string().optional(),
- /**
- * Specify additional output data to include in the model response.
- * Example values: 'file_search_call.results'.
- @@ -2186,6 +2198,9 @@ var XaiResponsesLanguageModel = class {
- },
- ...options.previousResponseId != null && {
- previous_response_id: options.previousResponseId
- + },
- + ...options.promptCacheKey != null && {
- + prompt_cache_key: options.promptCacheKey
- }
- };
- if (xaiTools2 && xaiTools2.length > 0) {
- diff --git a/src/responses/convert-to-xai-responses-input.ts b/src/responses/convert-to-xai-responses-input.ts
- index 9a3712990cf646a6f7ba757d3f2893a3c37c6ef9..b018a9b95eb21e6c12794e6bddb3d953f40441e5 100644
- --- a/src/responses/convert-to-xai-responses-input.ts
- +++ b/src/responses/convert-to-xai-responses-input.ts
- @@ -64,6 +64,17 @@ export async function convertToXaiResponsesInput({
- type: 'input_file',
- file_url: block.data.toString(),
- });
- + } else if (block.mediaType === 'application/pdf') {
- + contentParts.push({
- + type: 'input_file',
- + ...(typeof block.data === 'string' &&
- + block.data.startsWith('file-')
- + ? { file_id: block.data }
- + : {
- + filename: block.filename ?? 'file',
- + file_data: `data:application/pdf;base64,${convertToBase64(block.data)}`,
- + }),
- + });
- } else {
- throw new UnsupportedFunctionalityError({
- functionality: `file part media type ${block.mediaType} as inline data (xAI Responses requires a URL or a Files API reference for non-image files)`,
- diff --git a/src/responses/xai-responses-api.ts b/src/responses/xai-responses-api.ts
- index 70483ea4f7c340b84c23766ac1d1df21e052842b..4b4d052860caa019556151e9e46dbfda8dfb18a9 100644
- --- a/src/responses/xai-responses-api.ts
- +++ b/src/responses/xai-responses-api.ts
- @@ -27,7 +27,13 @@ export type XaiResponsesSystemMessage = {
- export type XaiResponsesUserMessageContentPart =
- | { type: 'input_text'; text: string }
- | { type: 'input_image'; image_url: string }
- - | { type: 'input_file'; file_url: string };
- + | {
- + type: 'input_file';
- + file_url?: string;
- + file_id?: string;
- + file_data?: string;
- + filename?: string;
- + };
-
- export type XaiResponsesUserMessage = {
- role: 'user';
- diff --git a/src/responses/xai-responses-language-model.ts b/src/responses/xai-responses-language-model.ts
- index f90df62eb9a30154388b1390e9f3acc3ccc022bf..00e61cba6cf048ae0045be692f33cb7e1e6a1188 100644
- --- a/src/responses/xai-responses-language-model.ts
- +++ b/src/responses/xai-responses-language-model.ts
- @@ -182,6 +182,9 @@ export class XaiResponsesLanguageModel implements LanguageModelV3 {
- ...(options.previousResponseId != null && {
- previous_response_id: options.previousResponseId,
- }),
- + ...(options.promptCacheKey != null && {
- + prompt_cache_key: options.promptCacheKey,
- + }),
- };
-
- if (xaiTools && xaiTools.length > 0) {
- diff --git a/src/responses/xai-responses-options.ts b/src/responses/xai-responses-options.ts
- index f8e96c061bf8793a402ababb8cad65bb2ad6aead..2a39a36221ab23ea0000bff1d7854c5bce3f9d74 100644
- --- a/src/responses/xai-responses-options.ts
- +++ b/src/responses/xai-responses-options.ts
- @@ -18,7 +18,7 @@ export const xaiLanguageModelResponsesOptions = z.object({
- * tokens), `medium` and `high` (uses more reasoning tokens). Not all models
- * support reasoning effort; see xAI's docs for the values each model accepts.
- */
- - reasoningEffort: z.enum(['none', 'low', 'medium', 'high']).optional(),
- + reasoningEffort: z.string().optional(),
- logprobs: z.boolean().optional(),
- topLogprobs: z.number().int().min(0).max(8).optional(),
- /**
- @@ -32,6 +32,10 @@ export const xaiLanguageModelResponsesOptions = z.object({
- * The ID of the previous response from the model.
- */
- previousResponseId: z.string().optional(),
- + /**
- + * A stable key used by xAI to improve prompt cache routing.
- + */
- + promptCacheKey: z.string().optional(),
- /**
- * Specify additional output data to include in the model response.
- * Example values: 'file_search_call.results'.
- diff --git a/src/xai-chat-options.ts b/src/xai-chat-options.ts
- index d70a72a9fa01da2c711c291da5ce949efbde60b5..fd6b1ae025388b614f08b620244be553199479ca 100644
- --- a/src/xai-chat-options.ts
- +++ b/src/xai-chat-options.ts
- @@ -51,7 +51,7 @@ const searchSourceSchema = z.discriminatedUnion('type', [
-
- // xai-specific provider options
- export const xaiLanguageModelChatOptions = z.object({
- - reasoningEffort: z.enum(['none', 'low', 'medium', 'high']).optional(),
- + reasoningEffort: z.string().optional(),
- logprobs: z.boolean().optional(),
- topLogprobs: z.number().int().min(0).max(8).optional(),
-
|