gen_ai_hub.proxy.native.google_genai package¶
- class gen_ai_hub.proxy.native.google_genai.Client(vertexai: bool = True, project: str = 'placeholder', location: str = 'placeholder', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: BaseProxyClient = None, timeout: int = None, **kwargs)¶
Bases:
ClientUnified, native-feeling client that dynamically routes requests through SAP AI Core deployments based on the requested identifiers e.g. model name.
- __init__(vertexai: bool = True, project: str = 'placeholder', location: str = 'placeholder', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: BaseProxyClient = None, timeout: int = None, **kwargs)¶
Initializes the Client.
- Parameters:
vertexai (bool, optional) – to indicate Vertex AI usage, defaults to True
project (str, optional) – the GCP project, defaults to “placeholder”
location (str, optional) – the GCP location, defaults to “placeholder”
deployment_id (str, optional) – the deployment identifier, defaults to “”
config_id (str, optional) – the configuration identifier, defaults to “”
config_name (str, optional) – the configuration name, defaults to “”
proxy_client (BaseProxyClient, optional) – the proxy client to use, defaults to None
timeout (int, optional) – the request timeout, defaults to None
- class gen_ai_hub.proxy.native.google_genai.AICoreDynamicTransport(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Bases:
BaseTransportSynchronous transport that dynamically resolves deployment URLs per request.
- __init__(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Transport constructor.
- Parameters:
proxy_client (BaseProxyClient) – The proxy client used to select deployments.
- close()¶
Closes the inner transport.
- get_selector_kwargs()¶
Get the deployment selector kwargs.
- Returns:
The deployment selector kwargs.
- Return type:
dict
- handle_request(request: Request) Response¶
Handles the request by rewriting it to route through the appropriate AI Core deployment.
- Parameters:
request (httpx.Request) – The original HTTPX request.
- Returns:
The HTTPX response from the AI Core deployment.
- Return type:
httpx.Response
- class gen_ai_hub.proxy.native.google_genai.AsyncAICoreDynamicTransport(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Bases:
AsyncBaseTransportAsynchronous transport that dynamically resolves deployment URLs per request.
- __init__(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Transport constructor.
- Parameters:
proxy_client (BaseProxyClient) – The proxy client used to select deployments.
- async aclose()¶
Closes the inner transport.
- get_selector_kwargs()¶
get the deployment selector kwargs.
- Returns:
The deployment selector kwargs.
- Return type:
dict
- async handle_async_request(request: Request) Response¶
Handles the request by rewriting it to route through the appropriate AI Core deployment.
- Parameters:
request (httpx.Request) – The original HTTPX request.
- Returns:
The HTTPX response from the AI Core deployment.
- Return type:
httpx.Response