Cline - 中文版 Docs
  • Cline Documentation
  • 入门指南
    • 快速开始
    • What is Cline?
  • Basics
    • Cline - 中文版胜算 说明文档
      • Cline 和模型上下文协议 (MCP) 服务器:提升 AI 能力
      • Interactive blocks
        • OpenAPI
      • Integrations
        • Cloud Provider Integration
        • Security Concerns
      • .clineignore 功能支持
  • Cline - 中文版胜算 说明文档
    • 什么是Cline - 胜算云增强版
    • 对于新程序员
    • 安装 Cline-胜算云增强版
    • 安装 Dev Essentials
    • 我们最喜欢的技术栈
    • 上下文管理
    • 型号选择指南
  • Getting Started
    • What is Cline?
    • For New Coders
    • Installing Cline
    • Installing Dev Essentials
    • Our Favorite Tech Stack
    • Context Management
    • Model Selection Guide
  • 提高提示技巧
    • 提示工程指南
    • Cline-胜算云增强版 内存库
  • Improving Your Prompting Skills
    • Prompt Engineering Guide
    • Cline Memory Bank
  • 探索 Cline 的工具
    • Cline-胜算云增强版 工具指南
  • 检查站
  • 计划与行动模式:有效人工智能发展指南
  • 新建任务工具
  • Remote Browser 支持
  • Exploring Cline's Tools
    • Cline Tools Guide
    • Checkpoints
    • Plan & Act Modes: A Guide to Effective AI Development
    • New Task Tool
  • Remote Browser Support
  • 企业解决方案
    • 安全问题
  • 云提供商集成
  • MCP 服务器
  • 自定义说明
  • Security Concerns
    • Security Concerns
  • Cloud Provider Integration
  • MCP Servers
  • Custom Instructions
  • MCP服务器
    • MCP概述
    • MCP市场
  • 从 GitHub 添加 MCP 服务器
  • 配置 MCP 服务器
  • 连接到远程服务器
  • MCP 传输机制
  • MCP 服务器开发协议
  • MCP Servers
    • MCP Overview
  • MCP Marketplace
  • Adding MCP Servers from GitHub
  • Configuring MCP Servers
  • Connecting to a Remote Server
  • MCP Transport Mechanisms
  • MCP Server Development Protocol
  • 自定义模型配置
    • 带有凭证身份验证的 AWS Bedrock
    • 带配置文件身份验证的 AWS Bedrock
    • GCP Vertex AI
  • LiteLLM 和 Cline-胜算云增强版(使用 Codestral)
  • Custom Model Configs
    • AWS Bedrock w/ Credentials Authentication
  • AWS Bedrock w/ Profile Authentication
  • GCP Vertex AI
  • LiteLLM & Cline (using Codestral)
  • 本地运行模型
    • 请先阅读
    • Ollama
    • LM 工作室
  • Ollama
  • LM Studio
  • Running Models Locally
  • More Info
    • Telemetry
    • 遥测
Powered by GitBook
On this page

GCP Vertex AI

PreviousAWS Bedrock w/ Profile AuthenticationNextLiteLLM & Cline (using Codestral)

Last updated 2 months ago

Overview

GCP Vertex AI: A fully managed service that provides access to leading generative AI models—such as Anthropic’s Claude 3.5 Sonnet v2—through Google Cloud. .

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.


Step 1: Prepare Your GCP Environment

1.1 Create or Use a GCP Project

  • Sign in to the GCP Console: .

  • Select or Create a Project: Use an existing project or create a new one dedicated to Vertex AI.

    (Screenshot suggestion: Project selection/creation screen in the GCP Console)

1.2 Set Up IAM Permissions and Service Accounts

  • Assign Required Roles:

    • Grant your user (or service account) the Vertex AI User role (roles/aiplatform.user).

    • For service accounts, also attach the Vertex AI Service Agent role (roles/aiplatform.serviceAgent) to enable certain operations.

    • Consider additional predefined roles as needed:

      • Vertex AI Platform Express Admin

      • Vertex AI Platform Express User

      • Vertex AI Migration Service User

    (Screenshot suggestion: IAM console showing role assignments)

  • Cross-Project Resource Access:

    • For BigQuery tables in different projects, assign the BigQuery Data Viewer role.

    • For Cloud Storage buckets in different projects, assign the Storage Object Viewer role.

    • For external data sources, refer to the .


Step 2: Verify Regional and Model Access

2.1 Choose and Confirm a Region

Vertex AI supports eight regions. Select a region that meets your latency, compliance, and capacity needs. Examples include:

  • us-east5 (Columbus, Ohio)

  • us-east1 (South Carolina)

  • us-east4 (Northern Virginia)

  • us-central1 (Iowa)

  • us-west1 (The Dalles, Oregon)

  • us-west4 (Las Vegas, Nevada)

  • europe-west1 (Belgium)

  • asia-southeast1 (Singapore)

(Screenshot suggestion: List or map of supported regions in the Vertex AI dashboard)

2.2 Enable the Claude 3.5 Sonnet v2 Model

  • Open Vertex AI Model Garden: In the Cloud Console, navigate to Vertex AI → Model Garden.

  • Enable Claude 3.5 Sonnet v2: Locate the model card for Claude 3.5 Sonnet v2 and click Enable.

    (Screenshot suggestion: Model Garden showing the Claude 3.5 Sonnet v2 model card with the Enable button)


Step 3: Configure the Cline VS Code Extension

3.1 Install and Open Cline

  • Install the Cline Extension:

    • Open VS Code.

    • Navigate to the Extensions Marketplace (Ctrl+Shift+X or Cmd+Shift+X).

    • Search for Cline and install the extension.

3.2 Configure Cline Settings

  • Open Cline Settings: Click the settings ⚙️ icon within the Cline extension.

  • Set API Provider: Choose GCP Vertex AI from the API Provider dropdown.

  • Enter Your Google Cloud Project ID: Provide the project ID you set up earlier.

  • Select the Region: Choose one of the supported regions (e.g., us-east5).

  • Select the Model: From the available list, choose Claude 3.5 Sonnet v2.

  • Save and Test: Save your settings and test by sending a simple prompt (e.g., “Generate a Python function to check if a number is prime.”).

    (Screenshot suggestion: Cline settings showing project ID, region, and model selection)


Step 4: Authentication and Credentials Setup

Option A: Using Your Google Account (User Credentials)

  1. Initialize and Authenticate:

    Copy

    gcloud init
    gcloud auth application-default login
  • This sets up Application Default Credentials (ADC) using your Google account.

(Screenshot suggestion: Terminal output for successful gcloud auth application-default login)

  1. Restart VS Code: Ensure VS Code is restarted so that the Cline extension picks up the new credentials.

Option B: Using a Service Account (JSON Key)

  1. Create a Service Account:

    • In the GCP Console, navigate to IAM & Admin > Service Accounts.

    • Create a new service account (e.g., “vertex-ai-client”).

  2. Assign Roles:

    • Attach Vertex AI User (roles/aiplatform.user).

    • Attach Vertex AI Service Agent (roles/aiplatform.serviceAgent).

    • Optionally, add other roles as required.

    (Screenshot suggestion: Creating a service account with role assignments)

  3. Generate a JSON Key:

    • In the Service Accounts section, manage keys for your service account and download the JSON key.

  4. Set the Environment Variable:

    Copy

    export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
    • This instructs Google Cloud client libraries (and Cline) to use this key.

    (Screenshot suggestion: Terminal showing the export command)

  5. Restart VS Code: Launch VS Code from a terminal where the GOOGLE_APPLICATION_CREDENTIALS variable is set.


Step 5: Security, Monitoring, and Best Practices

5.1 Enforce Least Privilege

  • Principle of Least Privilege: Only grant the minimum necessary permissions. Custom roles can offer finer control compared to broad predefined roles.

5.2 Manage Resource Access

  • Project vs. Resource-Level Access: 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.

5.3 Monitor Usage and Quotas

  • Model Observability Dashboard:

    • In the Vertex AI Console, navigate to the Model Observability dashboard.

    • Monitor metrics such as request throughput, latency, and error rates (including 429 quota errors).

    (Screenshot suggestion: Model Observability dashboard with error metrics highlighted)

  • Quota Management:

    • If you encounter 429 errors, check the IAM & Admin > Quotas page.

5.4 Service Agents and Cross-Project Considerations

  • Service Agents: Be aware of the different service agents:

    • Vertex AI Service Agent

    • Vertex AI RAG Data Service Agent

    • Vertex AI Custom Code Service Agent

    • Vertex AI Extension Service Agent

  • Cross-Project Access: For resources in other projects (e.g., BigQuery, Cloud Storage), ensure that the appropriate roles (BigQuery Data Viewer, Storage Object Viewer) are assigned.


Conclusion

By following these steps, your enterprise team can securely integrate GCP Vertex AI with the Cline VS Code extension to harness the power of Claude 3.5 Sonnet v2:

  • Prepare Your GCP Environment: Create or use a project, configure IAM with least privilege, and ensure necessary roles (including the Vertex AI Service Agent role) are attached.

  • Verify Regional and Model Access: Confirm that your chosen region supports Claude 3.5 Sonnet v2 and that the model is enabled.

  • Configure Cline in VS Code: Install Cline, enter your project ID, select the appropriate region, and choose the model.

  • Set Up Authentication: Use either user credentials (via gcloud auth application-default login) or a service account with a JSON key.

  • Implement Security and Monitoring: Adhere to best practices for IAM, manage resource access carefully, and monitor usage with the Model Observability dashboard.

This guide will be updated as GCP Vertex AI and Cline evolve. Always refer to the latest documentation for current practices.

Download VS Code: .

Install the Google Cloud CLI: Follow the .

Best Practices: Refer to .

Request a quota increase if necessary. .

For further details, please consult the and your internal security policies. Happy coding!

Learn more about GCP Vertex AI
Google Cloud Console
GCP Vertex AI Access Control documentation
Download Visual Studio Code
installation guide
GCP IAM Best Practices
Learn more about GCP Vertex AI Quotas
GCP Vertex AI Documentation