File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed
src/content/docs/ai-gateway/providers Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -50,32 +50,26 @@ curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}/google-ai
5050 }'
5151```
5252
53- ### Use ` @google/genai ` with JavaScript
53+ ### Use ` @google/generative-ai ` with JavaScript
5454
55- If you are using the ` @google/genai ` package, you can set your endpoint like this:
55+ If you are using the ` @google/generative-ai ` package, you can set your endpoint like this:
5656
5757``` js title="JavaScript example"
58- import { GoogleGenAI } from " @google/genai " ;
58+ import { GoogleGenerativeAI } from " @google/generative-ai " ;
5959
6060const api_token = env .GOOGLE_AI_STUDIO_TOKEN ;
6161const account_id = " " ;
6262const gateway_name = " " ;
6363
64- const genAI = new GoogleGenAI ({
65- apiKey: api_token,
66- httpOptions: {
67- baseUrl: ` https://gateway.ai.cloudflare.com/v1/${ account_id} /${ gateway_name} /google-ai-studio` ,
68- },
69- });
70-
71- const model = " gemini-1.5-flash" ;
72- const prompt = " What is Cloudflare?" ;
73- const response = await genAI .models .generateContent ({
74- model,
75- contents: prompt,
76- });
77-
78- console .log (response .text );
64+ const genAI = new GoogleGenerativeAI (api_token);
65+ const model = genAI .getGenerativeModel (
66+ { model: " gemini-1.5-flash" },
67+ {
68+ baseUrl: ` https://gateway.ai.cloudflare.com/v1/${ account_id} /${ gateway_name} /google-ai-studio` ,
69+ },
70+ );
71+
72+ await model .generateContent ([" What is Cloudflare?" ]);
7973```
8074
8175<Render
You can’t perform that action at this time.
0 commit comments