Skip to content

Commit 2ef4c4d

Browse files
authored
Revert "Update Google AI Studio SDK example to use gateway base URL"
1 parent a8c617b commit 2ef4c4d

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/content/docs/ai-gateway/providers/google-ai-studio.mdx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff 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

6060
const api_token = env.GOOGLE_AI_STUDIO_TOKEN;
6161
const account_id = "";
6262
const 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

0 commit comments

Comments
 (0)