@providerprotocol/ai 0.0.13 → 0.0.14

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/dist/xai/index.js CHANGED
@@ -450,14 +450,22 @@ function createCompletionsLLMHandler() {
450
450
  );
451
451
  const baseUrl = request.config.baseUrl ?? XAI_COMPLETIONS_API_URL;
452
452
  const body = transformRequest(request, modelId);
453
+ const headers = {
454
+ "Content-Type": "application/json",
455
+ Authorization: `Bearer ${apiKey}`
456
+ };
457
+ if (request.config.headers) {
458
+ for (const [key, value] of Object.entries(request.config.headers)) {
459
+ if (value !== void 0) {
460
+ headers[key] = value;
461
+ }
462
+ }
463
+ }
453
464
  const response = await doFetch(
454
465
  baseUrl,
455
466
  {
456
467
  method: "POST",
457
- headers: {
458
- "Content-Type": "application/json",
459
- Authorization: `Bearer ${apiKey}`
460
- },
468
+ headers,
461
469
  body: JSON.stringify(body),
462
470
  signal: request.signal
463
471
  },
@@ -488,14 +496,22 @@ function createCompletionsLLMHandler() {
488
496
  const body = transformRequest(request, modelId);
489
497
  body.stream = true;
490
498
  body.stream_options = { include_usage: true };
499
+ const headers = {
500
+ "Content-Type": "application/json",
501
+ Authorization: `Bearer ${apiKey}`
502
+ };
503
+ if (request.config.headers) {
504
+ for (const [key, value] of Object.entries(request.config.headers)) {
505
+ if (value !== void 0) {
506
+ headers[key] = value;
507
+ }
508
+ }
509
+ }
491
510
  const response = await doStreamFetch(
492
511
  baseUrl,
493
512
  {
494
513
  method: "POST",
495
- headers: {
496
- "Content-Type": "application/json",
497
- Authorization: `Bearer ${apiKey}`
498
- },
514
+ headers,
499
515
  body: JSON.stringify(body),
500
516
  signal: request.signal
501
517
  },
@@ -1091,14 +1107,22 @@ function createResponsesLLMHandler() {
1091
1107
  );
1092
1108
  const baseUrl = request.config.baseUrl ?? XAI_RESPONSES_API_URL;
1093
1109
  const body = transformRequest2(request, modelId);
1110
+ const headers = {
1111
+ "Content-Type": "application/json",
1112
+ Authorization: `Bearer ${apiKey}`
1113
+ };
1114
+ if (request.config.headers) {
1115
+ for (const [key, value] of Object.entries(request.config.headers)) {
1116
+ if (value !== void 0) {
1117
+ headers[key] = value;
1118
+ }
1119
+ }
1120
+ }
1094
1121
  const response = await doFetch(
1095
1122
  baseUrl,
1096
1123
  {
1097
1124
  method: "POST",
1098
- headers: {
1099
- "Content-Type": "application/json",
1100
- Authorization: `Bearer ${apiKey}`
1101
- },
1125
+ headers,
1102
1126
  body: JSON.stringify(body),
1103
1127
  signal: request.signal
1104
1128
  },
@@ -1136,14 +1160,22 @@ function createResponsesLLMHandler() {
1136
1160
  const baseUrl = request.config.baseUrl ?? XAI_RESPONSES_API_URL;
1137
1161
  const body = transformRequest2(request, modelId);
1138
1162
  body.stream = true;
1163
+ const headers = {
1164
+ "Content-Type": "application/json",
1165
+ Authorization: `Bearer ${apiKey}`
1166
+ };
1167
+ if (request.config.headers) {
1168
+ for (const [key, value] of Object.entries(request.config.headers)) {
1169
+ if (value !== void 0) {
1170
+ headers[key] = value;
1171
+ }
1172
+ }
1173
+ }
1139
1174
  const response = await doStreamFetch(
1140
1175
  baseUrl,
1141
1176
  {
1142
1177
  method: "POST",
1143
- headers: {
1144
- "Content-Type": "application/json",
1145
- Authorization: `Bearer ${apiKey}`
1146
- },
1178
+ headers,
1147
1179
  body: JSON.stringify(body),
1148
1180
  signal: request.signal
1149
1181
  },
@@ -1571,15 +1603,23 @@ function createMessagesLLMHandler() {
1571
1603
  );
1572
1604
  const baseUrl = request.config.baseUrl ?? XAI_MESSAGES_API_URL;
1573
1605
  const body = transformRequest3(request, modelId);
1606
+ const headers = {
1607
+ "Content-Type": "application/json",
1608
+ "x-api-key": apiKey,
1609
+ "anthropic-version": "2023-06-01"
1610
+ };
1611
+ if (request.config.headers) {
1612
+ for (const [key, value] of Object.entries(request.config.headers)) {
1613
+ if (value !== void 0) {
1614
+ headers[key] = value;
1615
+ }
1616
+ }
1617
+ }
1574
1618
  const response = await doFetch(
1575
1619
  baseUrl,
1576
1620
  {
1577
1621
  method: "POST",
1578
- headers: {
1579
- "Content-Type": "application/json",
1580
- "x-api-key": apiKey,
1581
- "anthropic-version": "2023-06-01"
1582
- },
1622
+ headers,
1583
1623
  body: JSON.stringify(body),
1584
1624
  signal: request.signal
1585
1625
  },
@@ -1609,15 +1649,23 @@ function createMessagesLLMHandler() {
1609
1649
  const baseUrl = request.config.baseUrl ?? XAI_MESSAGES_API_URL;
1610
1650
  const body = transformRequest3(request, modelId);
1611
1651
  body.stream = true;
1652
+ const headers = {
1653
+ "Content-Type": "application/json",
1654
+ "x-api-key": apiKey,
1655
+ "anthropic-version": "2023-06-01"
1656
+ };
1657
+ if (request.config.headers) {
1658
+ for (const [key, value] of Object.entries(request.config.headers)) {
1659
+ if (value !== void 0) {
1660
+ headers[key] = value;
1661
+ }
1662
+ }
1663
+ }
1612
1664
  const response = await doStreamFetch(
1613
1665
  baseUrl,
1614
1666
  {
1615
1667
  method: "POST",
1616
- headers: {
1617
- "Content-Type": "application/json",
1618
- "x-api-key": apiKey,
1619
- "anthropic-version": "2023-06-01"
1620
- },
1668
+ headers,
1621
1669
  body: JSON.stringify(body),
1622
1670
  signal: request.signal
1623
1671
  },