Skip to content

Commit a9ffc60

Browse files
yeesiancopybara-github
authored andcommitted
feat: GenAI SDK client - Add api_key parameter to vertexai.Client`
PiperOrigin-RevId: 800051985
1 parent 219c33f commit a9ffc60

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

vertexai/_genai/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class Client:
122122
def __init__(
123123
self,
124124
*,
125+
api_key: Optional[str] = None,
125126
credentials: Optional[google.auth.credentials.Credentials] = None,
126127
project: Optional[str] = None,
127128
location: Optional[str] = None,
@@ -131,6 +132,9 @@ def __init__(
131132
"""Initializes the client.
132133
133134
Args:
135+
api_key (str): The `API key
136+
<https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/overview#api-keys>`_
137+
to use for authentication. Applies to Vertex AI in express mode only.
134138
credentials (google.auth.credentials.Credentials): The credentials to use
135139
for authentication when calling the Vertex AI APIs. Credentials can be
136140
obtained from environment variables and default credentials. For more
@@ -156,6 +160,7 @@ def __init__(
156160

157161
self._api_client = genai_client.Client._get_api_client(
158162
vertexai=True,
163+
api_key=api_key,
159164
credentials=credentials,
160165
project=project,
161166
location=location,

0 commit comments

Comments
 (0)