@ai-sdk/xai 4.0.44 → 4.0.47
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 +26 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1112 -633
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +60 -0
- package/package.json +2 -2
- package/src/responses/xai-responses-api.ts +22 -18
- package/src/responses/xai-responses-batch.ts +558 -0
- package/src/responses/xai-responses-language-model.ts +109 -3
- package/src/xai-chat-language-model.ts +29 -22
- package/src/xai-provider.ts +6 -5
- package/src/xai-video-model.ts +12 -1
package/dist/index.js
CHANGED
|
@@ -969,19 +969,20 @@ var xaiUsageSchema = z4.object({
|
|
|
969
969
|
prompt_tokens: z4.number(),
|
|
970
970
|
completion_tokens: z4.number(),
|
|
971
971
|
total_tokens: z4.number(),
|
|
972
|
+
cost_in_usd_ticks: z4.number().nullish(),
|
|
972
973
|
prompt_tokens_details: z4.object({
|
|
973
974
|
text_tokens: z4.number().nullish(),
|
|
974
975
|
audio_tokens: z4.number().nullish(),
|
|
975
976
|
image_tokens: z4.number().nullish(),
|
|
976
977
|
cached_tokens: z4.number().nullish()
|
|
977
|
-
}).nullish(),
|
|
978
|
+
}).catchall(z4.json()).nullish(),
|
|
978
979
|
completion_tokens_details: z4.object({
|
|
979
980
|
reasoning_tokens: z4.number().nullish(),
|
|
980
981
|
audio_tokens: z4.number().nullish(),
|
|
981
982
|
accepted_prediction_tokens: z4.number().nullish(),
|
|
982
983
|
rejected_prediction_tokens: z4.number().nullish()
|
|
983
|
-
}).nullish()
|
|
984
|
-
});
|
|
984
|
+
}).catchall(z4.json()).nullish()
|
|
985
|
+
}).catchall(z4.json());
|
|
985
986
|
var xaiChatResponseSchema = z4.object({
|
|
986
987
|
id: z4.string().nullish(),
|
|
987
988
|
created: z4.number().nullish(),
|
|
@@ -1238,11 +1239,50 @@ var xaiImageResponseSchema = z6.object({
|
|
|
1238
1239
|
}).nullish()
|
|
1239
1240
|
});
|
|
1240
1241
|
|
|
1242
|
+
// src/responses/xai-responses-batch.ts
|
|
1243
|
+
import {
|
|
1244
|
+
InvalidArgumentError
|
|
1245
|
+
} from "@ai-sdk/provider";
|
|
1246
|
+
import {
|
|
1247
|
+
combineHeaders as combineHeaders4,
|
|
1248
|
+
convertAsyncIteratorToReadableStream,
|
|
1249
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1250
|
+
createNullLanguageModelUsage,
|
|
1251
|
+
getFromApi as getFromApi2,
|
|
1252
|
+
lazySchema as lazySchema7,
|
|
1253
|
+
normalizeBatchRequestCounts,
|
|
1254
|
+
postFormDataToApi,
|
|
1255
|
+
postJsonToApi as postJsonToApi4,
|
|
1256
|
+
safeValidateTypes,
|
|
1257
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE4,
|
|
1258
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE4,
|
|
1259
|
+
zodSchema as zodSchema7
|
|
1260
|
+
} from "@ai-sdk/provider-utils";
|
|
1261
|
+
import { z as z15 } from "zod/v4";
|
|
1262
|
+
|
|
1263
|
+
// src/files/xai-files-api.ts
|
|
1264
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
1265
|
+
import { z as z7 } from "zod/v4";
|
|
1266
|
+
var xaiFilesResponseSchema = lazySchema(
|
|
1267
|
+
() => zodSchema(
|
|
1268
|
+
z7.object({
|
|
1269
|
+
id: z7.string(),
|
|
1270
|
+
object: z7.string().nullish(),
|
|
1271
|
+
bytes: z7.number().nullish(),
|
|
1272
|
+
created_at: z7.number().nullish(),
|
|
1273
|
+
filename: z7.string().nullish(),
|
|
1274
|
+
purpose: z7.string().nullish(),
|
|
1275
|
+
status: z7.string().nullish()
|
|
1276
|
+
})
|
|
1277
|
+
)
|
|
1278
|
+
);
|
|
1279
|
+
|
|
1241
1280
|
// src/responses/xai-responses-language-model.ts
|
|
1242
1281
|
import {
|
|
1243
1282
|
combineHeaders as combineHeaders3,
|
|
1244
1283
|
createEventSourceResponseHandler as createEventSourceResponseHandler2,
|
|
1245
1284
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1285
|
+
createProviderStreamError,
|
|
1246
1286
|
isCustomReasoning as isCustomReasoning2,
|
|
1247
1287
|
mapReasoningToProviderEffort as mapReasoningToProviderEffort2,
|
|
1248
1288
|
parseProviderOptions as parseProviderOptions5,
|
|
@@ -1542,461 +1582,461 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
1542
1582
|
}
|
|
1543
1583
|
|
|
1544
1584
|
// src/responses/xai-responses-api.ts
|
|
1545
|
-
import { z as
|
|
1546
|
-
var annotationSchema =
|
|
1547
|
-
|
|
1548
|
-
type:
|
|
1549
|
-
url:
|
|
1550
|
-
title:
|
|
1585
|
+
import { z as z8 } from "zod/v4";
|
|
1586
|
+
var annotationSchema = z8.union([
|
|
1587
|
+
z8.object({
|
|
1588
|
+
type: z8.literal("url_citation"),
|
|
1589
|
+
url: z8.string(),
|
|
1590
|
+
title: z8.string().optional()
|
|
1551
1591
|
}),
|
|
1552
|
-
|
|
1553
|
-
type:
|
|
1592
|
+
z8.object({
|
|
1593
|
+
type: z8.string()
|
|
1554
1594
|
})
|
|
1555
1595
|
]);
|
|
1556
|
-
var messageContentPartSchema =
|
|
1557
|
-
type:
|
|
1558
|
-
text:
|
|
1559
|
-
logprobs:
|
|
1560
|
-
annotations:
|
|
1596
|
+
var messageContentPartSchema = z8.object({
|
|
1597
|
+
type: z8.string(),
|
|
1598
|
+
text: z8.string().optional(),
|
|
1599
|
+
logprobs: z8.array(z8.any()).optional(),
|
|
1600
|
+
annotations: z8.array(annotationSchema).optional()
|
|
1561
1601
|
});
|
|
1562
|
-
var reasoningSummaryPartSchema =
|
|
1563
|
-
type:
|
|
1564
|
-
text:
|
|
1602
|
+
var reasoningSummaryPartSchema = z8.object({
|
|
1603
|
+
type: z8.string(),
|
|
1604
|
+
text: z8.string()
|
|
1565
1605
|
});
|
|
1566
|
-
var toolCallSchema =
|
|
1567
|
-
name:
|
|
1568
|
-
arguments:
|
|
1569
|
-
input:
|
|
1570
|
-
call_id:
|
|
1571
|
-
id:
|
|
1572
|
-
status:
|
|
1573
|
-
action:
|
|
1606
|
+
var toolCallSchema = z8.object({
|
|
1607
|
+
name: z8.string().optional(),
|
|
1608
|
+
arguments: z8.string().optional(),
|
|
1609
|
+
input: z8.string().optional(),
|
|
1610
|
+
call_id: z8.string().optional(),
|
|
1611
|
+
id: z8.string(),
|
|
1612
|
+
status: z8.string(),
|
|
1613
|
+
action: z8.any().optional()
|
|
1574
1614
|
});
|
|
1575
|
-
var mcpCallSchema =
|
|
1576
|
-
name:
|
|
1577
|
-
arguments:
|
|
1578
|
-
output:
|
|
1579
|
-
error:
|
|
1580
|
-
id:
|
|
1581
|
-
status:
|
|
1582
|
-
server_label:
|
|
1615
|
+
var mcpCallSchema = z8.object({
|
|
1616
|
+
name: z8.string().optional(),
|
|
1617
|
+
arguments: z8.string().optional(),
|
|
1618
|
+
output: z8.string().optional(),
|
|
1619
|
+
error: z8.string().optional(),
|
|
1620
|
+
id: z8.string(),
|
|
1621
|
+
status: z8.string(),
|
|
1622
|
+
server_label: z8.string().optional()
|
|
1583
1623
|
});
|
|
1584
|
-
var outputItemSchema =
|
|
1585
|
-
|
|
1586
|
-
type:
|
|
1624
|
+
var outputItemSchema = z8.discriminatedUnion("type", [
|
|
1625
|
+
z8.object({
|
|
1626
|
+
type: z8.literal("web_search_call"),
|
|
1587
1627
|
...toolCallSchema.shape
|
|
1588
1628
|
}),
|
|
1589
|
-
|
|
1590
|
-
type:
|
|
1629
|
+
z8.object({
|
|
1630
|
+
type: z8.literal("x_search_call"),
|
|
1591
1631
|
...toolCallSchema.shape
|
|
1592
1632
|
}),
|
|
1593
|
-
|
|
1594
|
-
type:
|
|
1633
|
+
z8.object({
|
|
1634
|
+
type: z8.literal("code_interpreter_call"),
|
|
1595
1635
|
...toolCallSchema.shape
|
|
1596
1636
|
}),
|
|
1597
|
-
|
|
1598
|
-
type:
|
|
1637
|
+
z8.object({
|
|
1638
|
+
type: z8.literal("code_execution_call"),
|
|
1599
1639
|
...toolCallSchema.shape
|
|
1600
1640
|
}),
|
|
1601
|
-
|
|
1602
|
-
type:
|
|
1641
|
+
z8.object({
|
|
1642
|
+
type: z8.literal("view_image_call"),
|
|
1603
1643
|
...toolCallSchema.shape
|
|
1604
1644
|
}),
|
|
1605
|
-
|
|
1606
|
-
type:
|
|
1645
|
+
z8.object({
|
|
1646
|
+
type: z8.literal("view_x_video_call"),
|
|
1607
1647
|
...toolCallSchema.shape
|
|
1608
1648
|
}),
|
|
1609
|
-
|
|
1610
|
-
type:
|
|
1611
|
-
id:
|
|
1612
|
-
status:
|
|
1613
|
-
queries:
|
|
1614
|
-
results:
|
|
1615
|
-
|
|
1616
|
-
file_id:
|
|
1617
|
-
filename:
|
|
1618
|
-
score:
|
|
1619
|
-
text:
|
|
1649
|
+
z8.object({
|
|
1650
|
+
type: z8.literal("file_search_call"),
|
|
1651
|
+
id: z8.string(),
|
|
1652
|
+
status: z8.string(),
|
|
1653
|
+
queries: z8.array(z8.string()).optional(),
|
|
1654
|
+
results: z8.array(
|
|
1655
|
+
z8.object({
|
|
1656
|
+
file_id: z8.string(),
|
|
1657
|
+
filename: z8.string(),
|
|
1658
|
+
score: z8.number(),
|
|
1659
|
+
text: z8.string()
|
|
1620
1660
|
})
|
|
1621
1661
|
).nullish()
|
|
1622
1662
|
}),
|
|
1623
|
-
|
|
1624
|
-
type:
|
|
1625
|
-
id:
|
|
1626
|
-
status:
|
|
1627
|
-
prompt:
|
|
1628
|
-
result:
|
|
1663
|
+
z8.object({
|
|
1664
|
+
type: z8.literal("image_generation_call"),
|
|
1665
|
+
id: z8.string(),
|
|
1666
|
+
status: z8.string(),
|
|
1667
|
+
prompt: z8.string().nullish(),
|
|
1668
|
+
result: z8.string().nullish()
|
|
1629
1669
|
}),
|
|
1630
|
-
|
|
1631
|
-
type:
|
|
1670
|
+
z8.object({
|
|
1671
|
+
type: z8.literal("custom_tool_call"),
|
|
1632
1672
|
...toolCallSchema.shape
|
|
1633
1673
|
}),
|
|
1634
|
-
|
|
1635
|
-
type:
|
|
1674
|
+
z8.object({
|
|
1675
|
+
type: z8.literal("mcp_call"),
|
|
1636
1676
|
...mcpCallSchema.shape
|
|
1637
1677
|
}),
|
|
1638
|
-
|
|
1639
|
-
type:
|
|
1640
|
-
role:
|
|
1641
|
-
content:
|
|
1642
|
-
id:
|
|
1643
|
-
status:
|
|
1678
|
+
z8.object({
|
|
1679
|
+
type: z8.literal("message"),
|
|
1680
|
+
role: z8.string(),
|
|
1681
|
+
content: z8.array(messageContentPartSchema),
|
|
1682
|
+
id: z8.string(),
|
|
1683
|
+
status: z8.string()
|
|
1644
1684
|
}),
|
|
1645
|
-
|
|
1646
|
-
type:
|
|
1647
|
-
name:
|
|
1648
|
-
arguments:
|
|
1649
|
-
call_id:
|
|
1650
|
-
id:
|
|
1685
|
+
z8.object({
|
|
1686
|
+
type: z8.literal("function_call"),
|
|
1687
|
+
name: z8.string(),
|
|
1688
|
+
arguments: z8.string(),
|
|
1689
|
+
call_id: z8.string(),
|
|
1690
|
+
id: z8.string()
|
|
1651
1691
|
}),
|
|
1652
|
-
|
|
1653
|
-
type:
|
|
1654
|
-
id:
|
|
1655
|
-
summary:
|
|
1656
|
-
content:
|
|
1657
|
-
status:
|
|
1658
|
-
encrypted_content:
|
|
1692
|
+
z8.object({
|
|
1693
|
+
type: z8.literal("reasoning"),
|
|
1694
|
+
id: z8.string(),
|
|
1695
|
+
summary: z8.array(reasoningSummaryPartSchema),
|
|
1696
|
+
content: z8.array(z8.object({ type: z8.string(), text: z8.string() })).nullish(),
|
|
1697
|
+
status: z8.string(),
|
|
1698
|
+
encrypted_content: z8.string().nullish()
|
|
1659
1699
|
})
|
|
1660
1700
|
]);
|
|
1661
|
-
var xaiResponsesUsageSchema =
|
|
1662
|
-
input_tokens:
|
|
1663
|
-
output_tokens:
|
|
1664
|
-
total_tokens:
|
|
1665
|
-
input_tokens_details:
|
|
1666
|
-
cached_tokens:
|
|
1667
|
-
}).optional(),
|
|
1668
|
-
output_tokens_details:
|
|
1669
|
-
reasoning_tokens:
|
|
1670
|
-
}).optional(),
|
|
1671
|
-
num_sources_used:
|
|
1672
|
-
num_server_side_tools_used:
|
|
1673
|
-
cost_in_usd_ticks:
|
|
1674
|
-
});
|
|
1675
|
-
var xaiResponsesResponseSchema =
|
|
1676
|
-
id:
|
|
1677
|
-
created_at:
|
|
1678
|
-
model:
|
|
1679
|
-
object:
|
|
1680
|
-
output:
|
|
1701
|
+
var xaiResponsesUsageSchema = z8.object({
|
|
1702
|
+
input_tokens: z8.number(),
|
|
1703
|
+
output_tokens: z8.number(),
|
|
1704
|
+
total_tokens: z8.number().optional(),
|
|
1705
|
+
input_tokens_details: z8.object({
|
|
1706
|
+
cached_tokens: z8.number().optional()
|
|
1707
|
+
}).catchall(z8.json()).optional(),
|
|
1708
|
+
output_tokens_details: z8.object({
|
|
1709
|
+
reasoning_tokens: z8.number().optional()
|
|
1710
|
+
}).catchall(z8.json()).optional(),
|
|
1711
|
+
num_sources_used: z8.number().optional(),
|
|
1712
|
+
num_server_side_tools_used: z8.number().optional(),
|
|
1713
|
+
cost_in_usd_ticks: z8.number().nullish()
|
|
1714
|
+
}).catchall(z8.json());
|
|
1715
|
+
var xaiResponsesResponseSchema = z8.object({
|
|
1716
|
+
id: z8.string().nullish(),
|
|
1717
|
+
created_at: z8.number().nullish(),
|
|
1718
|
+
model: z8.string().nullish(),
|
|
1719
|
+
object: z8.literal("response"),
|
|
1720
|
+
output: z8.array(outputItemSchema),
|
|
1681
1721
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1682
|
-
status:
|
|
1683
|
-
service_tier:
|
|
1722
|
+
status: z8.string(),
|
|
1723
|
+
service_tier: z8.string().nullish()
|
|
1684
1724
|
});
|
|
1685
|
-
var xaiResponsesChunkSchema =
|
|
1686
|
-
|
|
1687
|
-
type:
|
|
1725
|
+
var xaiResponsesChunkSchema = z8.union([
|
|
1726
|
+
z8.object({
|
|
1727
|
+
type: z8.literal("response.created"),
|
|
1688
1728
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1689
1729
|
}),
|
|
1690
|
-
|
|
1691
|
-
type:
|
|
1730
|
+
z8.object({
|
|
1731
|
+
type: z8.literal("response.in_progress"),
|
|
1692
1732
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1693
1733
|
}),
|
|
1694
|
-
|
|
1695
|
-
type:
|
|
1734
|
+
z8.object({
|
|
1735
|
+
type: z8.literal("response.output_item.added"),
|
|
1696
1736
|
item: outputItemSchema,
|
|
1697
|
-
output_index:
|
|
1737
|
+
output_index: z8.number()
|
|
1698
1738
|
}),
|
|
1699
|
-
|
|
1700
|
-
type:
|
|
1739
|
+
z8.object({
|
|
1740
|
+
type: z8.literal("response.output_item.done"),
|
|
1701
1741
|
item: outputItemSchema,
|
|
1702
|
-
output_index:
|
|
1742
|
+
output_index: z8.number()
|
|
1703
1743
|
}),
|
|
1704
|
-
|
|
1705
|
-
type:
|
|
1706
|
-
item_id:
|
|
1707
|
-
output_index:
|
|
1708
|
-
content_index:
|
|
1744
|
+
z8.object({
|
|
1745
|
+
type: z8.literal("response.content_part.added"),
|
|
1746
|
+
item_id: z8.string(),
|
|
1747
|
+
output_index: z8.number(),
|
|
1748
|
+
content_index: z8.number(),
|
|
1709
1749
|
part: messageContentPartSchema
|
|
1710
1750
|
}),
|
|
1711
|
-
|
|
1712
|
-
type:
|
|
1713
|
-
item_id:
|
|
1714
|
-
output_index:
|
|
1715
|
-
content_index:
|
|
1751
|
+
z8.object({
|
|
1752
|
+
type: z8.literal("response.content_part.done"),
|
|
1753
|
+
item_id: z8.string(),
|
|
1754
|
+
output_index: z8.number(),
|
|
1755
|
+
content_index: z8.number(),
|
|
1716
1756
|
part: messageContentPartSchema
|
|
1717
1757
|
}),
|
|
1718
|
-
|
|
1719
|
-
type:
|
|
1720
|
-
item_id:
|
|
1721
|
-
output_index:
|
|
1722
|
-
content_index:
|
|
1723
|
-
delta:
|
|
1724
|
-
logprobs:
|
|
1758
|
+
z8.object({
|
|
1759
|
+
type: z8.literal("response.output_text.delta"),
|
|
1760
|
+
item_id: z8.string(),
|
|
1761
|
+
output_index: z8.number(),
|
|
1762
|
+
content_index: z8.number(),
|
|
1763
|
+
delta: z8.string(),
|
|
1764
|
+
logprobs: z8.array(z8.any()).optional()
|
|
1725
1765
|
}),
|
|
1726
|
-
|
|
1727
|
-
type:
|
|
1728
|
-
item_id:
|
|
1729
|
-
output_index:
|
|
1730
|
-
content_index:
|
|
1731
|
-
text:
|
|
1732
|
-
logprobs:
|
|
1733
|
-
annotations:
|
|
1766
|
+
z8.object({
|
|
1767
|
+
type: z8.literal("response.output_text.done"),
|
|
1768
|
+
item_id: z8.string(),
|
|
1769
|
+
output_index: z8.number(),
|
|
1770
|
+
content_index: z8.number(),
|
|
1771
|
+
text: z8.string(),
|
|
1772
|
+
logprobs: z8.array(z8.any()).optional(),
|
|
1773
|
+
annotations: z8.array(annotationSchema).optional()
|
|
1734
1774
|
}),
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1737
|
-
item_id:
|
|
1738
|
-
output_index:
|
|
1739
|
-
content_index:
|
|
1740
|
-
annotation_index:
|
|
1775
|
+
z8.object({
|
|
1776
|
+
type: z8.literal("response.output_text.annotation.added"),
|
|
1777
|
+
item_id: z8.string(),
|
|
1778
|
+
output_index: z8.number(),
|
|
1779
|
+
content_index: z8.number(),
|
|
1780
|
+
annotation_index: z8.number(),
|
|
1741
1781
|
annotation: annotationSchema
|
|
1742
1782
|
}),
|
|
1743
|
-
|
|
1744
|
-
type:
|
|
1745
|
-
item_id:
|
|
1746
|
-
output_index:
|
|
1747
|
-
summary_index:
|
|
1783
|
+
z8.object({
|
|
1784
|
+
type: z8.literal("response.reasoning_summary_part.added"),
|
|
1785
|
+
item_id: z8.string(),
|
|
1786
|
+
output_index: z8.number(),
|
|
1787
|
+
summary_index: z8.number(),
|
|
1748
1788
|
part: reasoningSummaryPartSchema
|
|
1749
1789
|
}),
|
|
1750
|
-
|
|
1751
|
-
type:
|
|
1752
|
-
item_id:
|
|
1753
|
-
output_index:
|
|
1754
|
-
summary_index:
|
|
1790
|
+
z8.object({
|
|
1791
|
+
type: z8.literal("response.reasoning_summary_part.done"),
|
|
1792
|
+
item_id: z8.string(),
|
|
1793
|
+
output_index: z8.number(),
|
|
1794
|
+
summary_index: z8.number(),
|
|
1755
1795
|
part: reasoningSummaryPartSchema
|
|
1756
1796
|
}),
|
|
1757
|
-
|
|
1758
|
-
type:
|
|
1759
|
-
item_id:
|
|
1760
|
-
output_index:
|
|
1761
|
-
summary_index:
|
|
1762
|
-
delta:
|
|
1797
|
+
z8.object({
|
|
1798
|
+
type: z8.literal("response.reasoning_summary_text.delta"),
|
|
1799
|
+
item_id: z8.string(),
|
|
1800
|
+
output_index: z8.number(),
|
|
1801
|
+
summary_index: z8.number(),
|
|
1802
|
+
delta: z8.string()
|
|
1763
1803
|
}),
|
|
1764
|
-
|
|
1765
|
-
type:
|
|
1766
|
-
item_id:
|
|
1767
|
-
output_index:
|
|
1768
|
-
summary_index:
|
|
1769
|
-
text:
|
|
1804
|
+
z8.object({
|
|
1805
|
+
type: z8.literal("response.reasoning_summary_text.done"),
|
|
1806
|
+
item_id: z8.string(),
|
|
1807
|
+
output_index: z8.number(),
|
|
1808
|
+
summary_index: z8.number(),
|
|
1809
|
+
text: z8.string()
|
|
1770
1810
|
}),
|
|
1771
|
-
|
|
1772
|
-
type:
|
|
1773
|
-
item_id:
|
|
1774
|
-
output_index:
|
|
1775
|
-
content_index:
|
|
1776
|
-
delta:
|
|
1811
|
+
z8.object({
|
|
1812
|
+
type: z8.literal("response.reasoning_text.delta"),
|
|
1813
|
+
item_id: z8.string(),
|
|
1814
|
+
output_index: z8.number(),
|
|
1815
|
+
content_index: z8.number(),
|
|
1816
|
+
delta: z8.string()
|
|
1777
1817
|
}),
|
|
1778
|
-
|
|
1779
|
-
type:
|
|
1780
|
-
item_id:
|
|
1781
|
-
output_index:
|
|
1782
|
-
content_index:
|
|
1783
|
-
text:
|
|
1818
|
+
z8.object({
|
|
1819
|
+
type: z8.literal("response.reasoning_text.done"),
|
|
1820
|
+
item_id: z8.string(),
|
|
1821
|
+
output_index: z8.number(),
|
|
1822
|
+
content_index: z8.number(),
|
|
1823
|
+
text: z8.string()
|
|
1784
1824
|
}),
|
|
1785
|
-
|
|
1786
|
-
type:
|
|
1787
|
-
item_id:
|
|
1788
|
-
output_index:
|
|
1825
|
+
z8.object({
|
|
1826
|
+
type: z8.literal("response.web_search_call.in_progress"),
|
|
1827
|
+
item_id: z8.string(),
|
|
1828
|
+
output_index: z8.number()
|
|
1789
1829
|
}),
|
|
1790
|
-
|
|
1791
|
-
type:
|
|
1792
|
-
item_id:
|
|
1793
|
-
output_index:
|
|
1830
|
+
z8.object({
|
|
1831
|
+
type: z8.literal("response.web_search_call.searching"),
|
|
1832
|
+
item_id: z8.string(),
|
|
1833
|
+
output_index: z8.number()
|
|
1794
1834
|
}),
|
|
1795
|
-
|
|
1796
|
-
type:
|
|
1797
|
-
item_id:
|
|
1798
|
-
output_index:
|
|
1835
|
+
z8.object({
|
|
1836
|
+
type: z8.literal("response.web_search_call.completed"),
|
|
1837
|
+
item_id: z8.string(),
|
|
1838
|
+
output_index: z8.number()
|
|
1799
1839
|
}),
|
|
1800
|
-
|
|
1801
|
-
type:
|
|
1802
|
-
item_id:
|
|
1803
|
-
output_index:
|
|
1840
|
+
z8.object({
|
|
1841
|
+
type: z8.literal("response.x_search_call.in_progress"),
|
|
1842
|
+
item_id: z8.string(),
|
|
1843
|
+
output_index: z8.number()
|
|
1804
1844
|
}),
|
|
1805
|
-
|
|
1806
|
-
type:
|
|
1807
|
-
item_id:
|
|
1808
|
-
output_index:
|
|
1845
|
+
z8.object({
|
|
1846
|
+
type: z8.literal("response.x_search_call.searching"),
|
|
1847
|
+
item_id: z8.string(),
|
|
1848
|
+
output_index: z8.number()
|
|
1809
1849
|
}),
|
|
1810
|
-
|
|
1811
|
-
type:
|
|
1812
|
-
item_id:
|
|
1813
|
-
output_index:
|
|
1850
|
+
z8.object({
|
|
1851
|
+
type: z8.literal("response.x_search_call.completed"),
|
|
1852
|
+
item_id: z8.string(),
|
|
1853
|
+
output_index: z8.number()
|
|
1814
1854
|
}),
|
|
1815
|
-
|
|
1816
|
-
type:
|
|
1817
|
-
item_id:
|
|
1818
|
-
output_index:
|
|
1855
|
+
z8.object({
|
|
1856
|
+
type: z8.literal("response.file_search_call.in_progress"),
|
|
1857
|
+
item_id: z8.string(),
|
|
1858
|
+
output_index: z8.number()
|
|
1819
1859
|
}),
|
|
1820
|
-
|
|
1821
|
-
type:
|
|
1822
|
-
item_id:
|
|
1823
|
-
output_index:
|
|
1860
|
+
z8.object({
|
|
1861
|
+
type: z8.literal("response.file_search_call.searching"),
|
|
1862
|
+
item_id: z8.string(),
|
|
1863
|
+
output_index: z8.number()
|
|
1824
1864
|
}),
|
|
1825
|
-
|
|
1826
|
-
type:
|
|
1827
|
-
item_id:
|
|
1828
|
-
output_index:
|
|
1865
|
+
z8.object({
|
|
1866
|
+
type: z8.literal("response.file_search_call.completed"),
|
|
1867
|
+
item_id: z8.string(),
|
|
1868
|
+
output_index: z8.number()
|
|
1829
1869
|
}),
|
|
1830
|
-
|
|
1831
|
-
type:
|
|
1832
|
-
item_id:
|
|
1833
|
-
output_index:
|
|
1870
|
+
z8.object({
|
|
1871
|
+
type: z8.literal("response.image_generation_call.in_progress"),
|
|
1872
|
+
item_id: z8.string(),
|
|
1873
|
+
output_index: z8.number()
|
|
1834
1874
|
}),
|
|
1835
|
-
|
|
1836
|
-
type:
|
|
1837
|
-
item_id:
|
|
1838
|
-
output_index:
|
|
1875
|
+
z8.object({
|
|
1876
|
+
type: z8.literal("response.image_generation_call.generating"),
|
|
1877
|
+
item_id: z8.string(),
|
|
1878
|
+
output_index: z8.number()
|
|
1839
1879
|
}),
|
|
1840
|
-
|
|
1841
|
-
type:
|
|
1842
|
-
item_id:
|
|
1843
|
-
output_index:
|
|
1880
|
+
z8.object({
|
|
1881
|
+
type: z8.literal("response.image_generation_call.completed"),
|
|
1882
|
+
item_id: z8.string(),
|
|
1883
|
+
output_index: z8.number()
|
|
1844
1884
|
}),
|
|
1845
|
-
|
|
1846
|
-
type:
|
|
1847
|
-
item_id:
|
|
1848
|
-
output_index:
|
|
1885
|
+
z8.object({
|
|
1886
|
+
type: z8.literal("response.code_execution_call.in_progress"),
|
|
1887
|
+
item_id: z8.string(),
|
|
1888
|
+
output_index: z8.number()
|
|
1849
1889
|
}),
|
|
1850
|
-
|
|
1851
|
-
type:
|
|
1852
|
-
item_id:
|
|
1853
|
-
output_index:
|
|
1890
|
+
z8.object({
|
|
1891
|
+
type: z8.literal("response.code_execution_call.executing"),
|
|
1892
|
+
item_id: z8.string(),
|
|
1893
|
+
output_index: z8.number()
|
|
1854
1894
|
}),
|
|
1855
|
-
|
|
1856
|
-
type:
|
|
1857
|
-
item_id:
|
|
1858
|
-
output_index:
|
|
1895
|
+
z8.object({
|
|
1896
|
+
type: z8.literal("response.code_execution_call.completed"),
|
|
1897
|
+
item_id: z8.string(),
|
|
1898
|
+
output_index: z8.number()
|
|
1859
1899
|
}),
|
|
1860
|
-
|
|
1861
|
-
type:
|
|
1862
|
-
item_id:
|
|
1863
|
-
output_index:
|
|
1900
|
+
z8.object({
|
|
1901
|
+
type: z8.literal("response.code_interpreter_call.in_progress"),
|
|
1902
|
+
item_id: z8.string(),
|
|
1903
|
+
output_index: z8.number()
|
|
1864
1904
|
}),
|
|
1865
|
-
|
|
1866
|
-
type:
|
|
1867
|
-
item_id:
|
|
1868
|
-
output_index:
|
|
1905
|
+
z8.object({
|
|
1906
|
+
type: z8.literal("response.code_interpreter_call.executing"),
|
|
1907
|
+
item_id: z8.string(),
|
|
1908
|
+
output_index: z8.number()
|
|
1869
1909
|
}),
|
|
1870
|
-
|
|
1871
|
-
type:
|
|
1872
|
-
item_id:
|
|
1873
|
-
output_index:
|
|
1910
|
+
z8.object({
|
|
1911
|
+
type: z8.literal("response.code_interpreter_call.interpreting"),
|
|
1912
|
+
item_id: z8.string(),
|
|
1913
|
+
output_index: z8.number()
|
|
1874
1914
|
}),
|
|
1875
|
-
|
|
1876
|
-
type:
|
|
1877
|
-
item_id:
|
|
1878
|
-
output_index:
|
|
1915
|
+
z8.object({
|
|
1916
|
+
type: z8.literal("response.code_interpreter_call.completed"),
|
|
1917
|
+
item_id: z8.string(),
|
|
1918
|
+
output_index: z8.number()
|
|
1879
1919
|
}),
|
|
1880
1920
|
// Code interpreter code streaming events
|
|
1881
|
-
|
|
1882
|
-
type:
|
|
1883
|
-
item_id:
|
|
1884
|
-
output_index:
|
|
1885
|
-
delta:
|
|
1921
|
+
z8.object({
|
|
1922
|
+
type: z8.literal("response.code_interpreter_call_code.delta"),
|
|
1923
|
+
item_id: z8.string(),
|
|
1924
|
+
output_index: z8.number(),
|
|
1925
|
+
delta: z8.string()
|
|
1886
1926
|
}),
|
|
1887
|
-
|
|
1888
|
-
type:
|
|
1889
|
-
item_id:
|
|
1890
|
-
output_index:
|
|
1891
|
-
code:
|
|
1927
|
+
z8.object({
|
|
1928
|
+
type: z8.literal("response.code_interpreter_call_code.done"),
|
|
1929
|
+
item_id: z8.string(),
|
|
1930
|
+
output_index: z8.number(),
|
|
1931
|
+
code: z8.string()
|
|
1892
1932
|
}),
|
|
1893
|
-
|
|
1894
|
-
type:
|
|
1895
|
-
item_id:
|
|
1896
|
-
output_index:
|
|
1897
|
-
delta:
|
|
1933
|
+
z8.object({
|
|
1934
|
+
type: z8.literal("response.custom_tool_call_input.delta"),
|
|
1935
|
+
item_id: z8.string(),
|
|
1936
|
+
output_index: z8.number(),
|
|
1937
|
+
delta: z8.string()
|
|
1898
1938
|
}),
|
|
1899
|
-
|
|
1900
|
-
type:
|
|
1901
|
-
item_id:
|
|
1902
|
-
output_index:
|
|
1903
|
-
input:
|
|
1939
|
+
z8.object({
|
|
1940
|
+
type: z8.literal("response.custom_tool_call_input.done"),
|
|
1941
|
+
item_id: z8.string(),
|
|
1942
|
+
output_index: z8.number(),
|
|
1943
|
+
input: z8.string()
|
|
1904
1944
|
}),
|
|
1905
1945
|
// Function call arguments streaming events (standard function tools)
|
|
1906
|
-
|
|
1907
|
-
type:
|
|
1908
|
-
item_id:
|
|
1909
|
-
output_index:
|
|
1910
|
-
delta:
|
|
1946
|
+
z8.object({
|
|
1947
|
+
type: z8.literal("response.function_call_arguments.delta"),
|
|
1948
|
+
item_id: z8.string(),
|
|
1949
|
+
output_index: z8.number(),
|
|
1950
|
+
delta: z8.string()
|
|
1911
1951
|
}),
|
|
1912
|
-
|
|
1913
|
-
type:
|
|
1914
|
-
item_id:
|
|
1915
|
-
output_index:
|
|
1916
|
-
arguments:
|
|
1952
|
+
z8.object({
|
|
1953
|
+
type: z8.literal("response.function_call_arguments.done"),
|
|
1954
|
+
item_id: z8.string(),
|
|
1955
|
+
output_index: z8.number(),
|
|
1956
|
+
arguments: z8.string()
|
|
1917
1957
|
}),
|
|
1918
|
-
|
|
1919
|
-
type:
|
|
1920
|
-
item_id:
|
|
1921
|
-
output_index:
|
|
1958
|
+
z8.object({
|
|
1959
|
+
type: z8.literal("response.mcp_call.in_progress"),
|
|
1960
|
+
item_id: z8.string(),
|
|
1961
|
+
output_index: z8.number()
|
|
1922
1962
|
}),
|
|
1923
|
-
|
|
1924
|
-
type:
|
|
1925
|
-
item_id:
|
|
1926
|
-
output_index:
|
|
1963
|
+
z8.object({
|
|
1964
|
+
type: z8.literal("response.mcp_call.executing"),
|
|
1965
|
+
item_id: z8.string(),
|
|
1966
|
+
output_index: z8.number()
|
|
1927
1967
|
}),
|
|
1928
|
-
|
|
1929
|
-
type:
|
|
1930
|
-
item_id:
|
|
1931
|
-
output_index:
|
|
1968
|
+
z8.object({
|
|
1969
|
+
type: z8.literal("response.mcp_call.completed"),
|
|
1970
|
+
item_id: z8.string(),
|
|
1971
|
+
output_index: z8.number()
|
|
1932
1972
|
}),
|
|
1933
|
-
|
|
1934
|
-
type:
|
|
1935
|
-
item_id:
|
|
1936
|
-
output_index:
|
|
1973
|
+
z8.object({
|
|
1974
|
+
type: z8.literal("response.mcp_call.failed"),
|
|
1975
|
+
item_id: z8.string(),
|
|
1976
|
+
output_index: z8.number()
|
|
1937
1977
|
}),
|
|
1938
|
-
|
|
1939
|
-
type:
|
|
1940
|
-
item_id:
|
|
1941
|
-
output_index:
|
|
1942
|
-
delta:
|
|
1978
|
+
z8.object({
|
|
1979
|
+
type: z8.literal("response.mcp_call_arguments.delta"),
|
|
1980
|
+
item_id: z8.string(),
|
|
1981
|
+
output_index: z8.number(),
|
|
1982
|
+
delta: z8.string()
|
|
1943
1983
|
}),
|
|
1944
|
-
|
|
1945
|
-
type:
|
|
1946
|
-
item_id:
|
|
1947
|
-
output_index:
|
|
1948
|
-
arguments:
|
|
1984
|
+
z8.object({
|
|
1985
|
+
type: z8.literal("response.mcp_call_arguments.done"),
|
|
1986
|
+
item_id: z8.string(),
|
|
1987
|
+
output_index: z8.number(),
|
|
1988
|
+
arguments: z8.string().optional()
|
|
1949
1989
|
}),
|
|
1950
|
-
|
|
1951
|
-
type:
|
|
1952
|
-
item_id:
|
|
1953
|
-
output_index:
|
|
1954
|
-
delta:
|
|
1990
|
+
z8.object({
|
|
1991
|
+
type: z8.literal("response.mcp_call_output.delta"),
|
|
1992
|
+
item_id: z8.string(),
|
|
1993
|
+
output_index: z8.number(),
|
|
1994
|
+
delta: z8.string()
|
|
1955
1995
|
}),
|
|
1956
|
-
|
|
1957
|
-
type:
|
|
1958
|
-
item_id:
|
|
1959
|
-
output_index:
|
|
1960
|
-
output:
|
|
1996
|
+
z8.object({
|
|
1997
|
+
type: z8.literal("response.mcp_call_output.done"),
|
|
1998
|
+
item_id: z8.string(),
|
|
1999
|
+
output_index: z8.number(),
|
|
2000
|
+
output: z8.string().optional()
|
|
1961
2001
|
}),
|
|
1962
|
-
|
|
1963
|
-
type:
|
|
1964
|
-
response:
|
|
1965
|
-
incomplete_details:
|
|
2002
|
+
z8.object({
|
|
2003
|
+
type: z8.literal("response.incomplete"),
|
|
2004
|
+
response: z8.object({
|
|
2005
|
+
incomplete_details: z8.object({ reason: z8.string() }).nullish(),
|
|
1966
2006
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1967
|
-
service_tier:
|
|
2007
|
+
service_tier: z8.string().nullish()
|
|
1968
2008
|
})
|
|
1969
2009
|
}),
|
|
1970
|
-
|
|
1971
|
-
type:
|
|
1972
|
-
response:
|
|
1973
|
-
error:
|
|
1974
|
-
code:
|
|
1975
|
-
message:
|
|
2010
|
+
z8.object({
|
|
2011
|
+
type: z8.literal("response.failed"),
|
|
2012
|
+
response: z8.object({
|
|
2013
|
+
error: z8.object({
|
|
2014
|
+
code: z8.string().nullish(),
|
|
2015
|
+
message: z8.string()
|
|
1976
2016
|
}).nullish(),
|
|
1977
|
-
incomplete_details:
|
|
2017
|
+
incomplete_details: z8.object({ reason: z8.string() }).nullish(),
|
|
1978
2018
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1979
2019
|
})
|
|
1980
2020
|
}),
|
|
1981
|
-
|
|
1982
|
-
type:
|
|
1983
|
-
code:
|
|
1984
|
-
message:
|
|
1985
|
-
param:
|
|
2021
|
+
z8.object({
|
|
2022
|
+
type: z8.literal("error"),
|
|
2023
|
+
code: z8.string().nullish(),
|
|
2024
|
+
message: z8.string(),
|
|
2025
|
+
param: z8.string().nullish()
|
|
1986
2026
|
}),
|
|
1987
|
-
|
|
1988
|
-
type:
|
|
2027
|
+
z8.object({
|
|
2028
|
+
type: z8.literal("response.done"),
|
|
1989
2029
|
response: xaiResponsesResponseSchema
|
|
1990
2030
|
}),
|
|
1991
|
-
|
|
1992
|
-
type:
|
|
2031
|
+
z8.object({
|
|
2032
|
+
type: z8.literal("response.completed"),
|
|
1993
2033
|
response: xaiResponsesResponseSchema
|
|
1994
2034
|
})
|
|
1995
2035
|
]);
|
|
1996
2036
|
|
|
1997
2037
|
// src/responses/xai-responses-language-model-options.ts
|
|
1998
|
-
import { z as
|
|
1999
|
-
var xaiLanguageModelResponsesOptions =
|
|
2038
|
+
import { z as z9 } from "zod/v4";
|
|
2039
|
+
var xaiLanguageModelResponsesOptions = z9.object({
|
|
2000
2040
|
/**
|
|
2001
2041
|
* Constrains how hard a reasoning model thinks before responding.
|
|
2002
2042
|
* Possible values are `none` (disables reasoning entirely; supported by
|
|
@@ -2006,27 +2046,27 @@ var xaiLanguageModelResponsesOptions = z8.object({
|
|
|
2006
2046
|
*
|
|
2007
2047
|
* @see https://docs.x.ai/docs/guides/reasoning
|
|
2008
2048
|
*/
|
|
2009
|
-
reasoningEffort:
|
|
2010
|
-
reasoningSummary:
|
|
2011
|
-
logprobs:
|
|
2012
|
-
topLogprobs:
|
|
2013
|
-
serviceTier:
|
|
2049
|
+
reasoningEffort: z9.enum(["none", "low", "medium", "high", "xhigh"]).optional(),
|
|
2050
|
+
reasoningSummary: z9.enum(["auto", "concise", "detailed"]).optional(),
|
|
2051
|
+
logprobs: z9.boolean().optional(),
|
|
2052
|
+
topLogprobs: z9.number().int().min(0).max(8).optional(),
|
|
2053
|
+
serviceTier: z9.enum(["default", "priority"]).optional(),
|
|
2014
2054
|
/**
|
|
2015
2055
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
2016
2056
|
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
2017
2057
|
* otherwise the API will return an error.
|
|
2018
2058
|
* @default true
|
|
2019
2059
|
*/
|
|
2020
|
-
store:
|
|
2060
|
+
store: z9.boolean().optional(),
|
|
2021
2061
|
/**
|
|
2022
2062
|
* The ID of the previous response from the model.
|
|
2023
2063
|
*/
|
|
2024
|
-
previousResponseId:
|
|
2064
|
+
previousResponseId: z9.string().optional(),
|
|
2025
2065
|
/**
|
|
2026
2066
|
* Specify additional output data to include in the model response.
|
|
2027
2067
|
* Example values: 'file_search_call.results'.
|
|
2028
2068
|
*/
|
|
2029
|
-
include:
|
|
2069
|
+
include: z9.array(z9.enum(["file_search_call.results"])).nullish()
|
|
2030
2070
|
});
|
|
2031
2071
|
|
|
2032
2072
|
// src/responses/xai-responses-prepare-tools.ts
|
|
@@ -2038,28 +2078,28 @@ import { validateTypes } from "@ai-sdk/provider-utils";
|
|
|
2038
2078
|
// src/tool/file-search.ts
|
|
2039
2079
|
import {
|
|
2040
2080
|
createProviderExecutedToolFactory,
|
|
2041
|
-
lazySchema,
|
|
2042
|
-
zodSchema
|
|
2081
|
+
lazySchema as lazySchema2,
|
|
2082
|
+
zodSchema as zodSchema2
|
|
2043
2083
|
} from "@ai-sdk/provider-utils";
|
|
2044
|
-
import { z as
|
|
2045
|
-
var fileSearchArgsSchema =
|
|
2046
|
-
() =>
|
|
2047
|
-
|
|
2048
|
-
vectorStoreIds:
|
|
2049
|
-
maxNumResults:
|
|
2084
|
+
import { z as z10 } from "zod/v4";
|
|
2085
|
+
var fileSearchArgsSchema = lazySchema2(
|
|
2086
|
+
() => zodSchema2(
|
|
2087
|
+
z10.object({
|
|
2088
|
+
vectorStoreIds: z10.array(z10.string()),
|
|
2089
|
+
maxNumResults: z10.number().optional()
|
|
2050
2090
|
})
|
|
2051
2091
|
)
|
|
2052
2092
|
);
|
|
2053
|
-
var fileSearchOutputSchema =
|
|
2054
|
-
() =>
|
|
2055
|
-
|
|
2056
|
-
queries:
|
|
2057
|
-
results:
|
|
2058
|
-
|
|
2059
|
-
fileId:
|
|
2060
|
-
filename:
|
|
2061
|
-
score:
|
|
2062
|
-
text:
|
|
2093
|
+
var fileSearchOutputSchema = lazySchema2(
|
|
2094
|
+
() => zodSchema2(
|
|
2095
|
+
z10.object({
|
|
2096
|
+
queries: z10.array(z10.string()),
|
|
2097
|
+
results: z10.array(
|
|
2098
|
+
z10.object({
|
|
2099
|
+
fileId: z10.string(),
|
|
2100
|
+
filename: z10.string(),
|
|
2101
|
+
score: z10.number().min(0).max(1),
|
|
2102
|
+
text: z10.string()
|
|
2063
2103
|
})
|
|
2064
2104
|
).nullable()
|
|
2065
2105
|
})
|
|
@@ -2067,7 +2107,7 @@ var fileSearchOutputSchema = lazySchema(
|
|
|
2067
2107
|
);
|
|
2068
2108
|
var fileSearchToolFactory = createProviderExecutedToolFactory({
|
|
2069
2109
|
id: "xai.file_search",
|
|
2070
|
-
inputSchema:
|
|
2110
|
+
inputSchema: lazySchema2(() => zodSchema2(z10.object({}))),
|
|
2071
2111
|
outputSchema: fileSearchOutputSchema
|
|
2072
2112
|
});
|
|
2073
2113
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
@@ -2075,23 +2115,23 @@ var fileSearch = (args) => fileSearchToolFactory(args);
|
|
|
2075
2115
|
// src/tool/image-generation.ts
|
|
2076
2116
|
import {
|
|
2077
2117
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
2078
|
-
lazySchema as
|
|
2079
|
-
zodSchema as
|
|
2118
|
+
lazySchema as lazySchema3,
|
|
2119
|
+
zodSchema as zodSchema3
|
|
2080
2120
|
} from "@ai-sdk/provider-utils";
|
|
2081
|
-
import { z as
|
|
2082
|
-
var imageGenerationArgsSchema =
|
|
2083
|
-
() =>
|
|
2084
|
-
|
|
2085
|
-
action:
|
|
2121
|
+
import { z as z11 } from "zod/v4";
|
|
2122
|
+
var imageGenerationArgsSchema = lazySchema3(
|
|
2123
|
+
() => zodSchema3(
|
|
2124
|
+
z11.object({
|
|
2125
|
+
action: z11.enum(["auto", "generate", "edit"]).optional()
|
|
2086
2126
|
})
|
|
2087
2127
|
)
|
|
2088
2128
|
);
|
|
2089
|
-
var imageGenerationInputSchema =
|
|
2090
|
-
var imageGenerationOutputSchema =
|
|
2091
|
-
() =>
|
|
2092
|
-
|
|
2093
|
-
result:
|
|
2094
|
-
prompt:
|
|
2129
|
+
var imageGenerationInputSchema = lazySchema3(() => zodSchema3(z11.object({})));
|
|
2130
|
+
var imageGenerationOutputSchema = lazySchema3(
|
|
2131
|
+
() => zodSchema3(
|
|
2132
|
+
z11.object({
|
|
2133
|
+
result: z11.string(),
|
|
2134
|
+
prompt: z11.string().optional()
|
|
2095
2135
|
})
|
|
2096
2136
|
)
|
|
2097
2137
|
);
|
|
@@ -2105,34 +2145,34 @@ var imageGeneration = (args = {}) => imageGenerationToolFactory(args);
|
|
|
2105
2145
|
// src/tool/mcp-server.ts
|
|
2106
2146
|
import {
|
|
2107
2147
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
2108
|
-
lazySchema as
|
|
2109
|
-
zodSchema as
|
|
2148
|
+
lazySchema as lazySchema4,
|
|
2149
|
+
zodSchema as zodSchema4
|
|
2110
2150
|
} from "@ai-sdk/provider-utils";
|
|
2111
|
-
import { z as
|
|
2112
|
-
var mcpServerArgsSchema =
|
|
2113
|
-
() =>
|
|
2114
|
-
|
|
2115
|
-
serverUrl:
|
|
2116
|
-
serverLabel:
|
|
2117
|
-
serverDescription:
|
|
2118
|
-
allowedTools:
|
|
2119
|
-
headers:
|
|
2120
|
-
authorization:
|
|
2151
|
+
import { z as z12 } from "zod/v4";
|
|
2152
|
+
var mcpServerArgsSchema = lazySchema4(
|
|
2153
|
+
() => zodSchema4(
|
|
2154
|
+
z12.object({
|
|
2155
|
+
serverUrl: z12.string().describe("The URL of the MCP server"),
|
|
2156
|
+
serverLabel: z12.string().optional().describe("A label for the MCP server"),
|
|
2157
|
+
serverDescription: z12.string().optional().describe("Description of the MCP server"),
|
|
2158
|
+
allowedTools: z12.array(z12.string()).optional().describe("List of allowed tool names"),
|
|
2159
|
+
headers: z12.record(z12.string(), z12.string()).optional().describe("Custom headers to send"),
|
|
2160
|
+
authorization: z12.string().optional().describe("Authorization header value")
|
|
2121
2161
|
})
|
|
2122
2162
|
)
|
|
2123
2163
|
);
|
|
2124
|
-
var mcpServerOutputSchema =
|
|
2125
|
-
() =>
|
|
2126
|
-
|
|
2127
|
-
name:
|
|
2128
|
-
arguments:
|
|
2129
|
-
result:
|
|
2164
|
+
var mcpServerOutputSchema = lazySchema4(
|
|
2165
|
+
() => zodSchema4(
|
|
2166
|
+
z12.object({
|
|
2167
|
+
name: z12.string(),
|
|
2168
|
+
arguments: z12.string(),
|
|
2169
|
+
result: z12.unknown()
|
|
2130
2170
|
})
|
|
2131
2171
|
)
|
|
2132
2172
|
);
|
|
2133
2173
|
var mcpServerToolFactory = createProviderExecutedToolFactory3({
|
|
2134
2174
|
id: "xai.mcp",
|
|
2135
|
-
inputSchema:
|
|
2175
|
+
inputSchema: lazySchema4(() => zodSchema4(z12.object({}))),
|
|
2136
2176
|
outputSchema: mcpServerOutputSchema
|
|
2137
2177
|
});
|
|
2138
2178
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
@@ -2140,29 +2180,29 @@ var mcpServer = (args) => mcpServerToolFactory(args);
|
|
|
2140
2180
|
// src/tool/web-search.ts
|
|
2141
2181
|
import {
|
|
2142
2182
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
2143
|
-
lazySchema as
|
|
2144
|
-
zodSchema as
|
|
2183
|
+
lazySchema as lazySchema5,
|
|
2184
|
+
zodSchema as zodSchema5
|
|
2145
2185
|
} from "@ai-sdk/provider-utils";
|
|
2146
|
-
import { z as
|
|
2147
|
-
var webSearchArgsSchema =
|
|
2148
|
-
() =>
|
|
2149
|
-
|
|
2150
|
-
allowedDomains:
|
|
2151
|
-
excludedDomains:
|
|
2152
|
-
enableImageSearch:
|
|
2153
|
-
enableImageUnderstanding:
|
|
2186
|
+
import { z as z13 } from "zod/v4";
|
|
2187
|
+
var webSearchArgsSchema = lazySchema5(
|
|
2188
|
+
() => zodSchema5(
|
|
2189
|
+
z13.object({
|
|
2190
|
+
allowedDomains: z13.array(z13.string()).max(5).optional(),
|
|
2191
|
+
excludedDomains: z13.array(z13.string()).max(5).optional(),
|
|
2192
|
+
enableImageSearch: z13.boolean().optional(),
|
|
2193
|
+
enableImageUnderstanding: z13.boolean().optional()
|
|
2154
2194
|
})
|
|
2155
2195
|
)
|
|
2156
2196
|
);
|
|
2157
|
-
var webSearchOutputSchema =
|
|
2158
|
-
() =>
|
|
2159
|
-
|
|
2160
|
-
query:
|
|
2161
|
-
sources:
|
|
2162
|
-
|
|
2163
|
-
title:
|
|
2164
|
-
url:
|
|
2165
|
-
snippet:
|
|
2197
|
+
var webSearchOutputSchema = lazySchema5(
|
|
2198
|
+
() => zodSchema5(
|
|
2199
|
+
z13.object({
|
|
2200
|
+
query: z13.string(),
|
|
2201
|
+
sources: z13.array(
|
|
2202
|
+
z13.object({
|
|
2203
|
+
title: z13.string(),
|
|
2204
|
+
url: z13.string(),
|
|
2205
|
+
snippet: z13.string()
|
|
2166
2206
|
})
|
|
2167
2207
|
)
|
|
2168
2208
|
})
|
|
@@ -2170,7 +2210,7 @@ var webSearchOutputSchema = lazySchema4(
|
|
|
2170
2210
|
);
|
|
2171
2211
|
var webSearchToolFactory = createProviderExecutedToolFactory4({
|
|
2172
2212
|
id: "xai.web_search",
|
|
2173
|
-
inputSchema:
|
|
2213
|
+
inputSchema: lazySchema5(() => zodSchema5(z13.object({}))),
|
|
2174
2214
|
outputSchema: webSearchOutputSchema
|
|
2175
2215
|
});
|
|
2176
2216
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
@@ -2178,32 +2218,32 @@ var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
|
2178
2218
|
// src/tool/x-search.ts
|
|
2179
2219
|
import {
|
|
2180
2220
|
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
2181
|
-
lazySchema as
|
|
2182
|
-
zodSchema as
|
|
2221
|
+
lazySchema as lazySchema6,
|
|
2222
|
+
zodSchema as zodSchema6
|
|
2183
2223
|
} from "@ai-sdk/provider-utils";
|
|
2184
|
-
import { z as
|
|
2185
|
-
var xSearchArgsSchema =
|
|
2186
|
-
() =>
|
|
2187
|
-
|
|
2188
|
-
allowedXHandles:
|
|
2189
|
-
excludedXHandles:
|
|
2190
|
-
fromDate:
|
|
2191
|
-
toDate:
|
|
2192
|
-
enableImageUnderstanding:
|
|
2193
|
-
enableVideoUnderstanding:
|
|
2224
|
+
import { z as z14 } from "zod/v4";
|
|
2225
|
+
var xSearchArgsSchema = lazySchema6(
|
|
2226
|
+
() => zodSchema6(
|
|
2227
|
+
z14.object({
|
|
2228
|
+
allowedXHandles: z14.array(z14.string()).max(10).optional(),
|
|
2229
|
+
excludedXHandles: z14.array(z14.string()).max(10).optional(),
|
|
2230
|
+
fromDate: z14.string().optional(),
|
|
2231
|
+
toDate: z14.string().optional(),
|
|
2232
|
+
enableImageUnderstanding: z14.boolean().optional(),
|
|
2233
|
+
enableVideoUnderstanding: z14.boolean().optional()
|
|
2194
2234
|
})
|
|
2195
2235
|
)
|
|
2196
2236
|
);
|
|
2197
|
-
var xSearchOutputSchema =
|
|
2198
|
-
() =>
|
|
2199
|
-
|
|
2200
|
-
query:
|
|
2201
|
-
posts:
|
|
2202
|
-
|
|
2203
|
-
author:
|
|
2204
|
-
text:
|
|
2205
|
-
url:
|
|
2206
|
-
likes:
|
|
2237
|
+
var xSearchOutputSchema = lazySchema6(
|
|
2238
|
+
() => zodSchema6(
|
|
2239
|
+
z14.object({
|
|
2240
|
+
query: z14.string(),
|
|
2241
|
+
posts: z14.array(
|
|
2242
|
+
z14.object({
|
|
2243
|
+
author: z14.string(),
|
|
2244
|
+
text: z14.string(),
|
|
2245
|
+
url: z14.string(),
|
|
2246
|
+
likes: z14.number()
|
|
2207
2247
|
})
|
|
2208
2248
|
)
|
|
2209
2249
|
})
|
|
@@ -2211,7 +2251,7 @@ var xSearchOutputSchema = lazySchema5(
|
|
|
2211
2251
|
);
|
|
2212
2252
|
var xSearchToolFactory = createProviderExecutedToolFactory5({
|
|
2213
2253
|
id: "xai.x_search",
|
|
2214
|
-
inputSchema:
|
|
2254
|
+
inputSchema: lazySchema6(() => zodSchema6(z14.object({}))),
|
|
2215
2255
|
outputSchema: xSearchOutputSchema
|
|
2216
2256
|
});
|
|
2217
2257
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -2379,6 +2419,64 @@ async function prepareResponsesTools({
|
|
|
2379
2419
|
}
|
|
2380
2420
|
|
|
2381
2421
|
// src/responses/xai-responses-language-model.ts
|
|
2422
|
+
function createXaiResponsesStreamError({
|
|
2423
|
+
message,
|
|
2424
|
+
code,
|
|
2425
|
+
eventType,
|
|
2426
|
+
data
|
|
2427
|
+
}) {
|
|
2428
|
+
const statusCode = getHttpStatusCode(code);
|
|
2429
|
+
return createProviderStreamError({
|
|
2430
|
+
message,
|
|
2431
|
+
type: eventType,
|
|
2432
|
+
code: code != null ? code : void 0,
|
|
2433
|
+
...statusCode != null ? {
|
|
2434
|
+
statusCode,
|
|
2435
|
+
isRetryable: isRetryableStatusCode(statusCode)
|
|
2436
|
+
} : getXaiResponsesStreamErrorMetadata(code),
|
|
2437
|
+
data
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
function getXaiResponsesStreamErrorMetadata(code) {
|
|
2441
|
+
switch (code) {
|
|
2442
|
+
case "rate_limit_exceeded":
|
|
2443
|
+
case "rate_limit_error":
|
|
2444
|
+
return { statusCode: 429, isRetryable: true };
|
|
2445
|
+
case "insufficient_quota":
|
|
2446
|
+
return { statusCode: 429, isRetryable: false };
|
|
2447
|
+
case "api_error":
|
|
2448
|
+
case "internal_server_error":
|
|
2449
|
+
case "server_error":
|
|
2450
|
+
return { statusCode: 500, isRetryable: true };
|
|
2451
|
+
case "overloaded_error":
|
|
2452
|
+
case "service_unavailable":
|
|
2453
|
+
return { statusCode: 503, isRetryable: true };
|
|
2454
|
+
case "timeout":
|
|
2455
|
+
case "timeout_error":
|
|
2456
|
+
return { statusCode: 504, isRetryable: true };
|
|
2457
|
+
case "authentication_error":
|
|
2458
|
+
case "invalid_api_key":
|
|
2459
|
+
return { statusCode: 401, isRetryable: false };
|
|
2460
|
+
case "permission_error":
|
|
2461
|
+
return { statusCode: 403, isRetryable: false };
|
|
2462
|
+
case "not_found_error":
|
|
2463
|
+
case "model_not_found":
|
|
2464
|
+
return { statusCode: 404, isRetryable: false };
|
|
2465
|
+
case "bad_request":
|
|
2466
|
+
case "context_length_exceeded":
|
|
2467
|
+
case "invalid_request_error":
|
|
2468
|
+
return { statusCode: 400, isRetryable: false };
|
|
2469
|
+
default:
|
|
2470
|
+
return {};
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
function getHttpStatusCode(value) {
|
|
2474
|
+
const statusCode = typeof value === "string" && /^\d{3}$/.test(value) ? Number(value) : value;
|
|
2475
|
+
return typeof statusCode === "number" && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599 ? statusCode : void 0;
|
|
2476
|
+
}
|
|
2477
|
+
function isRetryableStatusCode(statusCode) {
|
|
2478
|
+
return statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500;
|
|
2479
|
+
}
|
|
2382
2480
|
var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
2383
2481
|
constructor(modelId, config) {
|
|
2384
2482
|
this.specificationVersion = "v4";
|
|
@@ -2977,10 +3075,29 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2977
3075
|
if (event.response.usage) {
|
|
2978
3076
|
usage = convertXaiResponsesUsage(event.response.usage);
|
|
2979
3077
|
}
|
|
3078
|
+
if (event.response.error != null) {
|
|
3079
|
+
controller.enqueue({
|
|
3080
|
+
type: "error",
|
|
3081
|
+
error: createXaiResponsesStreamError({
|
|
3082
|
+
message: event.response.error.message,
|
|
3083
|
+
code: event.response.error.code,
|
|
3084
|
+
eventType: event.type,
|
|
3085
|
+
data: event
|
|
3086
|
+
})
|
|
3087
|
+
});
|
|
3088
|
+
}
|
|
2980
3089
|
return;
|
|
2981
3090
|
}
|
|
2982
3091
|
if (event.type === "error") {
|
|
2983
|
-
controller.enqueue({
|
|
3092
|
+
controller.enqueue({
|
|
3093
|
+
type: "error",
|
|
3094
|
+
error: createXaiResponsesStreamError({
|
|
3095
|
+
message: event.message,
|
|
3096
|
+
code: event.code,
|
|
3097
|
+
eventType: event.type,
|
|
3098
|
+
data: event
|
|
3099
|
+
})
|
|
3100
|
+
});
|
|
2984
3101
|
return;
|
|
2985
3102
|
}
|
|
2986
3103
|
if (event.type === "response.custom_tool_call_input.delta" || event.type === "response.custom_tool_call_input.done") {
|
|
@@ -3310,6 +3427,381 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
3310
3427
|
}
|
|
3311
3428
|
};
|
|
3312
3429
|
|
|
3430
|
+
// src/responses/xai-responses-batch.ts
|
|
3431
|
+
var xaiBatchEndpoint = "/v1/responses";
|
|
3432
|
+
var xaiBatchName = "ai-sdk-text-batch";
|
|
3433
|
+
var xaiBatchResultsPageSize = 1e3;
|
|
3434
|
+
var xaiBatchResponseSchema = lazySchema7(
|
|
3435
|
+
() => zodSchema7(
|
|
3436
|
+
z15.object({
|
|
3437
|
+
batch_id: z15.string(),
|
|
3438
|
+
name: z15.string().nullish(),
|
|
3439
|
+
create_time: z15.string().nullish(),
|
|
3440
|
+
expire_time: z15.string().nullish(),
|
|
3441
|
+
cancel_time: z15.string().nullish(),
|
|
3442
|
+
cancel_by_xai_message: z15.string().nullish(),
|
|
3443
|
+
state: z15.object({
|
|
3444
|
+
num_requests: z15.number().nullish(),
|
|
3445
|
+
num_pending: z15.number().nullish(),
|
|
3446
|
+
num_success: z15.number().nullish(),
|
|
3447
|
+
num_error: z15.number().nullish(),
|
|
3448
|
+
num_cancelled: z15.number().nullish()
|
|
3449
|
+
}).nullish()
|
|
3450
|
+
})
|
|
3451
|
+
)
|
|
3452
|
+
);
|
|
3453
|
+
var xaiBatchErrorSchema = z15.object({
|
|
3454
|
+
code: z15.union([z15.string(), z15.number()]).nullish(),
|
|
3455
|
+
message: z15.string().nullish()
|
|
3456
|
+
});
|
|
3457
|
+
var xaiBatchResultSchema = z15.object({
|
|
3458
|
+
batch_request_id: z15.string(),
|
|
3459
|
+
batch_result: z15.object({
|
|
3460
|
+
response: z15.object({
|
|
3461
|
+
chat_get_completion: z15.unknown().nullish()
|
|
3462
|
+
}).nullish(),
|
|
3463
|
+
error: xaiBatchErrorSchema.nullish()
|
|
3464
|
+
}).nullish(),
|
|
3465
|
+
error_message: z15.string().nullish()
|
|
3466
|
+
});
|
|
3467
|
+
var xaiBatchResultsPageSchema = lazySchema7(
|
|
3468
|
+
() => zodSchema7(
|
|
3469
|
+
z15.object({
|
|
3470
|
+
results: z15.array(xaiBatchResultSchema),
|
|
3471
|
+
pagination_token: z15.string().nullish()
|
|
3472
|
+
})
|
|
3473
|
+
)
|
|
3474
|
+
);
|
|
3475
|
+
var XaiResponsesBatch = class {
|
|
3476
|
+
constructor(options) {
|
|
3477
|
+
this.options = options;
|
|
3478
|
+
}
|
|
3479
|
+
async startBatch(options) {
|
|
3480
|
+
var _a, _b;
|
|
3481
|
+
const fileParts = [];
|
|
3482
|
+
const warnings = options.webhookUrl == null ? [] : [
|
|
3483
|
+
{
|
|
3484
|
+
warning: {
|
|
3485
|
+
type: "unsupported",
|
|
3486
|
+
feature: "webhookUrl",
|
|
3487
|
+
details: "The xAI Batch API does not support per-batch webhook URLs."
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
];
|
|
3491
|
+
for (const request of options.requests) {
|
|
3492
|
+
const preparedRequest = await this.options.prepareRequest(request);
|
|
3493
|
+
fileParts.push(
|
|
3494
|
+
JSON.stringify({
|
|
3495
|
+
custom_id: request.id,
|
|
3496
|
+
method: "POST",
|
|
3497
|
+
url: xaiBatchEndpoint,
|
|
3498
|
+
body: preparedRequest.body
|
|
3499
|
+
}),
|
|
3500
|
+
"\n"
|
|
3501
|
+
);
|
|
3502
|
+
for (const warning of preparedRequest.warnings) {
|
|
3503
|
+
warnings.push({ requestId: request.id, warning });
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
const filename = "batch.jsonl";
|
|
3507
|
+
const file = new Blob(fileParts, { type: "application/jsonl" });
|
|
3508
|
+
fileParts.length = 0;
|
|
3509
|
+
const formData = new FormData();
|
|
3510
|
+
formData.append("file", file, filename);
|
|
3511
|
+
const headers = combineHeaders4(
|
|
3512
|
+
(_b = (_a = this.options.config).headers) == null ? void 0 : _b.call(_a),
|
|
3513
|
+
options.headers
|
|
3514
|
+
);
|
|
3515
|
+
const { value: uploadedFile } = await postFormDataToApi({
|
|
3516
|
+
url: this.getUrl("/files"),
|
|
3517
|
+
headers,
|
|
3518
|
+
formData,
|
|
3519
|
+
failedResponseHandler: xaiFailedResponseHandler,
|
|
3520
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
3521
|
+
xaiFilesResponseSchema
|
|
3522
|
+
),
|
|
3523
|
+
abortSignal: options.abortSignal,
|
|
3524
|
+
fetch: this.options.config.fetch
|
|
3525
|
+
});
|
|
3526
|
+
const { value: batch } = await postJsonToApi4({
|
|
3527
|
+
url: this.getUrl("/batches"),
|
|
3528
|
+
headers,
|
|
3529
|
+
body: {
|
|
3530
|
+
name: xaiBatchName,
|
|
3531
|
+
input_file_id: uploadedFile.id
|
|
3532
|
+
},
|
|
3533
|
+
failedResponseHandler: xaiFailedResponseHandler,
|
|
3534
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
3535
|
+
xaiBatchResponseSchema
|
|
3536
|
+
),
|
|
3537
|
+
abortSignal: options.abortSignal,
|
|
3538
|
+
fetch: this.options.config.fetch
|
|
3539
|
+
});
|
|
3540
|
+
return {
|
|
3541
|
+
batchId: batch.batch_id,
|
|
3542
|
+
...convertXaiBatchStatus(batch),
|
|
3543
|
+
warnings
|
|
3544
|
+
};
|
|
3545
|
+
}
|
|
3546
|
+
async getBatchStatus(options) {
|
|
3547
|
+
return convertXaiBatchStatus(await this.retrieveBatch(options));
|
|
3548
|
+
}
|
|
3549
|
+
async getBatchResults(options) {
|
|
3550
|
+
const batch = await this.retrieveBatch(options);
|
|
3551
|
+
if (convertXaiBatchStatus(batch).status === "pending") {
|
|
3552
|
+
throw new InvalidArgumentError({
|
|
3553
|
+
argument: "batchId",
|
|
3554
|
+
message: `xAI batch "${options.batchId}" is not complete.`
|
|
3555
|
+
});
|
|
3556
|
+
}
|
|
3557
|
+
return convertAsyncIteratorToReadableStream(
|
|
3558
|
+
this.iterateBatchResults(options)
|
|
3559
|
+
);
|
|
3560
|
+
}
|
|
3561
|
+
async retrieveBatch(options) {
|
|
3562
|
+
var _a, _b;
|
|
3563
|
+
const { value: batch } = await getFromApi2({
|
|
3564
|
+
url: this.getUrl(`/batches/${encodeURIComponent(options.batchId)}`),
|
|
3565
|
+
headers: combineHeaders4((_b = (_a = this.options.config).headers) == null ? void 0 : _b.call(_a), options.headers),
|
|
3566
|
+
failedResponseHandler: xaiFailedResponseHandler,
|
|
3567
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
3568
|
+
xaiBatchResponseSchema
|
|
3569
|
+
),
|
|
3570
|
+
abortSignal: options.abortSignal,
|
|
3571
|
+
fetch: this.options.config.fetch,
|
|
3572
|
+
validateUrl: false
|
|
3573
|
+
});
|
|
3574
|
+
return batch;
|
|
3575
|
+
}
|
|
3576
|
+
async *iterateBatchResults(options) {
|
|
3577
|
+
var _a, _b, _c;
|
|
3578
|
+
let paginationToken;
|
|
3579
|
+
do {
|
|
3580
|
+
const query = new URLSearchParams({
|
|
3581
|
+
limit: String(xaiBatchResultsPageSize)
|
|
3582
|
+
});
|
|
3583
|
+
if (paginationToken != null) {
|
|
3584
|
+
query.set("pagination_token", paginationToken);
|
|
3585
|
+
}
|
|
3586
|
+
const { value: page } = await getFromApi2({
|
|
3587
|
+
url: this.getUrl(
|
|
3588
|
+
`/batches/${encodeURIComponent(options.batchId)}/results?${query}`
|
|
3589
|
+
),
|
|
3590
|
+
headers: combineHeaders4(
|
|
3591
|
+
(_b = (_a = this.options.config).headers) == null ? void 0 : _b.call(_a),
|
|
3592
|
+
options.headers
|
|
3593
|
+
),
|
|
3594
|
+
failedResponseHandler: xaiFailedResponseHandler,
|
|
3595
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
3596
|
+
xaiBatchResultsPageSchema
|
|
3597
|
+
),
|
|
3598
|
+
abortSignal: options.abortSignal,
|
|
3599
|
+
fetch: this.options.config.fetch,
|
|
3600
|
+
validateUrl: false
|
|
3601
|
+
});
|
|
3602
|
+
for (const result of page.results) {
|
|
3603
|
+
yield await this.convertBatchResult(result);
|
|
3604
|
+
}
|
|
3605
|
+
paginationToken = (_c = page.pagination_token) != null ? _c : void 0;
|
|
3606
|
+
} while (paginationToken != null);
|
|
3607
|
+
}
|
|
3608
|
+
async convertBatchResult(result) {
|
|
3609
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3610
|
+
const error = (_a = result.batch_result) == null ? void 0 : _a.error;
|
|
3611
|
+
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) {
|
|
3612
|
+
const convertedError = convertXaiBatchError(result);
|
|
3613
|
+
return {
|
|
3614
|
+
id: result.batch_request_id,
|
|
3615
|
+
status: isXaiCancellationError(error == null ? void 0 : error.code) ? "cancelled" : "failed",
|
|
3616
|
+
error: convertedError
|
|
3617
|
+
};
|
|
3618
|
+
}
|
|
3619
|
+
const response = (_f = result.batch_result) == null ? void 0 : _f.response;
|
|
3620
|
+
if ((response == null ? void 0 : response.chat_get_completion) != null) {
|
|
3621
|
+
const validation = await safeValidateTypes({
|
|
3622
|
+
value: response.chat_get_completion,
|
|
3623
|
+
schema: xaiChatResponseSchema
|
|
3624
|
+
});
|
|
3625
|
+
if (!validation.success) {
|
|
3626
|
+
return invalidXaiBatchResult(result.batch_request_id);
|
|
3627
|
+
}
|
|
3628
|
+
const conversion = convertXaiChatBatchResponse(validation.value);
|
|
3629
|
+
return conversion.success ? {
|
|
3630
|
+
id: result.batch_request_id,
|
|
3631
|
+
status: "succeeded",
|
|
3632
|
+
result: conversion.result
|
|
3633
|
+
} : {
|
|
3634
|
+
id: result.batch_request_id,
|
|
3635
|
+
status: "failed",
|
|
3636
|
+
error: conversion.error
|
|
3637
|
+
};
|
|
3638
|
+
}
|
|
3639
|
+
return invalidXaiBatchResult(result.batch_request_id);
|
|
3640
|
+
}
|
|
3641
|
+
getUrl(path) {
|
|
3642
|
+
var _a;
|
|
3643
|
+
return `${(_a = this.options.config.baseURL) != null ? _a : "https://api.x.ai/v1"}${path}`;
|
|
3644
|
+
}
|
|
3645
|
+
};
|
|
3646
|
+
var XaiResponsesBatchLanguageModel = class _XaiResponsesBatchLanguageModel extends XaiResponsesLanguageModel {
|
|
3647
|
+
static [WORKFLOW_SERIALIZE4](model) {
|
|
3648
|
+
return XaiResponsesLanguageModel[WORKFLOW_SERIALIZE4](model);
|
|
3649
|
+
}
|
|
3650
|
+
static [WORKFLOW_DESERIALIZE4](options) {
|
|
3651
|
+
return new _XaiResponsesBatchLanguageModel(options.modelId, options.config);
|
|
3652
|
+
}
|
|
3653
|
+
constructor(modelId, config) {
|
|
3654
|
+
super(modelId, config);
|
|
3655
|
+
this.batch = new XaiResponsesBatch({
|
|
3656
|
+
config,
|
|
3657
|
+
prepareRequest: async (request) => {
|
|
3658
|
+
const { args: body, warnings } = await this.getArgs(request.options);
|
|
3659
|
+
return { body, warnings };
|
|
3660
|
+
}
|
|
3661
|
+
});
|
|
3662
|
+
}
|
|
3663
|
+
experimental_doStartBatch(options) {
|
|
3664
|
+
return this.batch.startBatch(options);
|
|
3665
|
+
}
|
|
3666
|
+
experimental_doGetBatchStatus(options) {
|
|
3667
|
+
return this.batch.getBatchStatus(options);
|
|
3668
|
+
}
|
|
3669
|
+
experimental_doGetBatchResults(options) {
|
|
3670
|
+
return this.batch.getBatchResults(options);
|
|
3671
|
+
}
|
|
3672
|
+
};
|
|
3673
|
+
function convertXaiBatchStatus(batch) {
|
|
3674
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3675
|
+
const requestCounts = normalizeBatchRequestCounts({
|
|
3676
|
+
total: (_a = batch.state) == null ? void 0 : _a.num_requests,
|
|
3677
|
+
pending: (_b = batch.state) == null ? void 0 : _b.num_pending,
|
|
3678
|
+
completed: (_c = batch.state) == null ? void 0 : _c.num_success,
|
|
3679
|
+
failed: ((_d = batch.state) == null ? void 0 : _d.num_error) != null && ((_e = batch.state) == null ? void 0 : _e.num_cancelled) != null ? batch.state.num_error + batch.state.num_cancelled : void 0
|
|
3680
|
+
});
|
|
3681
|
+
const isCancelled = batch.cancel_time != null || batch.cancel_by_xai_message != null;
|
|
3682
|
+
const isExpired = isPastDate(batch.expire_time);
|
|
3683
|
+
const status = isCancelled || isExpired ? "failed" : requestCounts != null && requestCounts.total > 0 && requestCounts.pending === 0 ? "completed" : "pending";
|
|
3684
|
+
return {
|
|
3685
|
+
status,
|
|
3686
|
+
...requestCounts != null ? { requestCounts } : {},
|
|
3687
|
+
...isCancelled ? {
|
|
3688
|
+
error: {
|
|
3689
|
+
message: (_f = batch.cancel_by_xai_message) != null ? _f : `xAI batch "${batch.batch_id}" was cancelled.`,
|
|
3690
|
+
code: "batch_cancelled"
|
|
3691
|
+
}
|
|
3692
|
+
} : isExpired ? {
|
|
3693
|
+
error: {
|
|
3694
|
+
message: `xAI batch "${batch.batch_id}" expired.`,
|
|
3695
|
+
code: "batch_expired"
|
|
3696
|
+
}
|
|
3697
|
+
} : {},
|
|
3698
|
+
...batch.create_time != null ? { createdAt: batch.create_time } : {},
|
|
3699
|
+
...batch.expire_time != null ? { expiresAt: batch.expire_time } : {}
|
|
3700
|
+
};
|
|
3701
|
+
}
|
|
3702
|
+
function isPastDate(value) {
|
|
3703
|
+
if (value == null) {
|
|
3704
|
+
return false;
|
|
3705
|
+
}
|
|
3706
|
+
const timestamp = Date.parse(value);
|
|
3707
|
+
return !Number.isNaN(timestamp) && timestamp <= Date.now();
|
|
3708
|
+
}
|
|
3709
|
+
function convertXaiBatchError(result) {
|
|
3710
|
+
var _a;
|
|
3711
|
+
const error = (_a = result.batch_result) == null ? void 0 : _a.error;
|
|
3712
|
+
return {
|
|
3713
|
+
message: result.error_message || (error == null ? void 0 : error.message) || "xAI batch request failed.",
|
|
3714
|
+
...(error == null ? void 0 : error.code) != null && error.code !== 0 && error.code !== "0" ? { code: String(error.code) } : {}
|
|
3715
|
+
};
|
|
3716
|
+
}
|
|
3717
|
+
function isXaiCancellationError(code) {
|
|
3718
|
+
const normalizedCode = String(code).toLowerCase();
|
|
3719
|
+
return code === 1 || normalizedCode === "1" || normalizedCode === "cancelled" || normalizedCode === "batch_cancelled";
|
|
3720
|
+
}
|
|
3721
|
+
function invalidXaiBatchResult(id) {
|
|
3722
|
+
return {
|
|
3723
|
+
id,
|
|
3724
|
+
status: "failed",
|
|
3725
|
+
error: {
|
|
3726
|
+
message: "xAI returned an invalid Responses batch result.",
|
|
3727
|
+
code: "invalid_response"
|
|
3728
|
+
}
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
function convertXaiChatBatchResponse(response) {
|
|
3732
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3733
|
+
if (response.error != null) {
|
|
3734
|
+
return {
|
|
3735
|
+
success: false,
|
|
3736
|
+
error: {
|
|
3737
|
+
message: response.error,
|
|
3738
|
+
...response.code != null ? { code: response.code } : {}
|
|
3739
|
+
}
|
|
3740
|
+
};
|
|
3741
|
+
}
|
|
3742
|
+
const choice = (_a = response.choices) == null ? void 0 : _a[0];
|
|
3743
|
+
if (choice == null) {
|
|
3744
|
+
return {
|
|
3745
|
+
success: false,
|
|
3746
|
+
error: {
|
|
3747
|
+
message: "xAI returned a batch response without any choices.",
|
|
3748
|
+
code: "invalid_response"
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
if ((_b = choice.message.tool_calls) == null ? void 0 : _b.length) {
|
|
3753
|
+
return unsupportedXaiBatchContent("tool_calls");
|
|
3754
|
+
}
|
|
3755
|
+
const content = [];
|
|
3756
|
+
if (choice.message.content) {
|
|
3757
|
+
content.push({ type: "text", text: choice.message.content });
|
|
3758
|
+
}
|
|
3759
|
+
if (choice.message.reasoning_content) {
|
|
3760
|
+
content.push({
|
|
3761
|
+
type: "reasoning",
|
|
3762
|
+
text: choice.message.reasoning_content
|
|
3763
|
+
});
|
|
3764
|
+
}
|
|
3765
|
+
for (const url of (_c = response.citations) != null ? _c : []) {
|
|
3766
|
+
content.push({
|
|
3767
|
+
type: "source",
|
|
3768
|
+
sourceType: "url",
|
|
3769
|
+
id: url,
|
|
3770
|
+
url
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3773
|
+
return {
|
|
3774
|
+
success: true,
|
|
3775
|
+
result: {
|
|
3776
|
+
content,
|
|
3777
|
+
finishReason: {
|
|
3778
|
+
unified: mapXaiFinishReason(choice.finish_reason),
|
|
3779
|
+
raw: (_d = choice.finish_reason) != null ? _d : void 0
|
|
3780
|
+
},
|
|
3781
|
+
usage: response.usage ? convertXaiChatUsage(response.usage) : createNullLanguageModelUsage(),
|
|
3782
|
+
response: getResponseMetadata(response),
|
|
3783
|
+
warnings: [],
|
|
3784
|
+
...(((_e = response.usage) == null ? void 0 : _e.cost_in_usd_ticks) != null || response.service_tier != null) && {
|
|
3785
|
+
providerMetadata: {
|
|
3786
|
+
xai: {
|
|
3787
|
+
...((_f = response.usage) == null ? void 0 : _f.cost_in_usd_ticks) != null ? { costInUsdTicks: response.usage.cost_in_usd_ticks } : {},
|
|
3788
|
+
...response.service_tier != null ? { serviceTier: response.service_tier } : {}
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
};
|
|
3794
|
+
}
|
|
3795
|
+
function unsupportedXaiBatchContent(type) {
|
|
3796
|
+
return {
|
|
3797
|
+
success: false,
|
|
3798
|
+
error: {
|
|
3799
|
+
message: `xAI returned "${type}" content, but tool content is not supported in AI SDK text batches.`,
|
|
3800
|
+
code: "unsupported_content"
|
|
3801
|
+
}
|
|
3802
|
+
};
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3313
3805
|
// src/realtime/xai-realtime-event-mapper.ts
|
|
3314
3806
|
function parseXaiRealtimeServerEvent(raw) {
|
|
3315
3807
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
@@ -3681,43 +4173,43 @@ var XaiRealtimeModel = class {
|
|
|
3681
4173
|
|
|
3682
4174
|
// src/tool/code-execution.ts
|
|
3683
4175
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory6 } from "@ai-sdk/provider-utils";
|
|
3684
|
-
import { z as
|
|
3685
|
-
var codeExecutionOutputSchema =
|
|
3686
|
-
output:
|
|
3687
|
-
error:
|
|
4176
|
+
import { z as z16 } from "zod/v4";
|
|
4177
|
+
var codeExecutionOutputSchema = z16.object({
|
|
4178
|
+
output: z16.string().describe("the output of the code execution"),
|
|
4179
|
+
error: z16.string().optional().describe("any error that occurred")
|
|
3688
4180
|
});
|
|
3689
4181
|
var codeExecutionToolFactory = createProviderExecutedToolFactory6({
|
|
3690
4182
|
id: "xai.code_execution",
|
|
3691
|
-
inputSchema:
|
|
4183
|
+
inputSchema: z16.object({}).describe("no input parameters"),
|
|
3692
4184
|
outputSchema: codeExecutionOutputSchema
|
|
3693
4185
|
});
|
|
3694
4186
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
3695
4187
|
|
|
3696
4188
|
// src/tool/view-image.ts
|
|
3697
4189
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory7 } from "@ai-sdk/provider-utils";
|
|
3698
|
-
import { z as
|
|
3699
|
-
var viewImageOutputSchema =
|
|
3700
|
-
description:
|
|
3701
|
-
objects:
|
|
4190
|
+
import { z as z17 } from "zod/v4";
|
|
4191
|
+
var viewImageOutputSchema = z17.object({
|
|
4192
|
+
description: z17.string().describe("description of the image"),
|
|
4193
|
+
objects: z17.array(z17.string()).optional().describe("objects detected in the image")
|
|
3702
4194
|
});
|
|
3703
4195
|
var viewImageToolFactory = createProviderExecutedToolFactory7({
|
|
3704
4196
|
id: "xai.view_image",
|
|
3705
|
-
inputSchema:
|
|
4197
|
+
inputSchema: z17.object({}).describe("no input parameters"),
|
|
3706
4198
|
outputSchema: viewImageOutputSchema
|
|
3707
4199
|
});
|
|
3708
4200
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
3709
4201
|
|
|
3710
4202
|
// src/tool/view-x-video.ts
|
|
3711
4203
|
import { createProviderExecutedToolFactory as createProviderExecutedToolFactory8 } from "@ai-sdk/provider-utils";
|
|
3712
|
-
import { z as
|
|
3713
|
-
var viewXVideoOutputSchema =
|
|
3714
|
-
transcript:
|
|
3715
|
-
description:
|
|
3716
|
-
duration:
|
|
4204
|
+
import { z as z18 } from "zod/v4";
|
|
4205
|
+
var viewXVideoOutputSchema = z18.object({
|
|
4206
|
+
transcript: z18.string().optional().describe("transcript of the video"),
|
|
4207
|
+
description: z18.string().describe("description of the video content"),
|
|
4208
|
+
duration: z18.number().optional().describe("duration in seconds")
|
|
3717
4209
|
});
|
|
3718
4210
|
var viewXVideoToolFactory = createProviderExecutedToolFactory8({
|
|
3719
4211
|
id: "xai.view_x_video",
|
|
3720
|
-
inputSchema:
|
|
4212
|
+
inputSchema: z18.object({}).describe("no input parameters"),
|
|
3721
4213
|
outputSchema: viewXVideoOutputSchema
|
|
3722
4214
|
});
|
|
3723
4215
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -3735,45 +4227,28 @@ var xaiTools = {
|
|
|
3735
4227
|
};
|
|
3736
4228
|
|
|
3737
4229
|
// src/version.ts
|
|
3738
|
-
var VERSION = true ? "4.0.
|
|
4230
|
+
var VERSION = true ? "4.0.47" : "0.0.0-test";
|
|
3739
4231
|
|
|
3740
4232
|
// src/files/xai-files.ts
|
|
3741
4233
|
import {
|
|
3742
|
-
combineHeaders as
|
|
4234
|
+
combineHeaders as combineHeaders5,
|
|
3743
4235
|
convertInlineFileDataToUint8Array,
|
|
3744
|
-
createJsonResponseHandler as
|
|
4236
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3745
4237
|
parseProviderOptions as parseProviderOptions6,
|
|
3746
|
-
postFormDataToApi
|
|
4238
|
+
postFormDataToApi as postFormDataToApi2
|
|
3747
4239
|
} from "@ai-sdk/provider-utils";
|
|
3748
4240
|
|
|
3749
|
-
// src/files/xai-files-api.ts
|
|
3750
|
-
import { lazySchema as lazySchema6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
|
|
3751
|
-
import { z as z17 } from "zod/v4";
|
|
3752
|
-
var xaiFilesResponseSchema = lazySchema6(
|
|
3753
|
-
() => zodSchema6(
|
|
3754
|
-
z17.object({
|
|
3755
|
-
id: z17.string(),
|
|
3756
|
-
object: z17.string().nullish(),
|
|
3757
|
-
bytes: z17.number().nullish(),
|
|
3758
|
-
created_at: z17.number().nullish(),
|
|
3759
|
-
filename: z17.string().nullish(),
|
|
3760
|
-
purpose: z17.string().nullish(),
|
|
3761
|
-
status: z17.string().nullish()
|
|
3762
|
-
})
|
|
3763
|
-
)
|
|
3764
|
-
);
|
|
3765
|
-
|
|
3766
4241
|
// src/files/xai-files-options.ts
|
|
3767
4242
|
import {
|
|
3768
|
-
lazySchema as
|
|
3769
|
-
zodSchema as
|
|
4243
|
+
lazySchema as lazySchema8,
|
|
4244
|
+
zodSchema as zodSchema8
|
|
3770
4245
|
} from "@ai-sdk/provider-utils";
|
|
3771
|
-
import { z as
|
|
3772
|
-
var xaiFilesOptionsSchema =
|
|
3773
|
-
() =>
|
|
3774
|
-
|
|
3775
|
-
teamId:
|
|
3776
|
-
filePath:
|
|
4246
|
+
import { z as z19 } from "zod/v4";
|
|
4247
|
+
var xaiFilesOptionsSchema = lazySchema8(
|
|
4248
|
+
() => zodSchema8(
|
|
4249
|
+
z19.looseObject({
|
|
4250
|
+
teamId: z19.string().optional(),
|
|
4251
|
+
filePath: z19.string().optional()
|
|
3777
4252
|
})
|
|
3778
4253
|
)
|
|
3779
4254
|
);
|
|
@@ -3812,12 +4287,12 @@ var XaiFiles = class {
|
|
|
3812
4287
|
if ((xaiOptions == null ? void 0 : xaiOptions.teamId) != null) {
|
|
3813
4288
|
formData.append("team_id", xaiOptions.teamId);
|
|
3814
4289
|
}
|
|
3815
|
-
const { value: response } = await
|
|
4290
|
+
const { value: response } = await postFormDataToApi2({
|
|
3816
4291
|
url: `${this.config.baseURL}/files`,
|
|
3817
|
-
headers:
|
|
4292
|
+
headers: combineHeaders5(this.config.headers()),
|
|
3818
4293
|
formData,
|
|
3819
4294
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
3820
|
-
successfulResponseHandler:
|
|
4295
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
3821
4296
|
xaiFilesResponseSchema
|
|
3822
4297
|
),
|
|
3823
4298
|
fetch: this.config.fetch
|
|
@@ -3844,42 +4319,46 @@ import {
|
|
|
3844
4319
|
APICallError as APICallError2
|
|
3845
4320
|
} from "@ai-sdk/provider";
|
|
3846
4321
|
import {
|
|
3847
|
-
combineHeaders as
|
|
4322
|
+
combineHeaders as combineHeaders6,
|
|
3848
4323
|
convertUint8ArrayToBase64,
|
|
3849
|
-
createJsonResponseHandler as
|
|
4324
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
3850
4325
|
extractResponseHeaders as extractResponseHeaders2,
|
|
3851
|
-
getFromApi as
|
|
4326
|
+
getFromApi as getFromApi3,
|
|
3852
4327
|
getTopLevelMediaType as getTopLevelMediaType3,
|
|
3853
4328
|
parseProviderOptions as parseProviderOptions7,
|
|
3854
|
-
postJsonToApi as
|
|
4329
|
+
postJsonToApi as postJsonToApi5,
|
|
3855
4330
|
safeParseJSON as safeParseJSON2
|
|
3856
4331
|
} from "@ai-sdk/provider-utils";
|
|
3857
|
-
import { z as
|
|
4332
|
+
import { z as z21 } from "zod/v4";
|
|
3858
4333
|
|
|
3859
4334
|
// src/xai-video-model-options.ts
|
|
3860
|
-
import { lazySchema as
|
|
3861
|
-
import { z as
|
|
3862
|
-
var nonEmptyStringSchema =
|
|
3863
|
-
var resolutionSchema =
|
|
3864
|
-
var modeSchema =
|
|
4335
|
+
import { lazySchema as lazySchema9, zodSchema as zodSchema9 } from "@ai-sdk/provider-utils";
|
|
4336
|
+
import { z as z20 } from "zod/v4";
|
|
4337
|
+
var nonEmptyStringSchema = z20.string().min(1);
|
|
4338
|
+
var resolutionSchema = z20.enum(["480p", "720p", "1080p"]);
|
|
4339
|
+
var modeSchema = z20.enum(["edit-video", "extend-video", "reference-to-video"]);
|
|
3865
4340
|
var baseFields = {
|
|
3866
|
-
pollIntervalMs:
|
|
3867
|
-
pollTimeoutMs:
|
|
4341
|
+
pollIntervalMs: z20.number().positive().nullish(),
|
|
4342
|
+
pollTimeoutMs: z20.number().positive().nullish(),
|
|
3868
4343
|
resolution: resolutionSchema.nullish()
|
|
3869
4344
|
};
|
|
3870
|
-
var runtimeSchema =
|
|
4345
|
+
var runtimeSchema = z20.looseObject({
|
|
3871
4346
|
mode: modeSchema.optional(),
|
|
3872
4347
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
3873
|
-
referenceImageUrls:
|
|
3874
|
-
referenceVoiceIds:
|
|
3875
|
-
user:
|
|
4348
|
+
referenceImageUrls: z20.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
4349
|
+
referenceVoiceIds: z20.array(nonEmptyStringSchema).max(3).optional(),
|
|
4350
|
+
user: z20.string().optional(),
|
|
3876
4351
|
...baseFields
|
|
3877
4352
|
});
|
|
3878
|
-
var xaiVideoModelOptionsSchema =
|
|
3879
|
-
() =>
|
|
4353
|
+
var xaiVideoModelOptionsSchema = lazySchema9(
|
|
4354
|
+
() => zodSchema9(runtimeSchema)
|
|
3880
4355
|
);
|
|
3881
4356
|
|
|
3882
4357
|
// src/xai-video-model.ts
|
|
4358
|
+
function encodePathSegment(value) {
|
|
4359
|
+
const encodedValue = encodeURIComponent(value);
|
|
4360
|
+
return encodedValue === "." ? "%252E" : encodedValue === ".." ? "%252E%252E" : encodedValue;
|
|
4361
|
+
}
|
|
3883
4362
|
var RESOLUTION_MAP = {
|
|
3884
4363
|
"1920x1080": "1080p",
|
|
3885
4364
|
"1280x720": "720p",
|
|
@@ -4166,12 +4645,12 @@ var XaiVideoModel = class {
|
|
|
4166
4645
|
} else {
|
|
4167
4646
|
endpoint = `${baseURL}/videos/generations`;
|
|
4168
4647
|
}
|
|
4169
|
-
const { value: createResponse, responseHeaders } = await
|
|
4648
|
+
const { value: createResponse, responseHeaders } = await postJsonToApi5({
|
|
4170
4649
|
url: endpoint,
|
|
4171
|
-
headers:
|
|
4650
|
+
headers: combineHeaders6(this.config.headers(), options.headers),
|
|
4172
4651
|
body,
|
|
4173
4652
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4174
|
-
successfulResponseHandler:
|
|
4653
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
4175
4654
|
xaiCreateVideoResponseSchema
|
|
4176
4655
|
),
|
|
4177
4656
|
abortSignal: options.abortSignal,
|
|
@@ -4199,10 +4678,10 @@ var XaiVideoModel = class {
|
|
|
4199
4678
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
4200
4679
|
const { requestId } = options.operation;
|
|
4201
4680
|
const baseURL = (_d = this.config.baseURL) != null ? _d : "https://api.x.ai/v1";
|
|
4202
|
-
const { value: statusResponse, responseHeaders } = await
|
|
4203
|
-
url: `${baseURL}/videos/${requestId}`,
|
|
4681
|
+
const { value: statusResponse, responseHeaders } = await getFromApi3({
|
|
4682
|
+
url: `${baseURL}/videos/${encodePathSegment(requestId)}`,
|
|
4204
4683
|
validateUrl: false,
|
|
4205
|
-
headers:
|
|
4684
|
+
headers: combineHeaders6(this.config.headers(), options.headers),
|
|
4206
4685
|
successfulResponseHandler: xaiVideoStatusResponseHandler,
|
|
4207
4686
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4208
4687
|
abortSignal: options.abortSignal,
|
|
@@ -4290,27 +4769,27 @@ var XaiVideoModel = class {
|
|
|
4290
4769
|
};
|
|
4291
4770
|
}
|
|
4292
4771
|
};
|
|
4293
|
-
var xaiCreateVideoResponseSchema =
|
|
4294
|
-
request_id:
|
|
4772
|
+
var xaiCreateVideoResponseSchema = z21.object({
|
|
4773
|
+
request_id: z21.string().nullish()
|
|
4295
4774
|
});
|
|
4296
|
-
var xaiVideoStatusResponseSchema =
|
|
4297
|
-
status:
|
|
4298
|
-
video:
|
|
4299
|
-
url:
|
|
4300
|
-
duration:
|
|
4301
|
-
respect_moderation:
|
|
4775
|
+
var xaiVideoStatusResponseSchema = z21.object({
|
|
4776
|
+
status: z21.string().nullish(),
|
|
4777
|
+
video: z21.object({
|
|
4778
|
+
url: z21.string(),
|
|
4779
|
+
duration: z21.number().nullish(),
|
|
4780
|
+
respect_moderation: z21.boolean().nullish()
|
|
4302
4781
|
}).nullish(),
|
|
4303
|
-
model:
|
|
4304
|
-
usage:
|
|
4305
|
-
cost_in_usd_ticks:
|
|
4782
|
+
model: z21.string().nullish(),
|
|
4783
|
+
usage: z21.object({
|
|
4784
|
+
cost_in_usd_ticks: z21.number().nullish()
|
|
4306
4785
|
}).nullish(),
|
|
4307
|
-
progress:
|
|
4308
|
-
error:
|
|
4309
|
-
code:
|
|
4310
|
-
message:
|
|
4786
|
+
progress: z21.number().nullish(),
|
|
4787
|
+
error: z21.object({
|
|
4788
|
+
code: z21.string().nullish(),
|
|
4789
|
+
message: z21.string().nullish()
|
|
4311
4790
|
}).nullish()
|
|
4312
4791
|
});
|
|
4313
|
-
var xaiVideoStatusJsonResponseHandler =
|
|
4792
|
+
var xaiVideoStatusJsonResponseHandler = createJsonResponseHandler6(
|
|
4314
4793
|
xaiVideoStatusResponseSchema
|
|
4315
4794
|
);
|
|
4316
4795
|
var MAX_PENDING_BODY_BYTES = 1024 * 1024;
|
|
@@ -4374,69 +4853,69 @@ var xaiVideoStatusResponseHandler = async (options) => {
|
|
|
4374
4853
|
|
|
4375
4854
|
// src/xai-speech-model.ts
|
|
4376
4855
|
import {
|
|
4377
|
-
combineHeaders as
|
|
4856
|
+
combineHeaders as combineHeaders7,
|
|
4378
4857
|
convertBase64ToUint8Array,
|
|
4379
4858
|
createBinaryResponseHandler as createBinaryResponseHandler2,
|
|
4380
|
-
createJsonResponseHandler as
|
|
4859
|
+
createJsonResponseHandler as createJsonResponseHandler7,
|
|
4381
4860
|
parseProviderOptions as parseProviderOptions8,
|
|
4382
|
-
postJsonToApi as
|
|
4861
|
+
postJsonToApi as postJsonToApi6,
|
|
4383
4862
|
resolve,
|
|
4384
4863
|
serializeModelOptions as serializeModelOptions4,
|
|
4385
|
-
WORKFLOW_DESERIALIZE as
|
|
4386
|
-
WORKFLOW_SERIALIZE as
|
|
4864
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
|
|
4865
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
|
|
4387
4866
|
} from "@ai-sdk/provider-utils";
|
|
4388
|
-
import { z as
|
|
4867
|
+
import { z as z23 } from "zod/v4";
|
|
4389
4868
|
|
|
4390
4869
|
// src/xai-speech-model-options.ts
|
|
4391
4870
|
import {
|
|
4392
|
-
lazySchema as
|
|
4393
|
-
zodSchema as
|
|
4871
|
+
lazySchema as lazySchema10,
|
|
4872
|
+
zodSchema as zodSchema10
|
|
4394
4873
|
} from "@ai-sdk/provider-utils";
|
|
4395
|
-
import { z as
|
|
4396
|
-
var xaiSpeechModelOptionsSchema =
|
|
4397
|
-
() =>
|
|
4398
|
-
|
|
4874
|
+
import { z as z22 } from "zod/v4";
|
|
4875
|
+
var xaiSpeechModelOptionsSchema = lazySchema10(
|
|
4876
|
+
() => zodSchema10(
|
|
4877
|
+
z22.object({
|
|
4399
4878
|
/**
|
|
4400
4879
|
* Sample rate of the generated audio in Hz.
|
|
4401
4880
|
*/
|
|
4402
|
-
sampleRate:
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4881
|
+
sampleRate: z22.union([
|
|
4882
|
+
z22.literal(8e3),
|
|
4883
|
+
z22.literal(16e3),
|
|
4884
|
+
z22.literal(22050),
|
|
4885
|
+
z22.literal(24e3),
|
|
4886
|
+
z22.literal(44100),
|
|
4887
|
+
z22.literal(48e3)
|
|
4409
4888
|
]).nullish(),
|
|
4410
4889
|
/**
|
|
4411
4890
|
* MP3 bit rate in bits per second. Only applies when outputFormat is mp3.
|
|
4412
4891
|
*/
|
|
4413
|
-
bitRate:
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4892
|
+
bitRate: z22.union([
|
|
4893
|
+
z22.literal(32e3),
|
|
4894
|
+
z22.literal(64e3),
|
|
4895
|
+
z22.literal(96e3),
|
|
4896
|
+
z22.literal(128e3),
|
|
4897
|
+
z22.literal(192e3)
|
|
4419
4898
|
]).nullish(),
|
|
4420
4899
|
/**
|
|
4421
4900
|
* Reduce time to first audio chunk, trading some quality for latency.
|
|
4422
4901
|
*/
|
|
4423
|
-
optimizeStreamingLatency:
|
|
4902
|
+
optimizeStreamingLatency: z22.union([z22.literal(0), z22.literal(1), z22.literal(2)]).nullish(),
|
|
4424
4903
|
/**
|
|
4425
4904
|
* Normalize written-form text into spoken-form text before synthesis.
|
|
4426
4905
|
*/
|
|
4427
|
-
textNormalization:
|
|
4906
|
+
textNormalization: z22.boolean().nullish(),
|
|
4428
4907
|
/**
|
|
4429
4908
|
* Return character-level timing metadata alongside the audio. When
|
|
4430
4909
|
* enabled, the response carries per-character start/end times and the
|
|
4431
4910
|
* total duration, exposed via `providerMetadata.xai`.
|
|
4432
4911
|
*/
|
|
4433
|
-
withTimestamps:
|
|
4912
|
+
withTimestamps: z22.boolean().nullish(),
|
|
4434
4913
|
/**
|
|
4435
4914
|
* Map of phrases to spoken substitutions applied before synthesis.
|
|
4436
4915
|
* Values may be respellings (`{ 'Acme Mobile': 'Acme Mobull' }`) or IPA
|
|
4437
4916
|
* phonetics (`{ nginx: '/ˈɛndʒɪn ˈɛks/' }`).
|
|
4438
4917
|
*/
|
|
4439
|
-
replace:
|
|
4918
|
+
replace: z22.record(z22.string(), z22.string()).nullish()
|
|
4440
4919
|
})
|
|
4441
4920
|
)
|
|
4442
4921
|
);
|
|
@@ -4448,13 +4927,13 @@ var XaiSpeechModel = class _XaiSpeechModel {
|
|
|
4448
4927
|
this.config = config;
|
|
4449
4928
|
this.specificationVersion = "v4";
|
|
4450
4929
|
}
|
|
4451
|
-
static [
|
|
4930
|
+
static [WORKFLOW_SERIALIZE5](model) {
|
|
4452
4931
|
return serializeModelOptions4({
|
|
4453
4932
|
modelId: model.modelId,
|
|
4454
4933
|
config: model.config
|
|
4455
4934
|
});
|
|
4456
4935
|
}
|
|
4457
|
-
static [
|
|
4936
|
+
static [WORKFLOW_DESERIALIZE5](options) {
|
|
4458
4937
|
return new _XaiSpeechModel(options.modelId, options.config);
|
|
4459
4938
|
}
|
|
4460
4939
|
get provider() {
|
|
@@ -4530,15 +5009,15 @@ var XaiSpeechModel = class _XaiSpeechModel {
|
|
|
4530
5009
|
var _a, _b, _c;
|
|
4531
5010
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
4532
5011
|
const { requestBody, warnings, withTimestamps } = await this.getArgs(options);
|
|
4533
|
-
const { value, responseHeaders, rawValue } = await
|
|
5012
|
+
const { value, responseHeaders, rawValue } = await postJsonToApi6({
|
|
4534
5013
|
url: `${this.config.baseURL}/tts`,
|
|
4535
|
-
headers:
|
|
5014
|
+
headers: combineHeaders7(
|
|
4536
5015
|
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
4537
5016
|
options.headers
|
|
4538
5017
|
),
|
|
4539
5018
|
body: requestBody,
|
|
4540
5019
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4541
|
-
successfulResponseHandler: withTimestamps ?
|
|
5020
|
+
successfulResponseHandler: withTimestamps ? createJsonResponseHandler7(xaiSpeechTimestampsResponseSchema) : createBinaryResponseHandler2(),
|
|
4542
5021
|
abortSignal: options.abortSignal,
|
|
4543
5022
|
fetch: this.config.fetch
|
|
4544
5023
|
});
|
|
@@ -4579,109 +5058,109 @@ var XaiSpeechModel = class _XaiSpeechModel {
|
|
|
4579
5058
|
};
|
|
4580
5059
|
}
|
|
4581
5060
|
};
|
|
4582
|
-
var xaiSpeechTimestampsResponseSchema =
|
|
4583
|
-
audio:
|
|
4584
|
-
content_type:
|
|
4585
|
-
duration:
|
|
4586
|
-
audio_timestamps:
|
|
4587
|
-
graph_chars:
|
|
4588
|
-
graph_times:
|
|
5061
|
+
var xaiSpeechTimestampsResponseSchema = z23.object({
|
|
5062
|
+
audio: z23.string().nullish(),
|
|
5063
|
+
content_type: z23.string().nullish(),
|
|
5064
|
+
duration: z23.number().nullish(),
|
|
5065
|
+
audio_timestamps: z23.object({
|
|
5066
|
+
graph_chars: z23.array(z23.string()),
|
|
5067
|
+
graph_times: z23.array(z23.tuple([z23.number(), z23.number()]))
|
|
4589
5068
|
}).nullish()
|
|
4590
5069
|
});
|
|
4591
5070
|
|
|
4592
5071
|
// src/xai-transcription-model.ts
|
|
4593
5072
|
import {
|
|
4594
|
-
InvalidArgumentError
|
|
5073
|
+
InvalidArgumentError as InvalidArgumentError2
|
|
4595
5074
|
} from "@ai-sdk/provider";
|
|
4596
5075
|
import {
|
|
4597
|
-
combineHeaders as
|
|
5076
|
+
combineHeaders as combineHeaders8,
|
|
4598
5077
|
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
4599
|
-
createJsonResponseHandler as
|
|
5078
|
+
createJsonResponseHandler as createJsonResponseHandler8,
|
|
4600
5079
|
connectToWebSocket,
|
|
4601
5080
|
mediaTypeToExtension,
|
|
4602
5081
|
parseProviderOptions as parseProviderOptions9,
|
|
4603
|
-
postFormDataToApi as
|
|
5082
|
+
postFormDataToApi as postFormDataToApi3,
|
|
4604
5083
|
safeParseJSON as safeParseJSON3,
|
|
4605
5084
|
serializeModelOptions as serializeModelOptions5,
|
|
4606
5085
|
toWebSocketUrl,
|
|
4607
5086
|
waitForWebSocketBufferDrain,
|
|
4608
|
-
WORKFLOW_DESERIALIZE as
|
|
4609
|
-
WORKFLOW_SERIALIZE as
|
|
5087
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE6,
|
|
5088
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE6
|
|
4610
5089
|
} from "@ai-sdk/provider-utils";
|
|
4611
|
-
import { z as
|
|
5090
|
+
import { z as z25 } from "zod/v4";
|
|
4612
5091
|
|
|
4613
5092
|
// src/xai-transcription-model-options.ts
|
|
4614
5093
|
import {
|
|
4615
|
-
lazySchema as
|
|
4616
|
-
zodSchema as
|
|
5094
|
+
lazySchema as lazySchema11,
|
|
5095
|
+
zodSchema as zodSchema11
|
|
4617
5096
|
} from "@ai-sdk/provider-utils";
|
|
4618
|
-
import { z as
|
|
4619
|
-
var xaiTranscriptionModelOptionsSchema =
|
|
4620
|
-
() =>
|
|
4621
|
-
|
|
5097
|
+
import { z as z24 } from "zod/v4";
|
|
5098
|
+
var xaiTranscriptionModelOptionsSchema = lazySchema11(
|
|
5099
|
+
() => zodSchema11(
|
|
5100
|
+
z24.object({
|
|
4622
5101
|
/**
|
|
4623
5102
|
* Audio encoding for raw, headerless input audio.
|
|
4624
5103
|
*/
|
|
4625
|
-
audioFormat:
|
|
5104
|
+
audioFormat: z24.enum(["pcm", "mulaw", "alaw"]).nullish(),
|
|
4626
5105
|
/**
|
|
4627
5106
|
* Sample rate of the input audio in Hz.
|
|
4628
5107
|
*/
|
|
4629
|
-
sampleRate:
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
5108
|
+
sampleRate: z24.union([
|
|
5109
|
+
z24.literal(8e3),
|
|
5110
|
+
z24.literal(16e3),
|
|
5111
|
+
z24.literal(22050),
|
|
5112
|
+
z24.literal(24e3),
|
|
5113
|
+
z24.literal(44100),
|
|
5114
|
+
z24.literal(48e3)
|
|
4636
5115
|
]).nullish(),
|
|
4637
5116
|
/**
|
|
4638
5117
|
* Language code used for inverse text normalization.
|
|
4639
5118
|
*/
|
|
4640
|
-
language:
|
|
5119
|
+
language: z24.string().nullish(),
|
|
4641
5120
|
/**
|
|
4642
5121
|
* Enable inverse text normalization. Requires `language`.
|
|
4643
5122
|
*/
|
|
4644
|
-
format:
|
|
5123
|
+
format: z24.boolean().nullish(),
|
|
4645
5124
|
/**
|
|
4646
5125
|
* Enable per-channel transcription for multichannel audio.
|
|
4647
5126
|
*/
|
|
4648
|
-
multichannel:
|
|
5127
|
+
multichannel: z24.boolean().nullish(),
|
|
4649
5128
|
/**
|
|
4650
5129
|
* Number of interleaved audio channels.
|
|
4651
5130
|
*/
|
|
4652
|
-
channels:
|
|
5131
|
+
channels: z24.number().int().min(2).max(8).nullish(),
|
|
4653
5132
|
/**
|
|
4654
5133
|
* Enable speaker diarization.
|
|
4655
5134
|
*/
|
|
4656
|
-
diarize:
|
|
5135
|
+
diarize: z24.boolean().nullish(),
|
|
4657
5136
|
/**
|
|
4658
5137
|
* Terms to bias transcription toward.
|
|
4659
5138
|
*/
|
|
4660
|
-
keyterm:
|
|
5139
|
+
keyterm: z24.union([z24.string(), z24.array(z24.string())]).nullish(),
|
|
4661
5140
|
/**
|
|
4662
5141
|
* Include filler words such as "uh" and "um" in the transcript.
|
|
4663
5142
|
*/
|
|
4664
|
-
fillerWords:
|
|
5143
|
+
fillerWords: z24.boolean().nullish(),
|
|
4665
5144
|
/**
|
|
4666
5145
|
* Options for streaming speech-to-text over WebSocket.
|
|
4667
5146
|
*/
|
|
4668
|
-
streaming:
|
|
5147
|
+
streaming: z24.object({
|
|
4669
5148
|
/**
|
|
4670
5149
|
* Emit interim transcript results while speech is being processed.
|
|
4671
5150
|
*/
|
|
4672
|
-
interimResults:
|
|
5151
|
+
interimResults: z24.boolean().optional(),
|
|
4673
5152
|
/**
|
|
4674
5153
|
* Silence duration in milliseconds before an utterance-final event.
|
|
4675
5154
|
*/
|
|
4676
|
-
endpointing:
|
|
5155
|
+
endpointing: z24.number().int().min(0).max(5e3).optional(),
|
|
4677
5156
|
/**
|
|
4678
5157
|
* End-of-turn detection threshold. When set, enables Smart Turn.
|
|
4679
5158
|
*/
|
|
4680
|
-
smartTurn:
|
|
5159
|
+
smartTurn: z24.number().min(0).max(1).optional(),
|
|
4681
5160
|
/**
|
|
4682
5161
|
* Maximum silence duration in milliseconds before forcing speech_final.
|
|
4683
5162
|
*/
|
|
4684
|
-
smartTurnTimeout:
|
|
5163
|
+
smartTurnTimeout: z24.number().int().min(1).max(5e3).optional()
|
|
4685
5164
|
}).optional()
|
|
4686
5165
|
})
|
|
4687
5166
|
)
|
|
@@ -4694,13 +5173,13 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4694
5173
|
this.config = config;
|
|
4695
5174
|
this.specificationVersion = "v4";
|
|
4696
5175
|
}
|
|
4697
|
-
static [
|
|
5176
|
+
static [WORKFLOW_SERIALIZE6](model) {
|
|
4698
5177
|
return serializeModelOptions5({
|
|
4699
5178
|
modelId: model.modelId,
|
|
4700
5179
|
config: model.config
|
|
4701
5180
|
});
|
|
4702
5181
|
}
|
|
4703
|
-
static [
|
|
5182
|
+
static [WORKFLOW_DESERIALIZE6](options) {
|
|
4704
5183
|
return new _XaiTranscriptionModel(options.modelId, options.config);
|
|
4705
5184
|
}
|
|
4706
5185
|
get provider() {
|
|
@@ -4756,12 +5235,12 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4756
5235
|
value: response,
|
|
4757
5236
|
responseHeaders,
|
|
4758
5237
|
rawValue: rawResponse
|
|
4759
|
-
} = await
|
|
5238
|
+
} = await postFormDataToApi3({
|
|
4760
5239
|
url: `${(_d = this.config.baseURL) != null ? _d : "https://api.x.ai/v1"}/stt`,
|
|
4761
|
-
headers:
|
|
5240
|
+
headers: combineHeaders8((_f = (_e = this.config).headers) == null ? void 0 : _f.call(_e), options.headers),
|
|
4762
5241
|
formData,
|
|
4763
5242
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
4764
|
-
successfulResponseHandler:
|
|
5243
|
+
successfulResponseHandler: createJsonResponseHandler8(
|
|
4765
5244
|
xaiTranscriptionResponseSchema
|
|
4766
5245
|
),
|
|
4767
5246
|
abortSignal: options.abortSignal,
|
|
@@ -4795,7 +5274,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4795
5274
|
schema: xaiTranscriptionModelOptionsSchema
|
|
4796
5275
|
});
|
|
4797
5276
|
if ((xaiOptions == null ? void 0 : xaiOptions.multichannel) === true && xaiOptions.channels == null) {
|
|
4798
|
-
throw new
|
|
5277
|
+
throw new InvalidArgumentError2({
|
|
4799
5278
|
argument: "providerOptions",
|
|
4800
5279
|
message: "providerOptions.xai.channels is required when providerOptions.xai.multichannel is true"
|
|
4801
5280
|
});
|
|
@@ -4818,7 +5297,7 @@ var XaiTranscriptionModel = class _XaiTranscriptionModel {
|
|
|
4818
5297
|
inputAudioFormat: options.inputAudioFormat,
|
|
4819
5298
|
providerOptions: xaiOptions
|
|
4820
5299
|
});
|
|
4821
|
-
const headers =
|
|
5300
|
+
const headers = combineHeaders8((_f = (_e = this.config).headers) == null ? void 0 : _f.call(_e), options.headers);
|
|
4822
5301
|
return {
|
|
4823
5302
|
request: { body: url.toString() },
|
|
4824
5303
|
response: {
|
|
@@ -5080,15 +5559,15 @@ function timingFromXaiEvent(event) {
|
|
|
5080
5559
|
...event.start != null && event.duration != null ? { endSecond: event.start + event.duration } : {}
|
|
5081
5560
|
};
|
|
5082
5561
|
}
|
|
5083
|
-
var xaiTranscriptionResponseSchema =
|
|
5084
|
-
text:
|
|
5085
|
-
language:
|
|
5086
|
-
duration:
|
|
5087
|
-
words:
|
|
5088
|
-
|
|
5089
|
-
text:
|
|
5090
|
-
start:
|
|
5091
|
-
end:
|
|
5562
|
+
var xaiTranscriptionResponseSchema = z25.object({
|
|
5563
|
+
text: z25.string(),
|
|
5564
|
+
language: z25.string().nullish(),
|
|
5565
|
+
duration: z25.number().nullish(),
|
|
5566
|
+
words: z25.array(
|
|
5567
|
+
z25.object({
|
|
5568
|
+
text: z25.string(),
|
|
5569
|
+
start: z25.number(),
|
|
5570
|
+
end: z25.number()
|
|
5092
5571
|
})
|
|
5093
5572
|
).nullish()
|
|
5094
5573
|
});
|
|
@@ -5120,7 +5599,7 @@ function createXai(options = {}) {
|
|
|
5120
5599
|
});
|
|
5121
5600
|
};
|
|
5122
5601
|
const createResponsesLanguageModel = (modelId) => {
|
|
5123
|
-
return new
|
|
5602
|
+
return new XaiResponsesBatchLanguageModel(modelId, {
|
|
5124
5603
|
provider: "xai.responses",
|
|
5125
5604
|
baseURL,
|
|
5126
5605
|
headers: getHeaders,
|