You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-5Lines changed: 2 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,6 @@
1
-
# Google AI SDK for JavaScript
1
+
# Google Generative AI for Node.js
2
2
3
-
> [!NOTE] A new Javascript/Typescript SDK, `@google/genai`
4
-
> ([github](https://github.com/googleapis/js-genai/tree/main)), is currently
5
-
> available in a *preview launch* - designed to work with Gemini 2.0 features
6
-
> and support both the Gemini API and the Vertex API.
3
+
> **IMPORTANT:** This SDK is intended for use with older Gemini models (e.g., Gemini 1.0 Pro, Gemini 1.5 Pro). For access to the latest models, including Gemini 2.0 and Gemini 2.5 Pro, please use the newer SDK available at [https://github.com/googleapis/js-genai](https://github.com/googleapis/js-genai).
7
4
8
5
The Google AI JavaScript SDK is the easiest way for JavaScript developers to
9
6
build with the Gemini API. The Gemini API gives you access to Gemini
// Error parsing JSON is ignored, proceed with original status/text
254
+
}
255
+
256
+
letfinalMessage=`Error fetching from ${url.toString()}: [${response.status}${response.statusText}] ${originalMessage||'Server responded with an error.'}`;// Provide default if message is empty
257
+
258
+
if(isUnsupportedModelError){
259
+
// Prepend the specific message for known unsupported models
260
+
finalMessage=`It looks like you're trying to use a newer Gemini model (${requestedModel}) with an older SDK. This model requires the latest SDK. Please upgrade to the latest SDK available at ${newSdkUrl}. Original error: ${finalMessage}`;
261
+
}elseif((response.status===400||response.status===404)&&(originalMessage.includes("Invalid model")||originalMessage.includes("not found")||originalMessage.includes("API key not valid"))){
262
+
// Add a more general hint for other model-related or key errors that might be due to trying new models/regions
263
+
finalMessage+=`\nHint: If you are trying to use a newer Gemini model (e.g., Gemini 2.0, 2.5 Pro) or a specific region, ensure your API key is valid for that model/region and consider upgrading to the latest SDK: ${newSdkUrl}`;
210
264
}
265
+
211
266
thrownewGoogleGenerativeAIFetchError(
212
-
`Error fetching from ${url.toString()}: [${response.status}${
213
-
response.statusText
214
-
}] ${message}`,
267
+
finalMessage,
215
268
response.status,
216
269
response.statusText,
217
-
errorDetails,
218
270
);
219
-
}
220
-
221
-
/**
222
-
* Generates the request options to be passed to the fetch API.
223
-
* @param requestOptions - The user-defined request options.
0 commit comments