File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -49,3 +49,4 @@ to comment out cases you do not want to run.
49
49
| [ search_grounding.js] ( ./search_grounding.js ) | Generate with google search grounding |
50
50
| [ log_prob.js] ( ./log_prob.js ) | Generate with log probability for each token |
51
51
| [ text_generation.js] ( ./text_generation.js ) | Generating text |
52
+ | [ api_version.js] ( ./api_version.js ) | Setting api version|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import {
19
+ GoogleGenerativeAI ,
20
+ } from "@google/generative-ai" ;
21
+
22
+ async function apiVersion ( ) {
23
+ // [START api_version]
24
+ // Make sure to include these imports:
25
+ // import { GoogleGenerativeAI } from "@google/generative-ai";
26
+ const genAI = new GoogleGenerativeAI ( process . env . API_KEY ) ;
27
+ const model = genAI . getGenerativeModel (
28
+ { model : "gemini-1.5-flash" } ,
29
+ { apiVersion : "v1alpha" } ,
30
+ ) ;
31
+
32
+ const result = await model . generateContent ( "Why is the sky blue?" ) ;
33
+ console . log ( result . response . text ( ) ) ;
34
+ // [END api_version]
35
+ }
36
+
37
+ apiVersion ( ) ;
Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ async function searchGrounding() {
43
43
} ,
44
44
] ,
45
45
} ,
46
- { apiVersion : "v1beta" } ,
47
46
) ;
48
47
49
48
const prompt = "What is the price of Google stock today?" ;
You can’t perform that action at this time.
0 commit comments