Skip to content

Commit ae0786e

Browse files
committed
Update client ot use GA endpoint
1 parent a14bb72 commit ae0786e

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

genai/count_tokens/count_tokens_compute_with_txt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
def compute_tokens() -> int:
1717
# [START googlegenaisdk_count_tokens_compute_with_txt]
1818
from google import genai
19+
from google.genai.types import HttpOptions
1920

20-
client = genai.Client()
21+
client = genai.Client(http_options=HttpOptions(api_version="v1"))
2122
response = client.models.compute_tokens(
2223
model="gemini-2.0-flash-001",
2324
contents="What's the longest word in the English language?",

genai/count_tokens/count_tokens_resp_with_txt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
def generate_content() -> int:
1717
# [START googlegenaisdk_count_tokens_resp_with_txt]
1818
from google import genai
19+
from google.genai.types import HttpOptions
1920

20-
client = genai.Client()
21+
client = genai.Client(http_options=HttpOptions(api_version="v1"))
2122

2223
prompt = "Why is the sky blue?"
2324

genai/count_tokens/count_tokens_with_txt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
def count_tokens() -> int:
1717
# [START googlegenaisdk_count_tokens_with_txt]
1818
from google import genai
19+
from google.genai.types import HttpOptions
1920

20-
client = genai.Client()
21+
client = genai.Client(http_options=HttpOptions(api_version="v1"))
2122
response = client.models.count_tokens(
2223
model="gemini-2.0-flash-001",
2324
contents="What's the highest mountain in Africa?",

genai/count_tokens/count_tokens_with_txt_img_vid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
def count_tokens() -> int:
1717
# [START googlegenaisdk_count_tokens_with_txt_img_vid]
1818
from google import genai
19-
from google.genai.types import Part
19+
from google.genai.types import HttpOptions, Part
2020

21-
client = genai.Client()
21+
client = genai.Client(http_options=HttpOptions(api_version="v1"))
2222

2323
contents = [
2424
Part.from_uri(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-genai==1.1.0
1+
google-genai==1.2.0

0 commit comments

Comments
 (0)