ai 5.0.112 → 5.0.113

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.113
4
+
5
+ ### Patch Changes
6
+
7
+ - 7e6fb4d: fix(gateway): throw error with user-friendly message in non-production environments if `AI_GATEWAY_API_KEY` is not configured
8
+
3
9
  ## 5.0.112
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -777,7 +777,7 @@ function detectMediaType({
777
777
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
778
778
 
779
779
  // src/version.ts
780
- var VERSION = true ? "5.0.112" : "0.0.0-test";
780
+ var VERSION = true ? "5.0.113" : "0.0.0-test";
781
781
 
782
782
  // src/util/download/download.ts
783
783
  var download = async ({ url }) => {
@@ -1496,14 +1496,28 @@ async function standardizePrompt(prompt) {
1496
1496
  var import_gateway2 = require("@ai-sdk/gateway");
1497
1497
  var import_provider20 = require("@ai-sdk/provider");
1498
1498
  function wrapGatewayError(error) {
1499
- if (import_gateway2.GatewayAuthenticationError.isInstance(error) || import_gateway2.GatewayModelNotFoundError.isInstance(error)) {
1499
+ if (!import_gateway2.GatewayAuthenticationError.isInstance(error))
1500
+ return error;
1501
+ const isProductionEnv = (process == null ? void 0 : process.env.NODE_ENV) === "production";
1502
+ const moreInfoURL = "https://ai-sdk.dev/unauthenticated-ai-gateway";
1503
+ if (isProductionEnv) {
1500
1504
  return new import_provider20.AISDKError({
1501
1505
  name: "GatewayError",
1502
- message: "Unauthenticated. Configure AI_GATEWAY_API_KEY or configure and use a provider module. Learn more: https://vercel.link/unauthenticated-ai-gateway",
1503
- cause: error
1506
+ message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
1504
1507
  });
1505
1508
  }
1506
- return error;
1509
+ return Object.assign(
1510
+ new Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
1511
+
1512
+ To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
1513
+
1514
+ Alternatively, you can use a provider module instead of the AI Gateway.
1515
+
1516
+ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
1517
+
1518
+ `),
1519
+ { name: "GatewayAuthenticationError" }
1520
+ );
1507
1521
  }
1508
1522
 
1509
1523
  // src/telemetry/assemble-operation-name.ts