|
1 | 1 | --- |
2 | 2 | title: "Google Gemini" |
3 | | -description: "Configure GCP Vertex AI with CodinIT to access leading generative AI models like Claude 4.5 Sonnet v2. This guide covers GCP environment setup." |
| 3 | +description: "Configure GCP Vertex AI to access Gemini and Claude models through Google Cloud." |
4 | 4 | --- |
5 | 5 |
|
6 | | -### Overview |
| 6 | +Access leading AI models like Gemini and Claude 4.5 Sonnet through Google Cloud's Vertex AI platform. |
7 | 7 |
|
8 | | -**GCP Vertex AI:**\ |
9 | | -A fully managed service that provides access to leading generative AI models—such as Anthropic's Claude 4.5 Sonnet v2—through Google Cloud.\ |
10 | | -[Learn more about GCP Vertex AI](https://cloud.google.com/vertex-ai). |
| 8 | +**Website:** [https://cloud.google.com/vertex-ai](https://cloud.google.com/vertex-ai) |
11 | 9 |
|
12 | | -This guide is tailored for organizations with established GCP environments (leveraging IAM roles, service accounts, and best practices in resource management) to ensure secure and compliant usage. |
| 10 | +## Prerequisites |
13 | 11 |
|
14 | | ---- |
15 | | - |
16 | | -### Step 1: Prepare Your GCP Environment |
17 | | - |
18 | | -#### 1.1 Create or Use a GCP Project |
19 | | - |
20 | | -- **Sign in to the GCP Console:**\ |
21 | | - [Google Cloud Console](https://console.cloud.google.com/) |
22 | | -- **Select or Create a Project:**\ |
23 | | - Use an existing project or create a new one dedicated to Vertex AI. |
24 | | - |
25 | | -#### 1.2 Set Up IAM Permissions and Service Accounts |
26 | | - |
27 | | -- **Assign Required Roles:** |
28 | | - |
29 | | - - Grant your user (or service account) the **Vertex AI User** role (`roles/aiplatform.user`) |
30 | | - - For service accounts, also attach the **Vertex AI Service Agent** role (`roles/aiplatform.serviceAgent`) to enable certain operations |
31 | | - - Consider additional predefined roles as needed: |
32 | | - - Vertex AI Platform Express Admin |
33 | | - - Vertex AI Platform Express User |
34 | | - - Vertex AI Migration Service User |
35 | | - |
36 | | -- **Cross-Project Resource Access:** |
37 | | - - For BigQuery tables in different projects, assign the **BigQuery Data Viewer** role |
38 | | - - For Cloud Storage buckets in different projects, assign the **Storage Object Viewer** role |
39 | | - - For external data sources, refer to the [GCP Vertex AI Access Control documentation](https://cloud.google.com/vertex-ai/general/access-control) |
40 | | - |
41 | | ---- |
42 | | - |
43 | | -### Step 2: Verify Regional and Model Access |
44 | | - |
45 | | -#### 2.1 Choose and Confirm a Region |
46 | | - |
47 | | -Vertex AI supports multiple regions. Select a region that meets your latency, compliance, and capacity needs. Examples include: |
| 12 | +- GCP account with billing enabled |
| 13 | +- GCP project created |
| 14 | +- IAM permissions configured |
48 | 15 |
|
49 | | -- **us-east5 (Columbus, Ohio)** |
50 | | -- **us-central1 (Iowa)** |
51 | | -- **europe-west1 (Belgium)** |
52 | | -- **europe-west4 (Netherlands)** |
53 | | -- **asia-southeast1 (Singapore)** |
54 | | -- **global (Global)** |
55 | | - |
56 | | -The Global endpoint may offer higher availability and reduce resource exhausted errors. Only Gemini models are supported. |
57 | | - |
58 | | -#### 2.2 Enable the Claude 4.5 Sonnet v2 Model |
59 | | - |
60 | | -- **Open Vertex AI Model Garden:**\ |
61 | | - In the Cloud Console, navigate to **Vertex AI → Model Garden** |
62 | | -- **Enable Claude 4.5 Sonnet v2:**\ |
63 | | - Locate the model card for Claude 4.5 Sonnet v2 and click **Enable** |
64 | | - |
65 | | ---- |
66 | | - |
67 | | - |
68 | | -#### 3.1 Install and Open CodinIT |
69 | | - |
70 | | -- **Download VS Code:**\ |
71 | | - [Download Visual Studio Code](https://code.visualstudio.com/) |
72 | | -- **Install the CodinIT Extension:** |
73 | | - - Open VS Code |
74 | | - - Navigate to the Extensions Marketplace (Ctrl+Shift+X or Cmd+Shift+X) |
75 | | - - Search for **Github** and install the extension & Clone the repository |
76 | | - |
77 | | -#### 3.2 Configure CodinIT Settings |
78 | | - |
79 | | -- **Open CodinIT Settings:**\ |
80 | | - Click the settings ⚙️ icon within the CodinIT extension |
81 | | -- **Set API Provider:**\ |
82 | | - Choose **GCP Vertex AI** from the API Provider dropdown |
83 | | -- **Enter Your Google Cloud Project ID:**\ |
84 | | - Provide the project ID you set up earlier |
85 | | -- **Select the Region:**\ |
86 | | - Choose one of the supported regions (e.g., `us-east5`) |
87 | | -- **Select the Model:**\ |
88 | | - From the available list, choose **Claude 4.5 Sonnet v2** |
89 | | -- **Save and Test:**\ |
90 | | - Save your settings and test by sending a simple prompt (e.g., "Generate a Python function to check if a number is prime.") |
91 | | - |
92 | | ---- |
| 16 | +## Setup Steps |
93 | 17 |
|
94 | | -### Step 4: Authentication and Credentials Setup |
| 18 | +### 1. Prepare GCP Environment |
95 | 19 |
|
96 | | -#### Option A: Using Your Google Account (User Credentials) |
| 20 | +1. **Sign in:** [Google Cloud Console](https://console.cloud.google.com/) |
| 21 | +2. **Create/select project:** Use existing or create new project |
| 22 | +3. **Set up IAM:** |
| 23 | + - Grant **Vertex AI User** role (`roles/aiplatform.user`) |
| 24 | + - For service accounts, add **Vertex AI Service Agent** role (`roles/aiplatform.serviceAgent`) |
97 | 25 |
|
98 | | -1. **Install the Google Cloud CLI:**\ |
99 | | - Follow the [installation guide](https://cloud.google.com/sdk/install) |
100 | | -2. **Initialize and Authenticate:** |
| 26 | +### 2. Choose Region and Enable Models |
101 | 27 |
|
102 | | - ```bash |
103 | | - gcloud init |
104 | | - gcloud auth application-default login |
105 | | - ``` |
| 28 | +1. **Select region:** Choose region for latency/compliance needs (e.g., `us-east5`, `us-central1`, `europe-west1`) |
| 29 | + - Use `global` endpoint for higher availability (Gemini only) |
| 30 | +2. **Enable models:** Go to Vertex AI → Model Garden and enable desired models (e.g., Claude 4.5 Sonnet v2) |
106 | 31 |
|
107 | | - - This sets up Application Default Credentials (ADC) using your Google account |
| 32 | +### 3. Configure CodinIT |
108 | 33 |
|
109 | | -3. **Restart VS Code:**\ |
110 | | - Ensure VS Code is restarted so that the CodinIT extension picks up the new credentials |
| 34 | +1. Install CodinIT extension in VS Code |
| 35 | +2. Click settings icon (⚙️) |
| 36 | +3. Select **GCP Vertex AI** as API Provider |
| 37 | +4. Enter your **Google Cloud Project ID** |
| 38 | +5. Select your **Region** |
| 39 | +6. Choose your **Model** (e.g., Claude 4.5 Sonnet v2) |
| 40 | +7. Save and test |
111 | 41 |
|
112 | | -#### Option B: Using a Service Account (JSON Key) |
| 42 | +### 4. Authentication |
113 | 43 |
|
114 | | -1. **Create a Service Account:** |
| 44 | +**Option A: User Credentials** |
| 45 | +```bash |
| 46 | +gcloud init |
| 47 | +gcloud auth application-default login |
| 48 | +``` |
| 49 | +Restart VS Code after authentication. |
115 | 50 |
|
116 | | - - In the GCP Console, navigate to **IAM & Admin > Service Accounts** |
117 | | - - Create a new service account (e.g., "vertex-ai-client") |
| 51 | +**Option B: Service Account** |
| 52 | +1. Create service account in GCP Console |
| 53 | +2. Assign Vertex AI User and Service Agent roles |
| 54 | +3. Generate JSON key |
| 55 | +4. Set environment variable: |
| 56 | + ```bash |
| 57 | + export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json" |
| 58 | + ``` |
| 59 | +5. Launch VS Code from terminal with this variable set |
118 | 60 |
|
119 | | -2. **Assign Roles:** |
120 | | - |
121 | | - - Attach **Vertex AI User** (`roles/aiplatform.user`) |
122 | | - - Attach **Vertex AI Service Agent** (`roles/aiplatform.serviceAgent`) |
123 | | - - Optionally, add other roles as required |
124 | | - |
125 | | -3. **Generate a JSON Key:** |
126 | | - |
127 | | - - In the Service Accounts section, manage keys for your service account and download the JSON key |
128 | | - |
129 | | -4. **Set the Environment Variable:** |
130 | | - |
131 | | - ```bash |
132 | | - export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json" |
133 | | - ``` |
134 | | - |
135 | | - - This instructs Google Cloud client libraries (and CodinIT) to use this key |
136 | | - |
137 | | -5. **Restart VS Code:**\ |
138 | | - Launch VS Code from a terminal where the `GOOGLE_APPLICATION_CREDENTIALS` variable is set |
139 | | - |
140 | | ---- |
141 | | - |
142 | | -### Step 5: Security, Monitoring, and Best Practices |
143 | | - |
144 | | -#### 5.1 Enforce Least Privilege |
145 | | - |
146 | | -- **Principle of Least Privilege:**\ |
147 | | - Only grant the minimum necessary permissions. Custom roles can offer finer control compared to broad predefined roles |
148 | | -- **Best Practices:**\ |
149 | | - Refer to [GCP IAM Best Practices](https://cloud.google.com/iam/best-practices) |
150 | | - |
151 | | -#### 5.2 Manage Resource Access |
152 | | - |
153 | | -- **Project vs. Resource-Level Access:**\ |
154 | | - Access can be managed at both levels. Note that resource-level permissions (e.g., for BigQuery or Cloud Storage) add to, but do not override, project-level policies |
155 | | - |
156 | | -#### 5.3 Monitor Usage and Quotas |
157 | | - |
158 | | -- **Model Observability Dashboard:** |
159 | | - |
160 | | - - In the Vertex AI Console, navigate to the **Model Observability** dashboard |
161 | | - - Monitor metrics such as request throughput, latency, and error rates (including 429 quota errors) |
162 | | - |
163 | | -- **Quota Management:** |
164 | | - - If you encounter 429 errors, check the **IAM & Admin > Quotas** page |
165 | | - - Request a quota increase if necessary\ |
166 | | - [Learn more about GCP Vertex AI Quotas](https://cloud.google.com/vertex-ai/quotas) |
167 | | - |
168 | | -#### 5.4 Service Agents and Cross-Project Considerations |
169 | | - |
170 | | -- **Service Agents:**\ |
171 | | - Be aware of the different service agents: |
172 | | - |
173 | | - - Vertex AI Service Agent |
174 | | - - Vertex AI RAG Data Service Agent |
175 | | - - Vertex AI Custom Code Service Agent |
176 | | - - Vertex AI Extension Service Agent |
177 | | - |
178 | | -- **Cross-Project Access:**\ |
179 | | - For resources in other projects (e.g., BigQuery, Cloud Storage), ensure that the appropriate roles (BigQuery Data Viewer, Storage Object Viewer) are assigned |
180 | | - |
181 | | ---- |
| 61 | +## Supported Regions |
182 | 62 |
|
183 | | -### Conclusion |
| 63 | +- `us-east5` (Columbus, Ohio) |
| 64 | +- `us-central1` (Iowa) |
| 65 | +- `europe-west1` (Belgium) |
| 66 | +- `europe-west4` (Netherlands) |
| 67 | +- `asia-southeast1` (Singapore) |
| 68 | +- `global` (Global - Gemini only) |
184 | 69 |
|
185 | | -By following these steps, your enterprise team can securely integrate GCP Vertex AI with the CodinIT VS Code extension to harness the power of **Claude 4.5 Sonnet v2**: |
| 70 | +## Notes |
186 | 71 |
|
187 | | -- **Prepare Your GCP Environment:**\ |
188 | | - Create or use a project, configure IAM with least privilege, and ensure necessary roles (including the Vertex AI Service Agent role) are attached |
189 | | -- **Verify Regional and Model Access:**\ |
190 | | - Confirm that your chosen region supports Claude 4.5 Sonnet v2 and that the model is enabled |
191 | | -- **Configure CodinIT in VS Code:**\ |
192 | | - Install CodinIT, enter your project ID, select the appropriate region, and choose the model |
193 | | -- **Set Up Authentication:**\ |
194 | | - Use either user credentials (via `gcloud auth application-default login`) or a service account with a JSON key |
195 | | -- **Implement Security and Monitoring:**\ |
196 | | - Adhere to best practices for IAM, manage resource access carefully, and monitor usage with the Model Observability dashboard |
| 72 | +- **Cross-region inference:** Check "Cross Region Inference" for models requiring inference profiles |
| 73 | +- **First-time use:** Some models (e.g., Anthropic) require submitting use case form via Console |
| 74 | +- **Permissions:** Minimal required: `bedrock:InvokeModel`, `bedrock:InvokeModelWithResponseStream` |
| 75 | +- **Monitoring:** Use CloudWatch and CloudTrail for logging and monitoring |
| 76 | +- **Security:** Follow [GCP IAM Best Practices](https://cloud.google.com/iam/best-practices) |
197 | 77 |
|
198 | | -For further details, please consult the [GCP Vertex AI Documentation](https://cloud.google.com/vertex-ai/docs) and your internal security policies.\ |
199 | | -Happy coding! |
| 78 | +## Resources |
200 | 79 |
|
201 | | -_This guide will be updated as GCP Vertex AI and CodinIT evolve. Always refer to the latest documentation for current practices._ |
| 80 | +- [GCP Vertex AI Documentation](https://cloud.google.com/vertex-ai/docs) |
| 81 | +- [Access Control](https://cloud.google.com/vertex-ai/general/access-control) |
| 82 | +- [Quotas](https://cloud.google.com/vertex-ai/quotas) |
0 commit comments