ai 6.0.0-beta.147 → 6.0.0-beta.149

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,18 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.0-beta.149
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e2b04d: fix(gateway): throw error with user-friendly message in non-production environments if `AI_GATEWAY_API_KEY` is not configured
8
+
9
+ ## 6.0.0-beta.148
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [f18ef7f]
14
+ - @ai-sdk/gateway@2.0.0-beta.78
15
+
3
16
  ## 6.0.0-beta.147
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -962,7 +962,7 @@ function detectMediaType({
962
962
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
963
963
 
964
964
  // src/version.ts
965
- var VERSION = true ? "6.0.0-beta.147" : "0.0.0-test";
965
+ var VERSION = true ? "6.0.0-beta.149" : "0.0.0-test";
966
966
 
967
967
  // src/util/download/download.ts
968
968
  var download = async ({ url }) => {
@@ -1817,14 +1817,28 @@ async function standardizePrompt(prompt) {
1817
1817
  var import_gateway2 = require("@ai-sdk/gateway");
1818
1818
  var import_provider20 = require("@ai-sdk/provider");
1819
1819
  function wrapGatewayError(error) {
1820
- if (import_gateway2.GatewayAuthenticationError.isInstance(error) || import_gateway2.GatewayModelNotFoundError.isInstance(error)) {
1820
+ if (!import_gateway2.GatewayAuthenticationError.isInstance(error))
1821
+ return error;
1822
+ const isProductionEnv = (process == null ? void 0 : process.env.NODE_ENV) === "production";
1823
+ const moreInfoURL = "https://v6.ai-sdk.dev/unauthenticated-ai-gateway";
1824
+ if (isProductionEnv) {
1821
1825
  return new import_provider20.AISDKError({
1822
1826
  name: "GatewayError",
1823
- message: "Unauthenticated. Configure AI_GATEWAY_API_KEY or configure and use a provider module. Learn more: https://vercel.link/unauthenticated-ai-gateway-v6",
1824
- cause: error
1827
+ message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
1825
1828
  });
1826
1829
  }
1827
- return error;
1830
+ return Object.assign(
1831
+ new Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
1832
+
1833
+ To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
1834
+
1835
+ Alternatively, you can use a provider module instead of the AI Gateway.
1836
+
1837
+ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
1838
+
1839
+ `),
1840
+ { name: "GatewayAuthenticationError" }
1841
+ );
1828
1842
  }
1829
1843
 
1830
1844
  // src/telemetry/assemble-operation-name.ts