Skip to content

Commit cc8ee64

Browse files
yinghsienwucopybara-github
authored andcommitted
chore: add warnings when ephemeral token is used on v1beta or v1
PiperOrigin-RevId: 781100602
1 parent 03336fb commit cc8ee64

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

google/genai/live.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,16 @@ async def connect(
940940
)
941941
method = 'BidiGenerateContentConstrained'
942942
key_name = 'access_token'
943-
943+
if version != 'v1alpha':
944+
warnings.warn(
945+
message=(
946+
"The SDK's ephemeral token support is in v1alpha only."
947+
'Please use client = genai.Client(api_key=token.name, '
948+
'http_options=types.HttpOptions(api_version="v1alpha"))'
949+
' before session connection.'
950+
),
951+
category=errors.ExperimentalWarning,
952+
)
944953
uri = f'{base_url}/ws/google.ai.generativelanguage.{version}.GenerativeService.{method}?{key_name}={api_key}'
945954
headers = self._api_client._http_options.headers
946955

google/genai/tokens.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,18 @@ class AsyncTokens(_api_module.BaseModule):
284284
async def create(
285285
self, *, config: Optional[types.CreateAuthTokenConfigOrDict] = None
286286
) -> types.AuthToken:
287-
"""Creates an auth token asynchronously.
287+
"""Creates an auth token asynchronously. Support in v1alpha only.
288288
289289
Args:
290290
config (CreateAuthTokenConfig): Optional configuration for the request.
291291
292292
Usage:
293293
294294
.. code-block:: python
295+
client = genai.Client(
296+
api_key=API_KEY,
297+
http_options=types.HttpOptions(api_version='v1alpha'),
298+
)
295299
296300
auth_token = await client.aio.tokens.create(
297301
config=types.CreateAuthTokenConfig(

0 commit comments

Comments
 (0)