| | |
- google.genai._interactions.BaseTransport(builtins.object)
-
- AICoreDynamicTransport
- google.genai.client.Client(builtins.object)
-
- Client
- httpx.AsyncBaseTransport(builtins.object)
-
- AsyncAICoreDynamicTransport
class AICoreDynamicTransport(google.genai._interactions.BaseTransport) |
| |
AICoreDynamicTransport(proxy_client: gen_ai_hub.proxy.core.base.BaseProxyClient, **deployment_selector_kwargs)
Synchronous transport that dynamically resolves deployment URLs per request. |
| |
- Method resolution order:
- AICoreDynamicTransport
- google.genai._interactions.BaseTransport
- builtins.object
Methods defined here:
- __init__(self, proxy_client: gen_ai_hub.proxy.core.base.BaseProxyClient, **deployment_selector_kwargs)
- Transport constructor.
:param proxy_client: The proxy client used to select deployments.
:type proxy_client: BaseProxyClient
- close(self)
- Closes the inner transport.
- get_selector_kwargs(self)
- Get the deployment selector kwargs.
:return: The deployment selector kwargs.
:rtype: dict
- handle_request(self, request: httpx.Request) -> httpx.Response
- Handles the request by rewriting it to route through the appropriate AI Core deployment.
:param request: The original HTTPX request.
:type request: httpx.Request
:return: The HTTPX response from the AI Core deployment.
:rtype: httpx.Response
Methods inherited from google.genai._interactions.BaseTransport:
- __enter__(self: 'T') -> 'T'
- __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None'
Data descriptors inherited from google.genai._interactions.BaseTransport:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class AsyncAICoreDynamicTransport(httpx.AsyncBaseTransport) |
| |
AsyncAICoreDynamicTransport(proxy_client: gen_ai_hub.proxy.core.base.BaseProxyClient, **deployment_selector_kwargs)
Asynchronous transport that dynamically resolves deployment URLs per request. |
| |
- Method resolution order:
- AsyncAICoreDynamicTransport
- httpx.AsyncBaseTransport
- builtins.object
Methods defined here:
- __init__(self, proxy_client: gen_ai_hub.proxy.core.base.BaseProxyClient, **deployment_selector_kwargs)
- Transport constructor.
:param proxy_client: The proxy client used to select deployments.
:type proxy_client: BaseProxyClient
- async aclose(self)
- Closes the inner transport.
- get_selector_kwargs(self)
- get the deployment selector kwargs.
:return: The deployment selector kwargs.
:rtype: dict
- async handle_async_request(self, request: httpx.Request) -> httpx.Response
- Handles the request by rewriting it to route through the appropriate AI Core deployment.
:param request: The original HTTPX request.
:type request: httpx.Request
:return: The HTTPX response from the AI Core deployment.
:rtype: httpx.Response
Methods inherited from httpx.AsyncBaseTransport:
- async __aenter__(self: 'A') -> 'A'
- async __aexit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None'
Data descriptors inherited from httpx.AsyncBaseTransport:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Client(google.genai.client.Client) |
| |
Client(vertexai: bool = True, project: str = 'placeholder', location: str = 'placeholder', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: gen_ai_hub.proxy.core.base.BaseProxyClient = None, timeout: int = None, **kwargs)
Unified, native-feeling client that dynamically routes requests
through SAP AI Core deployments based on the requested identifiers e.g. model name. |
| |
- Method resolution order:
- Client
- google.genai.client.Client
- builtins.object
Methods defined here:
- __init__(self, vertexai: bool = True, project: str = 'placeholder', location: str = 'placeholder', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: gen_ai_hub.proxy.core.base.BaseProxyClient = None, timeout: int = None, **kwargs)
- Initializes the Client.
:param vertexai: to indicate Vertex AI usage, defaults to True
:type vertexai: bool, optional
:param project: the GCP project, defaults to "placeholder"
:type project: str, optional
:param location: the GCP location, defaults to "placeholder"
:type location: str, optional
:param deployment_id: the deployment identifier, defaults to ""
:type deployment_id: str, optional
:param config_id: the configuration identifier, defaults to ""
:type config_id: str, optional
:param config_name: the configuration name, defaults to ""
:type config_name: str, optional
:param proxy_client: the proxy client to use, defaults to None
:type proxy_client: BaseProxyClient, optional
:param timeout: the request timeout, defaults to None
:type timeout: int, optional
Methods inherited from google.genai.client.Client:
- __del__(self) -> None
- __enter__(self) -> 'Client'
- __exit__(self, exc_type: Optional[Exception], exc_value: Optional[Exception], traceback: Optional[traceback]) -> None
- close(self) -> None
- Closes the synchronous client explicitly.
However, it doesn't close the async client, which can be closed using the
Client.aio.aclose() method or using the async context manager.
Usage:
.. code-block:: python
from google.genai import Client
client = Client(
vertexai=True, project='my-project-id', location='us-central1'
)
response_1 = client.models.generate_content(
model='gemini-2.0-flash',
contents='Hello World',
)
response_2 = client.models.generate_content(
model='gemini-2.0-flash',
contents='Hello World',
)
# Close the client to release resources.
client.close()
Readonly properties inherited from google.genai.client.Client:
- aio
- auth_tokens
- batches
- caches
- chats
- file_search_stores
- files
- interactions
- models
- operations
- tunings
- vertexai
- Returns whether the client is using the Vertex AI API.
Data descriptors inherited from google.genai.client.Client:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |