Skip to content

Instantly share code, notes, and snippets.

@oberstet
Created May 27, 2025 18:57
Show Gist options
  • Select an option

  • Save oberstet/c547b523c518c997381dd98b7b7cc9f0 to your computer and use it in GitHub Desktop.

Select an option

Save oberstet/c547b523c518c997381dd98b7b7cc9f0 to your computer and use it in GitHub Desktop.
oberstet@intel-nuci7:~$ cd /tmp/
oberstet@intel-nuci7:/tmp$ wget https://files.pythonhosted.org/packages/ca/1f/1a52736e87b4a22afef615de45e2f509fbfb55c09798620b0c3f394076ef/google_genai-1.16.1.tar.gz
--2025-05-27 20:53:50-- https://files.pythonhosted.org/packages/ca/1f/1a52736e87b4a22afef615de45e2f509fbfb55c09798620b0c3f394076ef/google_genai-1.16.1.tar.gz
Auflösen des Hostnamens files.pythonhosted.org (files.pythonhosted.org) … 2a04:4e42::223, 2a04:4e42:400::223, 2a04:4e42:200::223, ...
Verbindungsaufbau zu files.pythonhosted.org (files.pythonhosted.org)|2a04:4e42::223|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 194270 (190K) [application/octet-stream]
Wird in ‘google_genai-1.16.1.tar.gz’ gespeichert.
google_genai-1.16.1.tar.gz 100%[================================================================================================================>] 189,72K --.-KB/s in 0,1s
2025-05-27 20:53:50 (1,90 MB/s) - ‘google_genai-1.16.1.tar.gz’ gespeichert [194270/194270]
oberstet@intel-nuci7:/tmp$ tar xvzf google_genai-1.16.1.tar.gz
google_genai-1.16.1/
google_genai-1.16.1/LICENSE
google_genai-1.16.1/MANIFEST.in
google_genai-1.16.1/PKG-INFO
google_genai-1.16.1/README.md
google_genai-1.16.1/google/
google_genai-1.16.1/google/genai/
google_genai-1.16.1/google/genai/__init__.py
google_genai-1.16.1/google/genai/_adapters.py
google_genai-1.16.1/google/genai/_api_client.py
google_genai-1.16.1/google/genai/_api_module.py
google_genai-1.16.1/google/genai/_automatic_function_calling_util.py
google_genai-1.16.1/google/genai/_base_url.py
google_genai-1.16.1/google/genai/_common.py
google_genai-1.16.1/google/genai/_extra_utils.py
google_genai-1.16.1/google/genai/_live_converters.py
google_genai-1.16.1/google/genai/_mcp_utils.py
google_genai-1.16.1/google/genai/_replay_api_client.py
google_genai-1.16.1/google/genai/_test_api_client.py
google_genai-1.16.1/google/genai/_tokens_converters.py
google_genai-1.16.1/google/genai/_transformers.py
google_genai-1.16.1/google/genai/batches.py
google_genai-1.16.1/google/genai/caches.py
google_genai-1.16.1/google/genai/chats.py
google_genai-1.16.1/google/genai/client.py
google_genai-1.16.1/google/genai/errors.py
google_genai-1.16.1/google/genai/files.py
google_genai-1.16.1/google/genai/live.py
google_genai-1.16.1/google/genai/live_music.py
google_genai-1.16.1/google/genai/models.py
google_genai-1.16.1/google/genai/operations.py
google_genai-1.16.1/google/genai/pagers.py
google_genai-1.16.1/google/genai/py.typed
google_genai-1.16.1/google/genai/tokens.py
google_genai-1.16.1/google/genai/tunings.py
google_genai-1.16.1/google/genai/types.py
google_genai-1.16.1/google/genai/version.py
google_genai-1.16.1/google_genai.egg-info/
google_genai-1.16.1/google_genai.egg-info/PKG-INFO
google_genai-1.16.1/google_genai.egg-info/SOURCES.txt
google_genai-1.16.1/google_genai.egg-info/dependency_links.txt
google_genai-1.16.1/google_genai.egg-info/requires.txt
google_genai-1.16.1/google_genai.egg-info/top_level.txt
google_genai-1.16.1/pyproject.toml
google_genai-1.16.1/setup.cfg
oberstet@intel-nuci7:/tmp$ find google_genai-1.16.1/ -type f -exec grep -Hi "API_KEY" {} \;
google_genai-1.16.1/README.md:client = genai.Client(api_key='GEMINI_API_KEY')
google_genai-1.16.1/README.md:**Gemini Developer API:** Set `GOOGLE_API_KEY` as shown below:
google_genai-1.16.1/README.md:export GOOGLE_API_KEY='your-api-key'
google_genai-1.16.1/README.md: api_key='GEMINI_API_KEY',
google_genai-1.16.1/PKG-INFO:client = genai.Client(api_key='GEMINI_API_KEY')
google_genai-1.16.1/PKG-INFO:**Gemini Developer API:** Set `GOOGLE_API_KEY` as shown below:
google_genai-1.16.1/PKG-INFO:export GOOGLE_API_KEY='your-api-key'
google_genai-1.16.1/PKG-INFO: api_key='GEMINI_API_KEY',
google_genai-1.16.1/google_genai.egg-info/PKG-INFO:client = genai.Client(api_key='GEMINI_API_KEY')
google_genai-1.16.1/google_genai.egg-info/PKG-INFO:**Gemini Developer API:** Set `GOOGLE_API_KEY` as shown below:
google_genai-1.16.1/google_genai.egg-info/PKG-INFO:export GOOGLE_API_KEY='your-api-key'
google_genai-1.16.1/google_genai.egg-info/PKG-INFO: api_key='GEMINI_API_KEY',
google_genai-1.16.1/google/genai/_test_api_client.py: api_client = BaseApiClient(api_key='test_api_key')
google_genai-1.16.1/google/genai/_test_api_client.py: api_client = ApiClient(api_key='test_api_key')
google_genai-1.16.1/google/genai/_test_api_client.py: api_client = ApiClient(api_key='test_api_key')
google_genai-1.16.1/google/genai/_api_client.py: api_key: Optional[str] = None,
google_genai-1.16.1/google/genai/_api_client.py: if (project or location) and api_key:
google_genai-1.16.1/google/genai/_api_client.py: # API cannot consume both project/location and api_key.
google_genai-1.16.1/google/genai/_api_client.py: elif credentials and api_key:
google_genai-1.16.1/google/genai/_api_client.py: # API cannot consume both credentials and api_key.
google_genai-1.16.1/google/genai/_api_client.py: env_api_key = os.environ.get('GOOGLE_API_KEY', None)
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = api_key or env_api_key
google_genai-1.16.1/google/genai/_api_client.py: # Explicit credentials take precedence over implicit api_key.
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = None
google_genai-1.16.1/google/genai/_api_client.py: elif (env_location or env_project) and api_key:
google_genai-1.16.1/google/genai/_api_client.py: # Explicit api_key takes precedence over implicit project/location.
google_genai-1.16.1/google/genai/_api_client.py: elif (project or location) and env_api_key:
google_genai-1.16.1/google/genai/_api_client.py: # Explicit project/location takes precedence over implicit api_key.
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = None
google_genai-1.16.1/google/genai/_api_client.py: elif (env_location or env_project) and env_api_key:
google_genai-1.16.1/google/genai/_api_client.py: # Implicit project/location takes precedence over implicit api_key.
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = None
google_genai-1.16.1/google/genai/_api_client.py: if not self.project and not self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: if not ((self.project and self.location) or self.api_key):
google_genai-1.16.1/google/genai/_api_client.py: if self.api_key or self.location == 'global':
google_genai-1.16.1/google/genai/_api_client.py: if not self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: ' provide (`api_key`) arguments. To use the Google Cloud API,'
google_genai-1.16.1/google/genai/_api_client.py: if self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: self._http_options.headers['x-goog-api-key'] = self.api_key
google_genai-1.16.1/google/genai/_api_client.py: and not self.api_key
google_genai-1.16.1/google/genai/_api_client.py: if self.vertexai and not self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: if self.vertexai and not self.api_key:
google_genai-1.16.1/google/genai/caches.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/caches.py: raise ValueError('api_key_string parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/caches.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/caches.py: raise ValueError('api_key_config parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/caches.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/caches.py: setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
google_genai-1.16.1/google/genai/caches.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/caches.py: api_client, getv(from_object, ['api_key_config']), to_object
google_genai-1.16.1/google/genai/_replay_api_client.py: api_key: Optional[str] = None,
google_genai-1.16.1/google/genai/_replay_api_client.py: api_key=api_key,
google_genai-1.16.1/google/genai/_live_converters.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/_live_converters.py: raise ValueError('api_key_string parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/_live_converters.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/_live_converters.py: setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
google_genai-1.16.1/google/genai/_live_converters.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/_live_converters.py: raise ValueError('api_key_config parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/_live_converters.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/_live_converters.py: api_client, getv(from_object, ['api_key_config']), to_object
google_genai-1.16.1/google/genai/live.py: client = genai.Client(api_key=API_KEY)
google_genai-1.16.1/google/genai/live.py: client = genai.Client(api_key=API_KEY)
google_genai-1.16.1/google/genai/live.py: client = genai.Client(api_key=API_KEY)
google_genai-1.16.1/google/genai/live.py: client = genai.Client(api_key=API_KEY)
google_genai-1.16.1/google/genai/live.py: if self._api_client.api_key:
google_genai-1.16.1/google/genai/live.py: api_key = self._api_client.api_key
google_genai-1.16.1/google/genai/live.py: uri = f'{base_url}/ws/google.ai.generativelanguage.{version}.GenerativeService.BidiGenerateContent?key={api_key}'
google_genai-1.16.1/google/genai/live.py: api_key=_DUMMY_KEY, # Can't be None during initialization
google_genai-1.16.1/google/genai/client.py: `api_key="your-api-key"` or by defining `GOOGLE_API_KEY="your-api-key"` as an
google_genai-1.16.1/google/genai/client.py: api_key: The `API key <https://ai.google.dev/gemini-api/docs/api-key>`_ to
google_genai-1.16.1/google/genai/client.py: client = genai.Client(api_key='my-api-key')
google_genai-1.16.1/google/genai/client.py: api_key: Optional[str] = None,
google_genai-1.16.1/google/genai/client.py: api_key (str): The `API key
google_genai-1.16.1/google/genai/client.py: api_key=api_key,
google_genai-1.16.1/google/genai/client.py: api_key: Optional[str] = None,
google_genai-1.16.1/google/genai/client.py: api_key=api_key,
google_genai-1.16.1/google/genai/client.py: api_key=api_key,
google_genai-1.16.1/google/genai/models.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/models.py: raise ValueError('api_key_string parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/models.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/models.py: raise ValueError('api_key_config parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/models.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/models.py: setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
google_genai-1.16.1/google/genai/models.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/models.py: api_client, getv(from_object, ['api_key_config']), to_object
google_genai-1.16.1/google/genai/live_music.py: if self._api_client.api_key:
google_genai-1.16.1/google/genai/live_music.py: api_key = self._api_client.api_key
google_genai-1.16.1/google/genai/live_music.py: uri = f'{base_url}/ws/google.ai.generativelanguage.{version}.GenerativeService.BidiGenerateMusic?key={api_key}'
google_genai-1.16.1/google/genai/types.py: API_KEY_AUTH = 'API_KEY_AUTH'
google_genai-1.16.1/google/genai/types.py: api_key_string: Optional[str] = Field(
google_genai-1.16.1/google/genai/types.py: api_key_string: Optional[str]
google_genai-1.16.1/google/genai/types.py: api_key_config: Optional[ApiKeyConfig] = Field(
google_genai-1.16.1/google/genai/types.py: api_key_config: Optional[ApiKeyConfigDict]
google_genai-1.16.1/google/genai/_tokens_converters.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/_tokens_converters.py: raise ValueError('api_key_string parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/_tokens_converters.py: if getv(from_object, ['api_key_string']) is not None:
google_genai-1.16.1/google/genai/_tokens_converters.py: setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
google_genai-1.16.1/google/genai/_tokens_converters.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/_tokens_converters.py: raise ValueError('api_key_config parameter is not supported in Gemini API.')
google_genai-1.16.1/google/genai/_tokens_converters.py: if getv(from_object, ['api_key_config']) is not None:
google_genai-1.16.1/google/genai/_tokens_converters.py: api_client, getv(from_object, ['api_key_config']), to_object
oberstet@intel-nuci7:/tmp$ grep -Hi "API_KEY" google_genai-1.16.1/google/genai/client.py
google_genai-1.16.1/google/genai/client.py: `api_key="your-api-key"` or by defining `GOOGLE_API_KEY="your-api-key"` as an
google_genai-1.16.1/google/genai/client.py: api_key: The `API key <https://ai.google.dev/gemini-api/docs/api-key>`_ to
google_genai-1.16.1/google/genai/client.py: client = genai.Client(api_key='my-api-key')
google_genai-1.16.1/google/genai/client.py: api_key: Optional[str] = None,
google_genai-1.16.1/google/genai/client.py: api_key (str): The `API key
google_genai-1.16.1/google/genai/client.py: api_key=api_key,
google_genai-1.16.1/google/genai/client.py: api_key: Optional[str] = None,
google_genai-1.16.1/google/genai/client.py: api_key=api_key,
google_genai-1.16.1/google/genai/client.py: api_key=api_key,
oberstet@intel-nuci7:/tmp$ grep -Hi "API_KEY" google_genai-1.16.1/google/genai/_api_client.py
google_genai-1.16.1/google/genai/_api_client.py: api_key: Optional[str] = None,
google_genai-1.16.1/google/genai/_api_client.py: if (project or location) and api_key:
google_genai-1.16.1/google/genai/_api_client.py: # API cannot consume both project/location and api_key.
google_genai-1.16.1/google/genai/_api_client.py: elif credentials and api_key:
google_genai-1.16.1/google/genai/_api_client.py: # API cannot consume both credentials and api_key.
google_genai-1.16.1/google/genai/_api_client.py: env_api_key = os.environ.get('GOOGLE_API_KEY', None)
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = api_key or env_api_key
google_genai-1.16.1/google/genai/_api_client.py: # Explicit credentials take precedence over implicit api_key.
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = None
google_genai-1.16.1/google/genai/_api_client.py: elif (env_location or env_project) and api_key:
google_genai-1.16.1/google/genai/_api_client.py: # Explicit api_key takes precedence over implicit project/location.
google_genai-1.16.1/google/genai/_api_client.py: elif (project or location) and env_api_key:
google_genai-1.16.1/google/genai/_api_client.py: # Explicit project/location takes precedence over implicit api_key.
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = None
google_genai-1.16.1/google/genai/_api_client.py: elif (env_location or env_project) and env_api_key:
google_genai-1.16.1/google/genai/_api_client.py: # Implicit project/location takes precedence over implicit api_key.
google_genai-1.16.1/google/genai/_api_client.py: self.api_key = None
google_genai-1.16.1/google/genai/_api_client.py: if not self.project and not self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: if not ((self.project and self.location) or self.api_key):
google_genai-1.16.1/google/genai/_api_client.py: if self.api_key or self.location == 'global':
google_genai-1.16.1/google/genai/_api_client.py: if not self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: ' provide (`api_key`) arguments. To use the Google Cloud API,'
google_genai-1.16.1/google/genai/_api_client.py: if self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: self._http_options.headers['x-goog-api-key'] = self.api_key
google_genai-1.16.1/google/genai/_api_client.py: and not self.api_key
google_genai-1.16.1/google/genai/_api_client.py: if self.vertexai and not self.api_key:
google_genai-1.16.1/google/genai/_api_client.py: if self.vertexai and not self.api_key:
oberstet@intel-nuci7:/tmp$ head -n10 google_genai-1.16.1/google/genai/_api_client.py
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
oberstet@intel-nuci7:/tmp$ head -n30 google_genai-1.16.1/google/genai/_api_client.py
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Base client for calling HTTP APIs sending and receiving JSON.
The BaseApiClient is intended to be a private module and is subject to change.
"""
import asyncio
from collections.abc import Awaitable, Generator
import copy
from dataclasses import dataclass
import datetime
import http
import io
import json
import logging
oberstet@intel-nuci7:/tmp$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment